Thanksgiving Cosmetics (#278)

* Added chickens to Holiday Manager (Thanksgiving)
Added TextEffect
Moved all the effects to a different package to make it easier to find
Added method in Effect to get the Effect Location

* Removed(?) wildcard import

* Testing New year thing
Added some symbols to UtilBlockText

* Allow multiple pets with the same EntityType

* Added Stray Morph
Added Shulker Pet
Added code for a possible new year effect
Added Metal Man Morph to the menus
Added Metal Man Morph as an yearly bonus for PPC subscriptions

* Added chickens to Holiday Manager (Thanksgiving)
Added TextEffect
Moved all the effects to a different package to make it easier to find
Added method in Effect to get the Effect Location

* Removed(?) wildcard import

* Testing New year thing
Added some symbols to UtilBlockText

* Allow multiple pets with the same EntityType

* Added Stray Morph
Added Shulker Pet
Added code for a possible new year effect
Added Metal Man Morph to the menus
Added Metal Man Morph as an yearly bonus for PPC subscriptions

* I seriously don't remember what is in this commit, I'm just doing it to
fix the thing with develop...

* Fixed Pet menu
Fixed morph menu
Changed from List to Set

* Changed from PurchasUnknownSalesPackage to AddUnknownSalesPackageOwned

* Added Santa Morph
Removed Sleigh Morph
Changed all the cosmetics GUIs to start on the second row, instead of the first

* Changed some stuff from Holiday Manager so now chickens will walk around when spawned

* Added sound effects to Metal Man
Added slowness to Metal Man

* Added new lore for the Metal Man Morph description
Added Stray Morph Ability
Fixed some problems with the Thanksgiving Chickens

* Added Fated giveaway manager and animation
Moved titan and fated giveaway managers to a new package

* Fixed lores for Stray morph and Shulker pet
Changed ability of Stray morph

* Removed Stray and Shulker pet from the menu
Deleted Pet class since it was not being used
Changed position of achievement on the menu
Changed color of chicken's name
Changed colors of Power Play message
Stray morph, Santa morph and Shulker pet are hidden from the menus for now
Removed feathers dropping from chickens, changed them to snow particles

* Added hover ability to Metal Man Morph

* Fixed some stuff on Metal Man
This commit is contained in:
LCastr0 2016-11-17 05:06:00 -02:00 committed by Shaun Bennett
parent db1598f896
commit b862a30c76
100 changed files with 2335 additions and 1334 deletions

View File

@ -524,5 +524,33 @@ public class UtilBlockText
{0,1,0,0},
{1,1,1,1}
});
alphabet.put(':', new int[][]
{
{0},
{1},
{0},
{1},
{0}
});
alphabet.put('=', new int[][]
{
{0,0,0},
{1,1,1},
{0,0,0},
{1,1,1},
{0,0,0}
});
// THIS IS A SINGLE SPACE
alphabet.put('|', new int[][]
{
{0},
{0},
{0},
{0},
{0}
});
}
}

View File

@ -114,4 +114,22 @@ public class UtilFirework
playFirework(location, FireworkEffect.builder().withColor(Color.RED).withColor(Color.BLUE)
.withColor(Color.WHITE).withFade(Color.RED).withFade(Color.BLUE).withFade(Color.WHITE).build());
}
public static FireworkEffect getRandomFireworkEffect(boolean fade, int maxColors, int maxFade)
{
FireworkEffect.Builder builder = FireworkEffect.builder().with(Type.values()[UtilMath.r(Type.values().length)])
.withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))).flicker(UtilMath.random.nextBoolean()).trail(UtilMath.random.nextBoolean());
if (fade)
{
for (int i = 0; i < maxFade; i++)
{
builder.withFade(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256)));
}
}
for (int i = 0; i < maxColors; i++)
{
builder.withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256)));
}
return builder.build();
}
}

View File

@ -9,6 +9,9 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagLong;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -22,8 +25,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.structs.ItemContainer;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagLong;
public class UtilItem
{
@ -1216,6 +1217,27 @@ public class UtilItem
return ent;
}
public static ItemStack getVersionSpecificItem(Player player, UtilPlayer.PlayerVersion requiredVersion, ItemStack base)
{
if (UtilPlayer.getPlayerVersion(player).compare(requiredVersion))
{
return base;
}
else
{
ItemStack barrier = new ItemStack(Material.BARRIER);
ItemMeta meta = barrier.getItemMeta();
meta.setDisplayName(base.getItemMeta().getDisplayName());
List<String> lore = new ArrayList<>();
lore.addAll(base.getItemMeta().getLore());
lore.add(" ");
lore.add(C.cRedB + "REQUIRES VERSION " + requiredVersion.getFriendlyName() + "+!");
meta.setLore(lore);
barrier.setItemMeta(meta);
return barrier;
}
}
public static double getAttackDamage(Material type)
{
return ItemDamage.get(type);

View File

@ -3,6 +3,7 @@ package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -10,8 +11,21 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ClickEvent.Action;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTracker;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.PlayerConnection;
import net.minecraft.server.v1_8_R3.WorldBorder;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -33,18 +47,6 @@ import org.bukkit.util.Vector;
import mineplex.core.common.MinecraftVersion;
import mineplex.core.common.events.PlayerMessageEvent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ClickEvent.Action;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTracker;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.PlayerConnection;
import net.minecraft.server.v1_8_R3.WorldBorder;
import java.util.*;
public class UtilPlayer
{
@ -1124,4 +1126,49 @@ public class UtilPlayer
{
return (playerUUID.hashCode() & 1) == 1;
}
public static PlayerVersion getPlayerVersion(Player player)
{
int playerVersion = ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion();
if (playerVersion >= 210)
{
return PlayerVersion._1_10;
}
else if (playerVersion >= 107)
{
return PlayerVersion._1_9;
}
return PlayerVersion._1_8;
}
public enum PlayerVersion
{
_1_8(47, "1.8"),
_1_9(107, "1.9"),
_1_10(210, "1.10");
private int _version;
private String _friendlyName;
PlayerVersion(int version, String friendlyName)
{
_version = version;
_friendlyName = friendlyName;
}
public int getVersion()
{
return _version;
}
public String getFriendlyName()
{
return _friendlyName;
}
public boolean compare(PlayerVersion versionToCompare)
{
return versionToCompare.getVersion() >= getVersion();
}
}
}

View File

@ -1,6 +1,12 @@
package mineplex.core.common.util;
import javax.imageio.ImageIO;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
@ -764,4 +770,35 @@ public class UtilText
}
return stringBuilder.toString();
}
/**
* Creates an image based on a string
* Removed from EffectLib
* @param font The font that is used
* @param s The string
* @return A buffered image containing the text
*/
public static BufferedImage stringToBufferedImage(Font font, String s) {
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = img.getGraphics();
g.setFont(font);
FontRenderContext frc = g.getFontMetrics().getFontRenderContext();
Rectangle2D rect = font.getStringBounds(s, frc);
g.dispose();
img = new BufferedImage((int) Math.ceil(rect.getWidth()), (int) Math.ceil(rect.getHeight()), BufferedImage.TYPE_4BYTE_ABGR);
g = img.getGraphics();
g.setColor(Color.black);
g.setFont(font);
FontMetrics fm = g.getFontMetrics();
int x = 0;
int y = fm.getAscent();
g.drawString(s, x, y);
g.dispose();
return img;
}
}

View File

@ -44,6 +44,13 @@ public enum Achievement
new int[]{10},
AchievementCategory.HOLIDAY),
GLOBAL_CHICKEN_CHASER_2016("2016 Chicken Chaser", 4000,
new String[]{"Global.Thanksgiving Chickens 2016"},
new String[]{"Catch 200 Thanksgiving Chickens,",
"during Thanksgiving 2016!"},
new int[]{200},
AchievementCategory.HOLIDAY),
//Bridges
BRIDGES_WINS("Bridge Champion", 600,
new String[]{"The Bridges.Wins"},

View File

@ -11,6 +11,12 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -22,11 +28,6 @@ import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.powerplayclub.PowerPlayClubRewards;
import mineplex.core.powerplayclub.PowerPlayData;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
public class PowerPlayClubButton implements GuiItem
{
@ -77,7 +78,7 @@ public class PowerPlayClubButton implements GuiItem
}
else
{
UtilPlayer.message(_player, F.main("Power Play Club", "You have no months left! Buy more months at " + C.cAqua + "www.mineplex.com/shop" + C.Reset + "!"));
UtilPlayer.message(_player, F.main("Power Play Club", "You have no months left! Buy more months at " + F.greenElem("www.mineplex.com/shop") + "!"));
}
}
}

View File

@ -1,16 +0,0 @@
package mineplex.core.cosmetic.ui;
import java.util.Comparator;
import mineplex.core.pet.Pet;
public class PetSorter implements Comparator<Pet>
{
public int compare(Pet a, Pet b)
{
if (a.getPetType().getTypeId() < b.getPetType().getTypeId())
return -1;
return 1;
}
}

View File

@ -3,23 +3,23 @@ package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.pet.Pet;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.pet.PetType;
import mineplex.core.shop.item.IButton;
public class PetButton implements IButton
{
private Pet _pet;
private PetType _petType;
private PetPage _page;
public PetButton(Pet pet, PetPage page)
public PetButton(PetType pet, PetPage page)
{
_pet = pet;
_petType = pet;
_page = page;
}
public void onClick(Player player, ClickType clickType)
{
_page.purchasePet(player, _pet);
_page.purchasePet(player, _petType);
}
}

View File

@ -1,11 +1,10 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetType;
import mineplex.core.shop.item.IButton;
public class RenamePetButton implements IButton
@ -21,7 +20,7 @@ public class RenamePetButton implements IButton
public void onClick(Player player, ClickType clickType)
{
_page.playAcceptSound(player);
Creature currentPet = _page.getPlugin().getPetManager().getActivePet(player.getName());
_page.renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false);
PetType currentType = _page.getPlugin().getPetManager().getActivePetType(player.getName());
_page.renamePet(player, currentType, false);
}
}

View File

@ -5,15 +5,15 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.PetPage;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetType;
import mineplex.core.shop.item.IButton;
public class ActivatePetButton implements IButton
{
private Pet _pet;
private PetType _pet;
private PetPage _page;
public ActivatePetButton(Pet pet, PetPage page)
public ActivatePetButton(PetType pet, PetPage page)
{
_pet = pet;
_page = page;
@ -23,7 +23,7 @@ public class ActivatePetButton implements IButton
public void onClick(Player player, ClickType clickType)
{
_page.playAcceptSound(player);
_page.getPlugin().getPetManager().addPetOwner(player, _pet.getPetType(), player.getLocation());
_page.getPlugin().getPetManager().addPetOwner(player, _pet, player.getLocation());
_page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));
}
}

View File

@ -26,7 +26,7 @@ public class ArrowTrailPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ARROW_TRAIL))
{
@ -37,8 +37,8 @@ public class ArrowTrailPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if (slot == 17)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -1,5 +1,9 @@
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
@ -9,9 +13,6 @@ import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class BalloonsPage extends GadgetPage
{
@ -24,7 +25,7 @@ public class BalloonsPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.BALLOON))
{
@ -35,10 +36,8 @@ public class BalloonsPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if(slot == 35)
slot = 37;
if (slot == 17 || slot == 26)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -26,7 +26,7 @@ public class DeathEffectPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.DEATH))
{
@ -37,8 +37,8 @@ public class DeathEffectPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if (slot == 17)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -26,7 +26,7 @@ public class DoubleJumpPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.DOUBLE_JUMP))
{
@ -37,8 +37,8 @@ public class DoubleJumpPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if (slot == 17)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -53,7 +53,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.ITEM))
{
@ -67,7 +67,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
slot++;
if (slot == 26 || slot == 35)
if (slot == 17 || slot == 26)
slot += 2;
}
@ -165,7 +165,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
}
else
{
itemLore.add(C.cBlue + "Found in Power Play Club");
itemLore.add(C.cBlue + "Bonus Item Unlocked with Power Play Club");
}
}
@ -355,7 +355,25 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
}
}
addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), new ActivateGadgetButton(gadget, this));
/*if (gadget instanceof MorphStray)
{
gadgetItemStack = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, gadgetItemStack);
}*/
IButton iButton = new ActivateGadgetButton(gadget, this);
/*if (gadgetItemStack.getData().getItemType().equals(Material.BARRIER))
{
iButton = null;
}
else
{
// Does not set the item stack yet
//gadgetItemStack.setType(Material.getMaterial(440));
}*/
addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), iButton);
}
}
else

View File

@ -29,7 +29,7 @@ public class HatPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
List<Gadget> list = getPlugin().getGadgetManager().getGadgets(GadgetType.HAT);
if(list != null)
@ -42,8 +42,8 @@ public class HatPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if (slot == 17)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -25,13 +25,12 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetType;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.Material;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -122,10 +121,10 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
int petOwned = 0;
int petMax = 0;
for (Pet pet : getPlugin().getPetManager().getFactory().GetPets())
for (PetType type : PetType.values())
{
Map<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
if (pets != null && pets.containsKey(pet.getPetType()))
Map<PetType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
if (pets != null && pets.containsKey(type))
{
petOwned++;
}

View File

@ -1,5 +1,9 @@
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
@ -10,9 +14,6 @@ import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class MorphPage extends GadgetPage
{
@ -24,7 +25,7 @@ public class MorphPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.MORPH))
{
@ -36,10 +37,8 @@ public class MorphPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if (slot == 35)
slot = 37;
if (slot == 17 || slot == 26 || slot == 35)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -39,15 +39,15 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Mount<?> mount : getPlugin().getMountManager().getMounts())
{
addMount(mount, slot);
slot++;
if (slot == 26)
slot = 28;
if (slot == 17)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -26,7 +26,7 @@ public class MusicPage extends GadgetPage
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.MUSIC_DISC))
{
@ -34,8 +34,8 @@ public class MusicPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if (slot == 17)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -24,7 +24,7 @@ public class ParticlePage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.PARTICLE))
{
@ -35,10 +35,8 @@ public class ParticlePage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if(slot == 35)
slot = 37;
if (slot == 17 || slot == 26)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -1,7 +1,9 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.minecraft.server.v1_8_R3.Blocks;
@ -25,14 +27,13 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.PetSorter;
import mineplex.core.cosmetic.ui.button.PetButton;
import mineplex.core.cosmetic.ui.button.RenamePetButton;
import mineplex.core.cosmetic.ui.button.activate.ActivatePetButton;
import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetExtra;
import mineplex.core.pet.PetType;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.AnvilContainer;
@ -49,87 +50,91 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
protected void buildPage()
{
int slot = 19;
int slot = 10;
List<Pet> pets = new ArrayList<Pet>(getPlugin().getPetManager().getFactory().GetPets());
PetType[] pets = PetType.values();
Arrays.sort(pets, Comparator.comparing(type -> type.getEntityType().getTypeId()));
Collections.sort(pets, new PetSorter());
for (Pet pet : pets)
for (PetType pet : pets)
{
List<String> itemLore = new ArrayList<String>();
itemLore.add(C.cBlack);
if (pet.getLore() != null)
if (pet.getLore().isPresent())
{
Collections.addAll(itemLore, UtilText.splitLineToArray(C.cGray + pet.getLore(), LineFormat.LORE));
Collections.addAll(itemLore, UtilText.splitLineToArray(C.cGray + pet.getLore().get(), LineFormat.LORE));
}
else
{
itemLore.add(C.cGray + "Your very own " + pet.getName() + "!");
}
//Chest Unlocks
if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
if (!getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet))
{
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -1)
if (pet.getPrice() == -1)
{
//Nothing
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -2 || pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
else if (pet.getPrice() == -2 || pet.getPrice() > 0)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Treasure Chests");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -3)
else if (pet.getPrice() == -3)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Winter Holiday Treasure");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -4)
else if (pet.getPrice() == -4)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Earned by defeating the Pumpkin King");
itemLore.add(C.cBlue + "in the 2014 Christmas Chaos Event.");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -5)
else if (pet.getPrice() == -5)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Easter Holiday Treasure");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -8)
else if (pet.getPrice() == -8)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Pumpkin's Revenge");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -9)
else if (pet.getPrice() == -9)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Haunted Chests");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -14)
else if (pet.getPrice() == -14)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Power Play Club");
}
else if (pet.getPrice() == -14)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Power Play Club");
}
//Rank Unlocks
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -10)
else if (pet.getPrice() == -10)
{
itemLore.add(C.cBlack);
itemLore.add(C.cAqua + "Unlocked with Ultra Rank");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -11)
else if (pet.getPrice() == -11)
{
itemLore.add(C.cBlack);
itemLore.add(C.cPurple + "Unlocked with Hero Rank");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -12)
else if (pet.getPrice() == -12)
{
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Unlocked with Legend Rank");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -13)
else if (pet.getPrice() == -13)
{
itemLore.add(C.cBlack);
itemLore.add(C.cRed + "Unlocked with Titan Rank");
@ -137,21 +142,21 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
}
//Owned
if (getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet.getPetType()))
if (getPlugin().getPetManager().Get(getPlayer()).getPets().containsKey(pet))
{
String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet.getPetType());
String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet);
if (petName == null)
{
petName = pet.getName();
}
if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() == pet.getPetType())
if (getPlugin().getPetManager().hasActivePet(getPlayer().getName()) && getPlugin().getPetManager().getActivePetType(getPlayer().getName()) == pet)
{
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Disable");
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(),
pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getEntityType().getTypeId(),
pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")",
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager()));
addGlow(slot);
@ -160,56 +165,76 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Enable");
/*
ItemStack petItem = ItemStackFactory.Instance.CreateStack(pet.getMaterial(), pet.getData(), 1,
pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore);
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(),
pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
IButton iButton = new ActivatePetButton(pet, this);
if (pet.equals(PetType.SHULKER))
{
petItem = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, petItem);
if (petItem.getType().equals(Material.BARRIER))
{
iButton = null;
}
else
{
// Does not set the item stack yet
//petItem.setType(Material.getMaterial(201));
}
}*/
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getEntityType().getTypeId(),
pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")",
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this));
//addButton(slot, new ShopItem(petItem, false, false), iButton);
}
}
//Not Owned
else
{
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
if (pet.getPrice() > 0)
{
itemLore.add(C.cBlack);
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getCost(GlobalCurrency.TREASURE_SHARD) + " Treasure Shards");
itemLore.add(C.cWhiteB + "Cost: " + C.cAqua + pet.getPrice() + " Treasure Shards");
}
if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getCost(GlobalCurrency.TREASURE_SHARD))
if (pet.getPrice() > 0 && getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD) >= pet.getPrice())
{
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Purchase");
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this));
addButton(slot, new ShopItem(Material.INK_SACK, (byte) 8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this));
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) > 0)
else if (pet.getPrice() > 0)
{
itemLore.add(C.cBlack);
itemLore.add(C.cRed + "Not enough Treasure Shards.");
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
else
{
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, pet.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
}
slot++;
if (slot == 26)
slot = 28;
if (slot == 17 || slot == 26)
slot += 2;
}
slot = 49;
for (PetExtra petExtra : getPlugin().getPetManager().getFactory().GetPetExtras())
for (PetExtra petExtra : PetExtra.values())
{
List<String> itemLore = new ArrayList<String>();
if (!getPlugin().getPetManager().hasActivePet(getPlayer().getName()))
{
itemLore.add(C.cWhite + "You must have an active pet to use this!");
getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle());
getInventory().setItem(slot, new ShopItem(petExtra.getMaterial(), (byte)0, C.cRed + petExtra.getName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle());
}
// Silverfish = Wither disguised
// Villager = Elf
@ -218,7 +243,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|| getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.VILLAGER
|| getPlugin().getPetManager().getActivePet(getPlayer().getName()).getType() != EntityType.ZOMBIE)
{
addButton(slot, new ShopItem(petExtra.GetMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getCost(GlobalCurrency.TREASURE_SHARD) + C.cGreen + " Shards", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this));
addButton(slot, new ShopItem(petExtra.getMaterial(), (byte) 0, "Rename " + getPlugin().getPetManager().getActivePet(getPlayer().getName()).getCustomName() + " for " + C.cYellow + petExtra.getPrice(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this));
}
slot++;
@ -233,12 +258,12 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
});
}
public void purchasePet(final Player player, final Pet pet)
public void purchasePet(final Player player, final PetType petType)
{
renamePet(player, pet, true);
renamePet(player, petType, true);
}
public void renamePet(Player player, Pet pet, boolean petPurchase)
public void renamePet(Player player, PetType pet, boolean petPurchase)
{
playAcceptSound(player);

View File

@ -1,9 +1,14 @@
package mineplex.core.cosmetic.ui.page;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.Items;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.cache.player.PlayerCache;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.cosmetic.CosmeticManager;
@ -11,31 +16,26 @@ import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.CloseButton;
import mineplex.core.cosmetic.ui.button.SelectTagButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetExtra;
import mineplex.core.pet.PetType;
import mineplex.core.pet.repository.token.PetChangeToken;
import mineplex.core.pet.repository.token.PetToken;
import mineplex.core.shop.confirmation.ConfirmationPage;
import mineplex.core.shop.item.SalesPackageBase;
import mineplex.core.shop.item.SalesPackageProcessor;
import mineplex.core.shop.page.ShopPageBase;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.Items;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
private String _tagName = "Pet Tag";
private Pet _pet;
private PetType _petType;
private boolean _petPurchase;
public PetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase)
public PetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, PetType petType, boolean petPurchase)
{
super(plugin, shop, clientManager, donationManager, name, player, 3);
_pet = pet;
_petType = petType;
_petPurchase = petPurchase;
buildPage();
@ -84,7 +84,7 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
return;
}
if (_tagName.equalsIgnoreCase("ULTRA"))
if (_tagName.toLowerCase().contains("ultra"))
{
UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + _tagName + " is a restricted name."));
playDenySound(getPlayer());
@ -93,10 +93,15 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
return;
}
PetExtra tag = new PetExtra("Rename " + _pet.getName() + " to " + _tagName, Material.NAME_TAG, 100);
final SalesPackageBase salesPackage = _petPurchase ? _pet : tag;
final SalesPackageBase salesPackage;
if (_petPurchase)
{
salesPackage = _petType.toSalesPackage(_tagName);
_pet.setDisplayName(C.cGreen + "Purchase " + _tagName);
} else
{
salesPackage = PetExtra.NAME_TAG.toSalesPackage("Rename " + _petType.getName() + " to " + _tagName);
}
getShop().openPageForPlayer(getPlayer(), new ConfirmationPage<>(_player, this, new SalesPackageProcessor(_player, GlobalCurrency.TREASURE_SHARD, salesPackage, _donationManager, () ->
{
@ -108,8 +113,7 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
token.AccountId = PlayerCache.getInstance().getPlayer(getPlayer().getUniqueId()).getAccountId();
token.Name = getPlayer().getName();
token.PetType = _pet.getPetType().toString();
token.PetId = _pet.getPetType().ordinal();
token.PetType = _petType.toString();
token.PetName = _tagName;
PetToken petToken = new PetToken();
@ -118,7 +122,7 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (_petPurchase)
{
getPlugin().getPetManager().getRepository().AddPet(token);
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType());
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _petType);
}
else
{
@ -126,7 +130,7 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName);
}
getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName);
getPlugin().getPetManager().Get(getPlayer()).getPets().put(_petType, token.PetName);
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer()));
}), salesPackage.buildIcon()));

View File

@ -29,7 +29,7 @@ public class TauntPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
List<Gadget> list = getPlugin().getGadgetManager().getGadgets(GadgetType.TAUNT);
if(list != null)
@ -43,7 +43,7 @@ public class TauntPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -26,7 +26,7 @@ public class WinEffectPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT))
{
@ -37,8 +37,8 @@ public class WinEffectPage extends GadgetPage
slot++;
if (slot == 26)
slot = 28;
if (slot == 17)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()

View File

@ -2,8 +2,6 @@ package mineplex.core.cosmetic.ui.page.gamemodifiers;
import java.util.List;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.cosmetic.ui.page.Menu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -14,6 +12,8 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.types.GameModifierGadget;
@ -32,7 +32,7 @@ public class GameModifierPage extends GadgetPage
@Override
protected void buildPage()
{
int slot = 19;
int slot = 10;
for (GameModifierType type : GameModifierType.values())
{

View File

@ -1,24 +1,24 @@
package mineplex.core.cosmetic.ui.page.gamemodifiers;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import java.util.List;
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.ItemMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
import mineplex.core.gadget.types.GameModifierGadget;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class GameModifierSubPage extends GadgetPage
{
@ -38,7 +38,7 @@ public class GameModifierSubPage extends GadgetPage
{
if(_type == null) return;
int slot = 19;
int slot = 10;
if (_type.hasKits())
{
@ -78,7 +78,7 @@ public class GameModifierSubPage extends GadgetPage
slot++;
if(slot%9 == 8) slot += 2;
if(slot % 9 == 8) slot += 2;
}
}
}

View File

@ -1,5 +1,9 @@
package mineplex.core.cosmetic.ui.page.gamemodifiers;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
@ -12,9 +16,6 @@ import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
import mineplex.core.gadget.types.GameModifierGadget;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class KitGameModifierPage extends GadgetPage
{
@ -36,7 +37,7 @@ public class KitGameModifierPage extends GadgetPage
{
if(_type == null) return;
int slot = 19;
int slot = 10;
for (GameModifierGadget gadget : getPlugin().getGadgetManager().getGameModifiers(_kitType))
{
@ -52,7 +53,7 @@ public class KitGameModifierPage extends GadgetPage
slot++;
if(slot%9 == 8) slot += 2;
if(slot % 9 == 8) slot += 2;
}
}
}

View File

@ -114,6 +114,7 @@ import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
import mineplex.core.gadget.gadgets.morph.MorphMetalMan;
import mineplex.core.gadget.gadgets.morph.MorphPig;
import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
@ -366,10 +367,11 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphSquid(this));
addGadget(new MorphWitch(this));
addGadget(new MorphGrimReaper(this));
addGadget(new MorphMetalMan(this));
addGadget(new MorphTurkey(this));
// Hidden in this update
//addGadget(new MorphSleigh(this));
//addGadget(new MorphMetalMan(this));
// Not in this update
//addGadget(new MorphStray(this));
//addGadget(new MorphSanta(this));
// Particles
addGadget(new ParticleFoot(this));

View File

@ -1,6 +1,7 @@
package mineplex.core.gadget.commands;
import mineplex.core.account.CoreClient;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
@ -8,7 +9,6 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import org.bukkit.entity.Player;
public class AmmoCommand extends CommandBase<GadgetManager>
{

View File

@ -1,5 +1,8 @@
package mineplex.core.gadget.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
@ -10,10 +13,7 @@ import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.pet.PetType;
public class LockCosmeticsCommand extends CommandBase<GadgetManager>
{
@ -106,11 +106,10 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
private void removePets(Player caller)
{
int removed = 0;
for (Pet pet : _plugin.getPetManager().getFactory().GetPets())
for (PetType pet : PetType.values())
{
if (_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType()))
if (_plugin.getPetManager().Get(caller).getPets().remove(pet) != null)
{
_plugin.getPetManager().Get(caller).getPets().remove(pet.getPetType());
removed++;
}
}

View File

@ -1,85 +0,0 @@
package mineplex.core.gadget.commands;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.GadgetManager;
public class ReindeerTestCommand extends CommandBase<GadgetManager>
{
private GadgetManager _plugin;
private Horse _horse;
private ArmorStand _armorStand;
public ReindeerTestCommand(GadgetManager plugin)
{
super(plugin, Rank.JNR_DEV, "reindeer");
_plugin = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
if (_horse == null)
{
Location testHorse = new Location(caller.getWorld(), 8.5, 71, 0.5, 0, 0);
testHorse.setYaw(180);
Horse horse = testHorse.getWorld().spawn(testHorse, Horse.class);
horse.setVariant(Horse.Variant.HORSE);
horse.setColor(Horse.Color.BROWN);
horse.setStyle(Horse.Style.NONE);
UtilEnt.Vegetate(horse, true);
UtilEnt.ghost(horse, true, false);
/**
* South
* .4 1 .6
* .2 1 .7
* 0 4 0
* 0 2 0
*
* North
*/
Location hornALoc = horse.getLocation().clone().add(-.3, 1, -.5);
Location hornBLoc = horse.getLocation().clone().add(-.25, 1, -.6);
ArmorStand hornA = hornALoc.getWorld().spawn(hornALoc, ArmorStand.class);
hornA.setVisible(false);
hornA.setGravity(false);
hornA.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornA.setRightArmPose(new EulerAngle(0, 4, 0));
ArmorStand hornB = hornBLoc.getWorld().spawn(hornBLoc, ArmorStand.class);
hornB.setVisible(false);
hornB.setGravity(false);
hornB.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornB.setRightArmPose(new EulerAngle(0, 2, 0));
_horse = horse;
Bukkit.getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), new Runnable()
{
@Override
public void run()
{
Location location = _horse.getLocation();
location.setYaw(180);
_horse.teleport(location);
}
}, 1l, 1l);
}
}
}

View File

@ -1,5 +1,8 @@
package mineplex.core.gadget.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
@ -10,10 +13,7 @@ import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.pet.PetType;
public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
{
@ -111,11 +111,11 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
private void addPets(Player caller)
{
int added = 0;
for (Pet pet : _plugin.getPetManager().getFactory().GetPets())
for (PetType pet : PetType.values())
{
if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType()))
if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet))
{
_plugin.getPetManager().Get(caller).getPets().put(pet.getPetType(), pet.getName());
_plugin.getPetManager().Get(caller).getPets().put(pet, pet.getName());
added++;
}
}

View File

@ -6,7 +6,7 @@ import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect;
import mineplex.core.particleeffects.BabyFireworkEffect;
import mineplex.core.gadget.types.ArrowEffectGadget;
import org.bukkit.ChatColor;
import org.bukkit.Color;

View File

@ -1,6 +1,5 @@
package mineplex.core.gadget.gadgets.item;
import mineplex.core.gadget.gadgets.hat.HatType;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -19,16 +18,18 @@ import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
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.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.gadgets.hat.HatType;
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.pet.PetType;
import mineplex.core.recharge.Recharge;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
@ -130,7 +131,7 @@ public class ItemCoal extends ItemGadget
Manager.getPetManager(),
Manager.getInventoryManager(),
Manager.getDonationManager(),
"Coal Apparition", "Coal Apparition", EntityType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0);
"Coal Apparition", "Coal Apparition", PetType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0);
if (reward.canGiveReward(player))
reward.giveReward(null, player, new Callback<RewardData>()

View File

@ -105,6 +105,8 @@ public class MorphGrimReaper extends MorphGadget
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
player.setFlying(false);
player.setAllowFlight(false);
_flying.remove(player);
_flyReady.remove(player);
_soulManager.resetSouls(player);
@ -189,7 +191,7 @@ public class MorphGrimReaper extends MorphGadget
private void setFlying(Player player, boolean flying, boolean isFast)
{
if (flying)
if (flying && isActive(player))
{
if (UtilPlayer.isSpectator(player))
return;

View File

@ -2,15 +2,21 @@ package mineplex.core.gadget.gadgets.morph;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
@ -18,29 +24,39 @@ 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.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.gadgets.particle.unrelated.MetalManEffect;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.particleeffects.MetalManEffect;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilGameProfile;
public class MorphMetalMan extends MorphGadget
{
private Map<UUID, Integer> _playerColors = new HashMap<>();
private Map<Player, Long> _flying = new HashMap<>();
private static final int FLY_TIME = 15;
public MorphMetalMan(GadgetManager manager)
{
super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods",
"",
C.cWhite + "Left-click to shoot laser beam"
C.cWhite + "Left-click to shoot laser beam",
C.cWhite + "Sneak to hover"
}, LineFormat.LORE),
-14, Material.IRON_INGOT, (byte) 0);
}
@ -57,6 +73,8 @@ public class MorphMetalMan extends MorphGadget
DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile);
disguisePlayer.showInTabList(true, 0);
UtilMorph.disguise(player, disguisePlayer, Manager);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 1, true, false));
}
@Override
@ -65,6 +83,21 @@ public class MorphMetalMan extends MorphGadget
removeArmor(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
if (_playerColors.containsKey(player.getUniqueId()))
{
_playerColors.remove(player.getUniqueId());
}
if (_flying.containsKey(player))
{
_flying.remove(player);
}
player.setFlying(false);
player.setAllowFlight(false);
player.removePotionEffect(PotionEffectType.SLOW);
}
@EventHandler
@ -81,7 +114,7 @@ public class MorphMetalMan extends MorphGadget
if (player.getItemInHand().getType() != Material.AIR)
return;
if (!Recharge.Instance.use(player, getName(), 5000, true, false, "Cosmetics"))
if (!Recharge.Instance.use(player, "Metal Man Missile", 5000, true, false, "Cosmetics"))
return;
// Creates colored laser
@ -114,6 +147,61 @@ public class MorphMetalMan extends MorphGadget
metalManEffect.start();
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!event.isSneaking())
return;
if (_flying.containsKey(event.getPlayer()))
return;
Player player = event.getPlayer();
if (!Recharge.Instance.use(player, "Metal Man Fly", 45000, true, false, "Cosmetics"))
return;
UtilAction.velocity(player, new Vector(0, 1, 0));
player.teleport(player.getLocation().add(0, 1, 0));
player.playSound(player.getLocation(), Sound.WITHER_SHOOT, 1, 1);
_flying.put(player, System.currentTimeMillis());
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Map.Entry<Player, Long>> iterator = _flying.entrySet().iterator();
while (iterator.hasNext())
{
Map.Entry<Player, Long> entry = iterator.next();
Player player = entry.getKey();
if (!isActive(player))
{
iterator.remove();
continue;
}
long started = entry.getValue();
if (UtilTime.elapsed(started, 15000))
{
player.setFlying(false);
player.setAllowFlight(false);
iterator.remove();
continue;
}
player.setAllowFlight(true);
player.setFlying(true);
int filledBars = (int) ((started + 15000 - System.currentTimeMillis()) / 1000);
UtilTextBottom.displayProgress("Flying", "", 15, filledBars, player);
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, player.getLocation(), 0, 0, 0, 0, 5, UtilParticle.ViewDist.NORMAL);
}
}
public void increaseColor(UUID uuid)
{
if (_playerColors.containsKey(uuid))

View File

@ -0,0 +1,281 @@
package mineplex.core.gadget.gadgets.morph;
import java.time.Month;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
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;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilGameProfile;
public class MorphSanta extends MorphGadget
{
private HashMap<Item, SantaPresent> _items = 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));
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
GameProfile profile = UtilGameProfile.getGameProfile(player);
profile.getProperties().clear();
profile.getProperties().put("textures", SkinData.SANTA.getProperty());
DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile);
disguisePlayer.showInTabList(true, 0);
UtilMorph.disguise(player, disguisePlayer, Manager);
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
}
// PRESENT
@EventHandler
public void throwPresent(PlayerInteractEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!UtilEvent.isAction(event, UtilEvent.ActionType.L))
return;
Player player = event.getPlayer();
int type = 0;
if (UtilMath.random(0.1, 1.1) > 0.76)
{
type = 1;
}
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);
if (Manager.getDonationManager().Get(player).getBalance(GlobalCurrency.TREASURE_SHARD) < shards + SHARD_CHARGE)
{
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Shards."));
return;
}
Item present = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()),
SkinData.PRESENT.getSkull("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));
present.setPickupDelay(40);
_items.put(present, new SantaPresent(player.getName(), SantaPresent.PresentType.PRESENT, shards));
//Announce
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
ChatColor.RESET + C.Bold + " hid a " +
C.cRed + C.Bold + "Christmas Present" +
ChatColor.RESET + C.Bold + " worth " +
C.cRed + C.Bold + shards + " Shards");
for (Player other : UtilServer.getPlayers())
other.playSound(other.getLocation(), Sound.BLAZE_HIT, 1.5f, 1.5f);
}
else
{
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);
int coals = UtilMath.rRange(1, 3);
coal.setPickupDelay(40);
_items.put(coal, new SantaPresent(player.getName(), SantaPresent.PresentType.COAL, coals));
//Announce
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
ChatColor.RESET + C.Bold + " hid a " +
C.cRed + C.Bold + "Christmas Coal" +
ChatColor.RESET + C.Bold + " worth " +
C.cRed + C.Bold + coals + " Coal Ammo");
for (Player other : UtilServer.getPlayers())
other.playSound(other.getLocation(), Sound.DIG_SNOW, 1.5f, 1.5f);
}
}
@EventHandler
public void presentPickup(PlayerPickupItemEvent event)
{
if (_items.containsKey(event.getItem()) && !_items.get(event.getItem()).getThrower().equals(event.getPlayer().getName()))
{
SantaPresent santaPresent = _items.get(event.getItem());
_items.remove(event.getItem());
event.setCancelled(true);
event.getItem().remove();
int presentsLeft = 0, coalsLeft = 0;
for (SantaPresent present : _items.values())
{
if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT))
{
presentsLeft++;
}
else if (present.getPresentType().equals(SantaPresent.PresentType.COAL))
{
coalsLeft++;
}
}
if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT))
{
Manager.getDonationManager().RewardCoinsLater(getName() + " Present Pickup", event.getPlayer(), santaPresent.getAmmo());
//Announce
Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() +
ChatColor.RESET + C.Bold + " found a " +
C.cGold + C.Bold + "Christmas Present" +
ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!");
}
else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL))
{
// Gives coals
Manager.getInventoryManager().addItemToInventory(event.getPlayer(), "Coal", santaPresent.getAmmo());
//Announce
Bukkit.broadcastMessage(C.cGold + C.Bold + event.getPlayer().getName() +
ChatColor.RESET + C.Bold + " found a " +
C.cGold + C.Bold + "Christmas Coal" +
ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!");
}
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 0.75f);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 1.25f);
UtilFirework.playFirework(event.getItem().getLocation(), FireworkEffect.Type.BURST, Color.RED, true, true);
}
}
@EventHandler
public void presentClean(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Iterator<Item> presentIter = _items.keySet().iterator();
while (presentIter.hasNext())
{
Item presentItem = presentIter.next();
if (!presentItem.isValid() || presentItem.getTicksLived() > 24000)
{
SantaPresent santaPresent = _items.get(presentItem);
presentItem.remove();
presentIter.remove();
//Announce
if (santaPresent.getPresentType().equals(SantaPresent.PresentType.PRESENT))
{
int presentsLeft = 0;
for (SantaPresent present : _items.values())
{
if (present.getPresentType().equals(SantaPresent.PresentType.PRESENT))
{
presentsLeft++;
}
}
Bukkit.broadcastMessage(
ChatColor.RESET + C.Bold + "No one found a " +
C.cGold + C.Bold + "Christmas Present" +
ChatColor.RESET + C.Bold + "! " + presentsLeft + " Presents left!");
}
else if (santaPresent.getPresentType().equals(SantaPresent.PresentType.COAL))
{
int coalsLeft = 0;
for (SantaPresent present : _items.values())
{
if (present.getPresentType().equals(SantaPresent.PresentType.COAL))
{
coalsLeft++;
}
}
Bukkit.broadcastMessage(
ChatColor.RESET + C.Bold + "No one found a " +
C.cGold + C.Bold + "Christmas Coal" +
ChatColor.RESET + C.Bold + "! " + coalsLeft + " Coals left!");
}
}
else
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, presentItem.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1,
UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
@EventHandler
public void presentDespawnCancel(ItemDespawnEvent event)
{
if (_items.containsKey(event.getEntity()))
event.setCancelled(true);
}
}

View File

@ -1,238 +0,0 @@
package mineplex.core.gadget.gadgets.morph;
import java.io.File;
import java.io.IOException;
import java.time.Month;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.sleigh.Sleigh;
import mineplex.core.gadget.gadgets.morph.managers.sleigh.SleighPosition;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MorphSleigh extends MorphGadget
{
/**
* Directions of the Sleigh, with the correct coord for the player to be teleported and the schematic name
*/
public enum SleighDirection
{
NORTH("SleighMorphNorth.schematic", 0.5, 4.5),
SOUTH("SleighMorphSouth.schematic", 0.5, 1.5),
EAST("SleighMorphEast.schematic", 1.5, 1.5),
WEST("SleighMorphWest.schematic", 4.5, 1.5);
private String _schematic;
private double _fixedX;
private double _fixedZ;
SleighDirection(String schematic, double fixedX, double fixedZ)
{
_schematic = schematic;
_fixedX = fixedX;
_fixedZ = fixedZ;
}
public String getSchematic()
{
return _schematic;
}
public double getFixedX()
{
return _fixedX;
}
public double getFixedZ()
{
return _fixedZ;
}
}
private Map<Player, Sleigh> _sleighs = new HashMap<>();
private Map<SleighDirection, Schematic> _schematics = new HashMap<>();
private List<SleighPosition> _positions = new ArrayList<>();
private Long _rightClickStart = null;
public MorphSleigh(GadgetManager manager)
{
super(manager, "Sleigh Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14, YearMonth.of(2016, Month.DECEMBER));
// Loads sleigh schematics
for (SleighDirection sleighDirection : SleighDirection.values())
{
try
{
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + sleighDirection.getSchematic()));
_schematics.put(sleighDirection, schematic);
} catch (IOException e)
{
e.printStackTrace();
}
}
buildPositions();
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
// TODO DISGUISE
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
// TODO UNDISGUISE
if (_sleighs.containsKey(player))
{
_sleighs.get(player).stopEffect();
_sleighs.remove(player);
}
}
/**
* Activates the sleigh effect when left-clicking
* This will be changed in the next releases
* @param event
*/
@EventHandler
public void activateSleigh(PlayerInteractEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!UtilEvent.isAction(event, UtilEvent.ActionType.L))
return;
Player player = event.getPlayer();
if (player.getItemInHand().getType() != Material.AIR)
return;
//if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics"))
//return;
List<SleighPosition> freePositions = _positions.stream().filter(position -> !position.isUsed()).collect(Collectors.toList());
if (freePositions.size() == 0)
{
UtilPlayer.message(player, F.main("Sleigh Ride", "There are too many sleighs in the sky right now! Please wait a minute and try again!"));
return;
}
int randomPosition = UtilMath.random.nextInt(freePositions.size());
SleighPosition position = freePositions.get(randomPosition);
position.setUsed(true);
SleighDirection direction = position.getDirection();
Schematic schematic = _schematics.get(direction);
if (schematic == null)
{
try
{
schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/SleighMorph.schematic"));
Location fixYaw = player.getLocation().clone();
fixYaw.setYaw(90);
player.teleport(fixYaw);
}
catch (IOException e)
{
e.printStackTrace();
}
}
Sleigh sleigh = new Sleigh(player, schematic, position);
sleigh.startEffect();
_sleighs.put(player, sleigh);
}
/**
* Stops player from leaving the sleigh if it's activte
* @param event
*/
@EventHandler
public void onLeaveVehicle(VehicleExitEvent event)
{
if (event.getExited() instanceof Player)
{
Player player = (Player) event.getExited();
if (isActive(player))
{
event.setCancelled(true);
}
}
}
/**
* Creates positions in the hub map
* TODO add arcade positions
*/
private void buildPositions()
{
_positions.add(new SleighPosition(-11, 143, -30, SleighDirection.SOUTH, -9.5, 145.5, -28.5));
_positions.add(new SleighPosition(57, 109, -150, SleighDirection.SOUTH, 58.5, 111.5, -148.5));
_positions.add(new SleighPosition(141, 101, 80, SleighDirection.NORTH, 142.5, 103.5, 84.5));
_positions.add(new SleighPosition(-12, 88, 85, SleighDirection.NORTH, -10.5, 90.5, 89.5));
_positions.add(new SleighPosition(-95, 90, 70, SleighDirection.NORTH, -93.5, 92.5, 74.5));
_positions.add(new SleighPosition(-105, 115, -80, SleighDirection.EAST, -103.5, 117.5, -78.5));
_positions.add(new SleighPosition(-135, 97, -8, SleighDirection.EAST, -133.5, 99.5, -6.5));
_positions.add(new SleighPosition(-45, 97, 15, SleighDirection.EAST, -43.5, 99.5, 16.5));
_positions.add(new SleighPosition(136, 116, 85, SleighDirection.WEST, 140.5, 118.5, 86.5));
}
/**
* Removes sleighs if they run out of time, or moves them if they still have time
* @param event
*/
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.FASTER)
{
_sleighs.values().forEach(Sleigh::playSound);
}
if (event.getType() != UpdateType.TICK)
return;
Iterator<Map.Entry<Player, Sleigh>> iterator = _sleighs.entrySet().iterator();
while (iterator.hasNext())
{
Map.Entry<Player, Sleigh> entry = iterator.next();
Sleigh sleigh = entry.getValue();
if (!sleigh.update())
{
iterator.remove();
}
}
}
}

View File

@ -0,0 +1,128 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.itemstack.ItemStackFactory;
/**
* THIS MORPH IS 1.9+ ONLY
*/
public class MorphStray extends MorphGadget
{
private List<Arrow> _strayArrows = new ArrayList<>();
private ItemStack _arrow;
public MorphStray(GadgetManager manager)
{
super(manager, "Stray Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "Even though it's a stray your mom probably won't let you keep this puppy.",
"",
C.cWhite + "Gains an arrow every 5 seconds with EXTREME knockback."
}, LineFormat.LORE),
0, Material.BARRIER, (byte) 0);
_arrow = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Stray Arrow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE));
}
@Override
public void enableCustom(Player player, boolean message)
{
// TODO CHECK IF LOBBY IS 1.9+
applyArmor(player, message);
DisguiseSquid disguiseSquid = new DisguiseSquid(player);
UtilMorph.disguise(player, disguiseSquid, Manager);
// Gives bow and arrow
ItemStack bow = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte) 0, 1, C.cGreen + "Stray Bow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE));
player.getInventory().setItem(2, bow);
player.getInventory().setItem(17, _arrow);
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
UtilMorph.undisguise(player, Manager.getDisguiseManager());
// Removes bow and arrow
player.getInventory().setItem(2, new ItemStack(Material.AIR));
player.getInventory().setItem(17, new ItemStack(Material.AIR));
}
@EventHandler
public void onShoot(EntityShootBowEvent event)
{
if (!(event.getEntity() instanceof Player))
return;
if (!(event.getProjectile() instanceof Arrow))
return;
Player player = (Player) event.getEntity();
if (!isActive(player))
return;
_strayArrows.add((Arrow) event.getProjectile());
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
player.getInventory().setItem(17, _arrow);
}
}, 3 * 20L);
}
@EventHandler
public void onArrowHitPlayer(EntityDamageByEntityEvent event)
{
if (!(event.getDamager() instanceof Arrow))
return;
if (!(event.getEntity() instanceof Player))
return;
if (!(((Arrow) event.getDamager()).getShooter() instanceof Player))
return;
Arrow arrow = (Arrow) event.getDamager();
Player player = (Player) event.getEntity();
if (!_strayArrows.contains(arrow))
return;
_strayArrows.remove(arrow);
Player shooter = (Player) arrow.getShooter();
arrow.remove();
if (shooter.getUniqueId().equals(player.getUniqueId()))
return;
player.setVelocity(player.getVelocity().multiply(-15).setY(15));
UtilPlayer.message(player, F.main("Stray Arrow", "You were hit with a " + F.greenElem("Stray Arrow") + " from " + F.name(shooter.getName()) + " and got knocked back!"));
UtilPlayer.message(shooter, F.main("Stray Arrow", "You hit " + F.name(player.getName()) + " with the " + F.greenElem("Stray Arrow") + " and they got knocked back!"));
}
}

View File

@ -5,7 +5,7 @@ import java.util.Map;
import java.util.Set;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.gadgets.particle.unrelated.WitchParticleEffect;
import mineplex.core.particleeffects.WitchParticleEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Bat;

View File

@ -0,0 +1,38 @@
package mineplex.core.gadget.gadgets.morph.managers;
public class SantaPresent
{
public enum PresentType
{
PRESENT,
COAL
}
private final String _thrower;
private final PresentType _presentType;
private final int _ammo;
public SantaPresent(String thrower, PresentType presentType, int ammo)
{
_thrower = thrower;
_presentType = presentType;
_ammo = ammo;
}
public String getThrower()
{
return _thrower;
}
public PresentType getPresentType()
{
return _presentType;
}
public int getAmmo()
{
return _ammo;
}
}

View File

@ -1,187 +0,0 @@
package mineplex.core.gadget.gadgets.morph.managers.sleigh;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.gadgets.morph.MorphSleigh;
/**
* Creates the sleigh effect for the Sleigh Morph
*/
public class Sleigh
{
private Map<Location, Material> _oldBlockMaterials = new HashMap<>();
private Map<Location, Byte> _oldBlockDatas = new HashMap<>();
private Player _player;
private Location _originalLocation;
private Schematic _schematic;
private SleighPosition _sleighPosition;
private Arrow _arrow;
private float _yaw;
private int _moves = 0;
public Sleigh(Player player, Schematic schematic, SleighPosition sleighPosition)
{
_player = player;
_schematic = schematic;
_sleighPosition = sleighPosition;
_yaw = (sleighPosition.getDirection() == MorphSleigh.SleighDirection.SOUTH) ? 0f :
(sleighPosition.getDirection() == MorphSleigh.SleighDirection.NORTH) ? 180f :
(sleighPosition.getDirection() == MorphSleigh.SleighDirection.WEST) ? 90f : -90f;
}
/**
* Starts the sleigh effect
*/
public void startEffect()
{
_originalLocation = _player.getLocation().clone();
Location origin = new Location(_originalLocation.getWorld(), _sleighPosition.getX(),
_sleighPosition.getY(), _sleighPosition.getZ());
try
{
pasteSchematic(origin, 0, 0);
} catch (IOException e)
{
e.printStackTrace();
}
}
/**
* Stops the sleigh effect
*/
public void stopEffect()
{
restoreBlocks();
_arrow.remove();
_player.teleport(_originalLocation.clone().add(0, 5, 0));
_sleighPosition.setUsed(false);
}
/**
* Pastes the schematic for the sleigh
* @param origin The location where the sleigh schematic will be placed
* @param playerX The X coord where player will be teleported
* @param playerZ The Z coord where player will be teleported
* @throws IOException
*/
private void pasteSchematic(Location origin, int playerX, int playerZ) throws IOException
{
restoreBlocks();
short width = _schematic.getWidth();
short height = _schematic.getHeight();
short length = _schematic.getLength();
for (short x = 0; x < width; x++)
{
for (short y = 0; y < height; y++)
{
for (short z = 0; z < length; z++)
{
Location location = origin.clone().add(x, y, z);
_oldBlockMaterials.put(location, location.getBlock().getType());
_oldBlockDatas.put(location, location.getBlock().getData());
}
}
}
_schematic.paste(origin);
Location playerLoc = new Location(_originalLocation.getWorld(), _sleighPosition.getPlayerX() + playerX,
_sleighPosition.getPlayerY(), _sleighPosition.getPlayerZ() + playerZ);
// Spawns arrow so it looks like player is sitting on the sleigh
if (_arrow != null)
{
_arrow.remove();
}
_arrow = playerLoc.getWorld().spawn(playerLoc, Arrow.class);
UtilEnt.ghost(_arrow, true, true);
playerLoc.setYaw(_yaw);
playerLoc.setPitch(0.0f);
_player.teleport(playerLoc);
_arrow.setPassenger(_player);
}
/**
* Updates sleigh to look like its moving
* @return true if the sleigh was moved, false if the time is over (3 seconds)
*/
public boolean update()
{
_moves++;
int x = 0, z = 0;
switch (_sleighPosition.getDirection())
{
case NORTH:
z = -1 * _moves;
break;
case SOUTH:
z = _moves;
break;
case WEST:
x = -1 * _moves;
break;
case EAST:
x = _moves;
}
Location newOrigin = new Location(_originalLocation.getWorld(), _sleighPosition.getX() + x,
_sleighPosition.getY(), _sleighPosition.getZ() + z);
restoreBlocks();
UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, _player.getLocation(), 0f, 0f, 0f, 0.6f, 100,
UtilParticle.ViewDist.LONGER, UtilServer.getPlayers());
try
{
pasteSchematic(newOrigin, x, z);
} catch (IOException e)
{
e.printStackTrace();
}
if (_moves >= 20 * 3)
{
stopEffect();
return false;
}
return true;
}
/**
* Plays sleigh sound to the player
*/
public void playSound()
{
_player.playSound(_player.getLocation(), Sound.ORB_PICKUP, 1f, 1f);
}
/**
* Restores the blocks that were changed from pasting the schematic
*/
private void restoreBlocks()
{
for (Map.Entry<Location, Material> entry : _oldBlockMaterials.entrySet())
{
Location location = entry.getKey();
Material material = entry.getValue();
byte data = 0;
if (_oldBlockDatas.containsKey(location))
{
data = _oldBlockDatas.get(location);
}
location.getBlock().setType(material);
location.getBlock().setData(data);
}
_oldBlockMaterials.clear();
_oldBlockDatas.clear();
}
}

View File

@ -1,76 +0,0 @@
package mineplex.core.gadget.gadgets.morph.managers.sleigh;
import mineplex.core.gadget.gadgets.morph.MorphSleigh;
/**
* Handles positions from Sleigh and player, and the direction of the sleigh and player
*/
public class SleighPosition
{
private int _x;
private int _y;
private int _z;
private MorphSleigh.SleighDirection _direction;
private double _playerX;
private double _playerY;
private double _playerZ;
private boolean _used;
public SleighPosition(int x, int y, int z, MorphSleigh.SleighDirection direction, double playerX, double playerY, double playerZ)
{
_x = x;
_y = y;
_z = z;
_direction = direction;
_playerX = playerX;
_playerY = playerY;
_playerZ = playerZ;
_used = false;
}
public int getX()
{
return _x;
}
public int getY()
{
return _y;
}
public int getZ()
{
return _z;
}
public MorphSleigh.SleighDirection getDirection()
{
return _direction;
}
public double getPlayerX()
{
return _playerX;
}
public double getPlayerY()
{
return _playerY;
}
public double getPlayerZ()
{
return _playerZ;
}
public void setUsed(boolean used)
{
_used = used;
}
public boolean isUsed()
{
return _used;
}
}

View File

@ -7,7 +7,7 @@ import java.util.UUID;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.particle.unrelated.FreedomFireworkEffect;
import mineplex.core.particleeffects.FreedomFireworkEffect;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;

View File

@ -26,7 +26,7 @@ import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect;
import mineplex.core.particleeffects.BabyFireworkEffect;
import mineplex.core.gadget.types.WinEffectGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;

View File

@ -5,15 +5,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -30,14 +23,20 @@ import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
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.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
public class ItemStackFactory extends MiniPlugin
{
public static ItemStackFactory Instance;

View File

@ -3,10 +3,9 @@ package mineplex.core.mount.types;
import java.util.*;
import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.gadgets.particle.unrelated.FreedomTrailEffect;
import mineplex.core.particleeffects.FreedomTrailEffect;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;

View File

@ -1,14 +1,15 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import java.util.Random;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.common.util.particles.NormalParticle;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
public class BabyFireworkEffect extends Effect
{

View File

@ -1,4 +1,4 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -11,6 +11,7 @@ public abstract class Effect
public EffectLocation _effectLocation;
public EffectLocation _targetLocation;
protected JavaPlugin _javaPlugin;
private boolean _running = false;
public Effect(int ticks, EffectLocation effectLocation, JavaPlugin javaPlugin)
{
@ -29,6 +30,8 @@ public abstract class Effect
public void start()
{
onStart();
_running = true;
_task = Bukkit.getScheduler().scheduleSyncRepeatingTask(_javaPlugin, new Runnable()
{
@Override
@ -42,9 +45,15 @@ public abstract class Effect
public void stop()
{
_running = false;
Bukkit.getScheduler().cancelTask(_task);
onStop();
}
public void onStart(){};
public void onStop(){};
private void update()
{
_ticks++;
@ -52,6 +61,11 @@ public abstract class Effect
Bukkit.getScheduler().cancelTask(_task);
}
public boolean isRunning()
{
return _running;
}
public abstract void runEffect();
public void setTargetLocation(EffectLocation effectLocation)
@ -64,4 +78,9 @@ public abstract class Effect
return _targetLocation;
}
public EffectLocation getEffectLocation()
{
return _effectLocation;
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import org.bukkit.Location;
import org.bukkit.entity.Entity;

View File

@ -1,4 +1,4 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import org.bukkit.Color;
import org.bukkit.Location;

View File

@ -1,13 +1,15 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class FreedomTrailEffect extends Effect
{

View File

@ -1,10 +1,11 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import mineplex.core.common.util.UtilFirework;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilFirework;
public class HalloweenSmashedEffect extends Effect
{

View File

@ -1,18 +1,24 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import java.awt.*;
import java.util.HashMap;
import java.util.HashSet;
import mineplex.core.common.util.*;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import org.bukkit.Color;
import mineplex.core.gadget.types.Gadget;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.types.Gadget;
public class MetalManEffect extends Effect
{
@ -23,20 +29,28 @@ public class MetalManEffect extends Effect
private Location _fixedLoc;
private Gadget _gadget;
private Player _player;
private int _totalCount = 0;
private boolean _forceStop = false;
public MetalManEffect(Location location, Location target, int color, Gadget gadget, Player player)
{
super(-1, new EffectLocation(location), gadget.Manager.getPlugin());
super(-1, new EffectLocation(player), gadget.Manager.getPlugin());
_color = color;
_gadget = gadget;
_player = player;
setTargetLocation(new EffectLocation(target));
}
@Override
public void onStart()
{
_player.getWorld().playSound(_player.getLocation(), Sound.PISTON_RETRACT, 1f, 1f);
}
@Override
public void runEffect()
{
Location location = _effectLocation.getFixedLocation().clone();
Location location = _effectLocation.getFixedLocation().clone().add(0, 1, 0);
if (_vector == null)
{
Location targetLoc = getTargetLocation().getFixedLocation().clone();
@ -54,21 +68,41 @@ public class MetalManEffect extends Effect
coloredParticle.setLocation(_fixedLoc);
coloredParticle.display(UtilParticle.ViewDist.LONG);
}
if (_fixedLoc.getBlock().getType() != Material.AIR || _count == 1000)
if (_fixedLoc.getBlock().getType() != Material.AIR )
{
explode();
stop();
}
else if (_count >= 1000)
{
_forceStop = true;
stop();
}
_count += 5;
}
private void explode()
@Override
public void onStop()
{
this.stop();
if (!_forceStop)
{
_count = 0;
_vector = null;
HashSet<Material> ignore = new HashSet<Material>();
ignore.add(Material.AIR);
Location loc = _player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
_effectLocation = new EffectLocation(_player);
setTargetLocation(new EffectLocation(loc));
_totalCount++;
if (_totalCount != 3)
{
start();
}
}
// Creates the explosion and knockback players
Location loc = _fixedLoc;
loc.getWorld().createExplosion(loc, 0f);
UtilParticle.PlayParticle(UtilParticle.ParticleType.EXPLODE, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers());
HashMap<Player, Double> players = UtilPlayer.getInRadius(loc, 5d);
HashMap<Player, Double> players = UtilPlayer.getInRadius(loc, 9d);
for (Player ent : players.keySet())
{
if (_gadget.Manager.collideEvent(_player, _gadget, ent))

View File

@ -0,0 +1,155 @@
package mineplex.core.particleeffects;
public class NewYearEffect //extends Effect
{
/*private static final int SECONDS_IN_A_MINUTE = 60;
private final Location _ballLocation, _clockLocation, _timerLocation, _timerLocationTen;
private int _seconds = 90;
private Collection<Block> _blocks = new ArrayList<>();
private List<Schematic> _schematics = new ArrayList<>();
private boolean _placed = false;
private int _currentRun = 0;
public NewYearEffect(JavaPlugin plugin, Location location)
{
super(-1, new EffectLocation(location), plugin, 10);
_ballLocation = new Location(location.clone().getWorld(), 0, 71, 38);
_clockLocation = _ballLocation.clone().add(-12, 0, -15);
_timerLocation = _clockLocation.clone().add(19, 7, 0);
_timerLocationTen = _timerLocation.clone().add(1, 0, 0);
try
{
for (int i = 0; i <= 10; i++)
{
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearBall" + i + ".schematic"));
_schematics.add(i, schematic);
}
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/NewYearClock.schematic"));
_schematics.add(11, schematic);
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void runEffect()
{
if (!_placed)
{
pasteSchematic(10, true);
_placed = true;
}
if (_seconds == -60)
{
stop();
return;
}
if (_seconds == 0)
{
List<int[]> fireworkLocations = new ArrayList<>();
List<int[]> fixedFireworkLocations = new ArrayList<>();
int[][] fireworkCoords = new int[][]
{
{0, 77, -37},
{-6, 71, 17},
{6, 71, 17},
{12, 71, 7},
{-12, 71, 7},
{5, 71, 92},
{-7, 71, 92},
{-9, 103, 37},
{13, 107, 40}
};
fireworkLocations.addAll(Arrays.asList(fireworkCoords));
int[][] fixedFireworkCoords = new int[][]
{
{0, 80, 0},
{0, 80, -32},
{6, 80, -26},
{-6, 80, -26}
};
fixedFireworkLocations.addAll(Arrays.asList(fixedFireworkCoords));
NewYearFireworkEffect newYearFireworkEffect = new NewYearFireworkEffect(_javaPlugin, fireworkLocations, fixedFireworkLocations, getEffectLocation().getFixedLocation().getWorld());
newYearFireworkEffect.start();
}
if (_currentRun % 2 != 0 && _seconds >= 0)
{
//Format seconds
int totalMinutes = 0, totalSeconds = 0, placeholder;
placeholder = _seconds;
if (_seconds > SECONDS_IN_A_MINUTE)
{
while (placeholder > SECONDS_IN_A_MINUTE)
{
totalMinutes++;
placeholder -= SECONDS_IN_A_MINUTE;
}
}
totalSeconds = placeholder;
String formatted = String.format("%02d:%02d", totalMinutes, totalSeconds);
if (_seconds <= 10)
{
formatted = "| " + _seconds + " |";
pasteSchematic(_seconds, false);
}
updateTimer(formatted, (byte) 0);
_seconds--;
}
else if (_seconds >= 0 && _seconds <= 10)
{
updateTimer("| " + _seconds + " |", (byte) 14);
}
else if (_currentRun % 2 != 0 && _seconds < 0)
{
updateTimer("2017!", (byte) 0);
_seconds--;
}
else if (_seconds < 0)
{
updateTimer("2017!", (byte) 14);
}
_currentRun++;
}
@Override
public void onStop()
{
_blocks.forEach(b -> b.setType(Material.AIR));
_blocks.clear();
updateTimer("2017!", (byte) 14);
}
private void pasteSchematic(int second, boolean pasteClock)
{
Schematic schematic = _schematics.get(second);
if (schematic != null)
{
schematic.paste(_ballLocation, false, true);
if (pasteClock)
{
Schematic clockSchematic = _schematics.get(11);
clockSchematic.paste(_clockLocation);
}
}
}
private void updateTimer(String time, byte color)
{
// Clears previous blocks
_blocks.forEach(b -> b.setType(Material.AIR));
Collection<Block> blocks = UtilBlockText.MakeText(time, (_seconds <= 10 && _seconds >= 0) ? _timerLocationTen : _timerLocation, BlockFace.WEST, Material.STAINED_CLAY.getId(), color, UtilBlockText.TextAlign.LEFT, false);
_blocks = blocks;
}*/
}

View File

@ -0,0 +1,46 @@
package mineplex.core.particleeffects;
public class NewYearFireworkEffect //extends Effect
{
/*private static final int MAX_TICKS = 1200;
private List<Location> _locations = new ArrayList<>();
private List<Location> _fixedLocations = new ArrayList<>();
private int _ticks = 0;
public NewYearFireworkEffect(JavaPlugin plugin, List<int[]> locations, List<int[]> fixedLocations, World world)
{
super(-1, null, plugin, 5);
for (int[] locCoords : locations)
{
_locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2]));
}
for (int[] locCoords : fixedLocations)
{
_locations.add(new Location(world, locCoords[0], locCoords[1], locCoords[2]));
}
}
@Override
public void runEffect()
{
for (int i = 0; i < 5; i++)
{
int r = UtilMath.random.nextInt(_locations.size() - 1);
Location location = _locations.get(r);
UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2),
new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1);
}
for (Location location : _fixedLocations)
{
UtilFirework.launchFirework(location, UtilFirework.getRandomFireworkEffect(true, 2, 2),
new Vector((Math.random() - 0.5) * 0.05, 0.1, (Math.random() - 0.5) * 0.05), 1);
}
_ticks += 5;
if (_ticks >= MAX_TICKS)
{
stop();
}
}*/
}

View File

@ -0,0 +1,87 @@
package mineplex.core.particleeffects;
import java.awt.*;
import java.awt.image.BufferedImage;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
public class TextEffect extends Effect
{
private static final double IMAGE_SIZE = 0.2;
private String _text;
private Font _font;
private boolean _realtime;
private boolean _invert;
private BufferedImage _bufferedImage;
private ColoredParticle _coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.GREEN), null);
public TextEffect(JavaPlugin plugin, int ticks, String text, Location location, boolean realtime, boolean invert) throws Exception
{
super(ticks, new EffectLocation(location), plugin);
_text = text;
_font = new Font("Tahoma", Font.PLAIN, 16);
_realtime = realtime;
_invert = invert;
}
public void setText(String text)
{
if (!_realtime)
return;
_text = text;
}
@Override
public void runEffect()
{
if (_text == null || _font == null)
{
stop();
return;
}
if (_bufferedImage == null || _realtime)
{
_bufferedImage = UtilText.stringToBufferedImage(_font, _text);
}
int color = 0;
for (int y = 0; y < _bufferedImage.getHeight(); y++)
{
for (int x = 0; x < _bufferedImage.getWidth(); x++)
{
color = _bufferedImage.getRGB(x, y);
if (!_invert && java.awt.Color.black.getRGB() != color)
continue;
else if (_invert && java.awt.Color.black.getRGB() == color)
continue;
Vector vector = new Vector((float) _bufferedImage.getWidth() / 2 - x, (float) _bufferedImage.getHeight() / 2 - y, 0).multiply(IMAGE_SIZE);
vector = rotateAroundAxisY(vector, -_effectLocation.getFixedLocation().getYaw() * (Math.PI / 180));
_coloredParticle.setLocation(_effectLocation.getFixedLocation().clone().add(vector));
_coloredParticle.display();
}
}
}
private Vector rotateAroundAxisY(Vector v, double angle)
{
double x, z, cos, sin;
cos = Math.cos(angle);
sin = Math.sin(angle);
x = v.getX() * cos + v.getZ() * sin;
z = v.getX() * -sin + v.getZ() * cos;
return v.setX(x).setZ(z);
}
}

View File

@ -1,9 +1,10 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
package mineplex.core.particleeffects;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
public class WitchParticleEffect extends Effect
{

View File

@ -1,57 +0,0 @@
package mineplex.core.pet;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.pet.repository.token.PetSalesToken;
import mineplex.core.shop.item.SalesPackageBase;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
public class Pet extends SalesPackageBase
{
private String _name;
private EntityType _petType;
private String _lore = null;
public Pet(String name, EntityType petType, int cost)
{
super(name, Material.MONSTER_EGG, (byte)petType.getTypeId(), new String[] {});
_name = name;
_petType = petType;
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost);
KnownPackage = false;
}
public Pet(String name, EntityType petType, int cost, String lore)
{
super(name, Material.MONSTER_EGG, (byte)petType.getTypeId(), new String[] {});
_name = name;
_petType = petType;
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost);
_lore = lore;
KnownPackage = false;
}
public EntityType getPetType()
{
return _petType;
}
public void update(PetSalesToken petToken)
{
_name = petToken.Name;
}
public String getPetName()
{
return _name;
}
public String getLore()
{
return _lore;
}
}

View File

@ -1,33 +1,28 @@
package mineplex.core.pet;
import org.bukkit.entity.EntityType;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.pet.repository.token.ClientPetToken;
import mineplex.core.pet.repository.token.PetToken;
import java.util.HashMap;
import java.util.Map;
import mineplex.core.pet.repository.token.ClientPetToken;
import mineplex.core.pet.repository.token.PetToken;
public class PetClient
{
private Map<EntityType, String> _pets = new HashMap<>();
private Map<PetType, String> _pets = new HashMap<>();
private int _petNameTagCount;
public void load(ClientPetToken token)
{
for (PetToken petToken : token.Pets)
{
if (petToken.PetName == null)
petToken.PetName = Enum.valueOf(EntityType.class, petToken.PetType).getName();
_pets.put(Enum.valueOf(EntityType.class, petToken.PetType), petToken.PetName);
PetType type = PetType.valueOf(petToken.PetType);
_pets.put(type, petToken.PetName != null ? petToken.PetName : type.getName());
}
_petNameTagCount = Math.max(0, token.PetNameTagCount);
}
public Map<EntityType, String> getPets()
public Map<PetType, String> getPets()
{
return _pets;
}

View File

@ -1,30 +1,22 @@
package mineplex.core.pet;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.pet.repository.token.PetExtraToken;
import mineplex.core.shop.item.SalesPackageBase;
import org.bukkit.Material;
public class PetExtra extends SalesPackageBase
import mineplex.core.pet.sales.PetExtraSalesPackage;
public enum PetExtra
{
private String _name;
private Material _material;
NAME_TAG("Name Tag", Material.NAME_TAG, 100)
;
private final String _name;
private final Material _material;
private final int _price;
public PetExtra(String name, Material material, int cost)
PetExtra(String name, Material material, int price)
{
super(name, material, (byte)0, new String[] { });
_name = name;
_material = material;
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, cost);
KnownPackage = false;
OneTimePurchaseOnly = false;
}
public void Update(PetExtraToken token)
{
_price = price;
}
public String getName()
@ -32,8 +24,18 @@ public class PetExtra extends SalesPackageBase
return _name;
}
public Material GetMaterial()
public Material getMaterial()
{
return _material;
}
public int getPrice()
{
return _price;
}
public PetExtraSalesPackage toSalesPackage(String text)
{
return new PetExtraSalesPackage(text, _material, _price);
}
}

View File

@ -1,72 +0,0 @@
package mineplex.core.pet;
import java.util.Collection;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.types.Elf;
import mineplex.core.pet.types.PetCoalApparition;
import mineplex.core.pet.types.Pumpkin;
public class PetFactory
{
private PetRepository _repository;
private NautHashMap<EntityType, Pet> _pets;
private NautHashMap<Material, PetExtra> _petExtras;
public PetFactory(PetRepository repository)
{
_repository = repository;
_pets = new NautHashMap<>();
_petExtras = new NautHashMap<>();
CreatePets();
CreatePetExtras();
}
private void CreatePets()
{
_pets.put(EntityType.ZOMBIE, new Pumpkin());
_pets.put(EntityType.PIG_ZOMBIE, new PetCoalApparition());
_pets.put(EntityType.VILLAGER, new Elf());
_pets.put(EntityType.PIG, new Pet("Pig", EntityType.PIG, 5000));
_pets.put(EntityType.SHEEP, new Pet("Sheep", EntityType.SHEEP, 3000));
_pets.put(EntityType.COW, new Pet("Cow", EntityType.COW, 2000));
_pets.put(EntityType.CHICKEN, new Pet("Chicken", EntityType.CHICKEN, 7000));
_pets.put(EntityType.WOLF, new Pet("Dog", EntityType.WOLF, 8000));
_pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000));
_pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000));
_pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -12));
_pets.put(EntityType.SKELETON, new Pet("Guardian", EntityType.SKELETON, -13));
_pets.put(EntityType.RABBIT, new Pet("Baby Zombie", EntityType.RABBIT, -9, "They're so cute - until a pack of them chases down your family and eats them."));
_pets.put(EntityType.BLAZE, new Pet("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?"));
}
private void CreatePetExtras()
{
_petExtras.put(Material.SIGN, new PetExtra("Name Tag", Material.NAME_TAG, 100));
}
public Collection<Pet> GetPets()
{
return _pets.values();
}
public Collection<PetExtra> GetPetExtras()
{
return _petExtras.values();
}
public Collection<PetExtra> GetPetExtraBySalesId(int salesId)
{
return _petExtras.values();
}
public Pet getPet(EntityType type)
{
return _pets.get(type);
}
}

View File

@ -1,37 +1,33 @@
package mineplex.core.pet;
import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import com.google.gson.Gson;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.shape.ShapeWings;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.donation.DonationManager;
import mineplex.core.events.AddConditionEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.NavigationAbstract;
import org.bukkit.*;
import org.bukkit.Bukkit;
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.CraftPigZombie;
import org.bukkit.entity.*;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Blaze;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Skeleton;
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.EntityDamageEvent;
@ -45,6 +41,35 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.google.gson.Gson;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Rank;
import mineplex.core.common.shape.ShapeWings;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.donation.DonationManager;
import mineplex.core.events.AddConditionEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PetManager extends MiniClientPlugin<PetClient>
{
private static Object _petOwnerSynch = new Object();
@ -53,13 +78,13 @@ public class PetManager extends MiniClientPlugin<PetClient>
private DisguiseManager _disguiseManager;
private mineplex.core.creature.Creature _creatureModule;
private PetRepository _repository;
private PetFactory _petFactory;
private BlockRestore _blockRestore;
private Map<String, PetType> _activePetOwnerTypes = new HashMap<>();
private NautHashMap<String, Creature> _activePetOwners;
private NautHashMap<String, Integer> _failedAttempts;
private NautHashMap<String, EntityType> _petOwnerQueue = new NautHashMap<String, EntityType>();
private Map<String, PetType> _petOwnerQueue = new HashMap<>();
private NautHashMap<String, String> _petRenameQueue = new NautHashMap<String, String>();
private DonationManager _donationManager;
private CoreClientManager _clientManager;
@ -78,7 +103,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
_creatureModule = creatureModule;
_disguiseManager = disguiseManager;
_repository = new PetRepository(plugin, webAddress);
_petFactory = new PetFactory(_repository);
_blockRestore = restore;
_donationManager = donationManager;
_clientManager = clientManager;
@ -88,11 +112,11 @@ public class PetManager extends MiniClientPlugin<PetClient>
_failedAttempts = new NautHashMap<String, Integer>();
}
public void addPetOwnerToQueue(String playerName, EntityType entityType)
public void addPetOwnerToQueue(String playerName, PetType petType)
{
synchronized (_petOwnerSynch)
{
_petOwnerQueue.put(playerName, entityType);
_petOwnerQueue.put(playerName, petType);
}
}
@ -150,22 +174,22 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (rank.has(Rank.LEGEND))
{
if (!Get(p).getPets().containsKey(EntityType.WITHER))
Get(p).getPets().put(EntityType.WITHER, "Widder");
if (!Get(p).getPets().containsKey(PetType.WITHER))
Get(p).getPets().put(PetType.WITHER, "Widder");
}
if (rank.has(Rank.TITAN))
{
if (!Get(p).getPets().containsKey(EntityType.SKELETON))
Get(p).getPets().put(EntityType.SKELETON, "Guardian");
if (!Get(p).getPets().containsKey(PetType.SKELETON))
Get(p).getPets().put(PetType.SKELETON, "Guardian");
}
}
public void addPetOwner(Player player, EntityType entityType, Location location)
public void addPetOwner(Player player, PetType petType, Location location)
{
if (_activePetOwners.containsKey(player.getName()))
if (_activePetOwnerTypes.containsKey(player.getName()))
{
if (_activePetOwners.get(player.getName()).getType() != entityType)
if (_activePetOwnerTypes.get(player.getName()) != petType)
{
removePet(player, true);
}
@ -174,6 +198,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
Creature pet;
EntityType entityType = petType.getEntityType();
//Wither Spawn
if (entityType == EntityType.WITHER)
@ -200,14 +225,14 @@ public class PetManager extends MiniClientPlugin<PetClient>
//Default Spawn
else
{
pet = (Creature)_creatureModule.SpawnEntity(location, entityType);
pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType());
}
//Named Pet
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
//pet.setCustomNameVisible(true);
pet.setCustomName(Get(player).getPets().get(entityType));
pet.setCustomName(Get(player).getPets().get(petType));
}
if (pet instanceof Zombie)
@ -282,6 +307,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
_grimReaperMorphs.put((Blaze) pet, grimReaperPetManager);
}
_activePetOwnerTypes.put(player.getName(), petType);
_activePetOwners.put(player.getName(), pet);
_failedAttempts.put(player.getName(), 0);
@ -318,6 +344,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (removeOwner)
{
_activePetOwnerTypes.remove(player.getName());
_activePetOwners.remove(player.getName());
}
}
@ -504,11 +531,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
return new PetClient();
}
public PetFactory getFactory()
{
return _petFactory;
}
public PetRepository getRepository()
{
return _repository;
@ -516,7 +538,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
public boolean hasActivePet(String name)
{
return _activePetOwners.containsKey(name);
return _activePetOwnerTypes.containsKey(name);
}
public PetType getActivePetType(String name)
{
return _activePetOwnerTypes.get(name);
}
public Creature getActivePet(String name)

View File

@ -0,0 +1,104 @@
package mineplex.core.pet;
import java.util.Optional;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import mineplex.core.pet.sales.PetSalesPackage;
public enum PetType
{
// These pets are named by EntityType for historic reasons -- the enum
// name() is stored by MSSQL to determine pet ownership. Future pet names
// can be made more accurate.
ZOMBIE("Pumpling", EntityType.ZOMBIE, -5), // Pumpling
PIG_ZOMBIE("Coal Apparition", EntityType.PIG_ZOMBIE, -1),
VILLAGER("Christmas Elf", EntityType.VILLAGER, -4),
PIG("Pig", EntityType.PIG, 5000),
SHEEP("Sheep", EntityType.SHEEP, 3000),
COW("Cow", EntityType.COW, 2000),
CHICKEN("Chicken", EntityType.CHICKEN, 7000),
WOLF("Dog", EntityType.WOLF, 8000),
OCELOT("Cat", EntityType.OCELOT, 6000),
MUSHROOM_COW("Mooshroom", EntityType.MUSHROOM_COW, 5000),
WITHER("Widder", EntityType.WITHER, -12),
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?"),
// 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.")
;
private final String _name;
private final EntityType _entityType;
private final int _price;
private final Optional<String> _lore;
private final Material _material;
private final byte _data;
PetType(String name, EntityType entityType, int price)
{
_name = name;
_entityType = entityType;
_price = price;
_lore = Optional.empty();
_material = Material.MONSTER_EGG;
_data = (byte) entityType.getTypeId();
}
PetType(String name, EntityType entityType, int price, String lore)
{
_name = name;
_entityType = entityType;
_price = price;
_lore = Optional.of(lore);
_material = Material.MONSTER_EGG;
_data = (byte) entityType.getTypeId();
}
PetType(String name, EntityType entityType, int price, String lore, Material material, byte data)
{
_name = name;
_entityType = entityType;
_price = price;
_lore = Optional.of(lore);
_material = material;
_data = data;
}
public String getName()
{
return _name;
}
public EntityType getEntityType()
{
return _entityType;
}
public int getPrice()
{
return _price;
}
public Optional<String> getLore()
{
return _lore;
}
public Material getMaterial()
{
return _material;
}
public byte getData()
{
return _data;
}
public PetSalesPackage toSalesPackage(String tagName)
{
return new PetSalesPackage(this, tagName);
}
}

View File

@ -2,19 +2,16 @@ package mineplex.core.pet.repository;
import java.util.List;
import mineplex.core.database.MinecraftRepository;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.gson.reflect.TypeToken;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
import mineplex.core.database.MinecraftRepository;
import mineplex.core.pet.repository.token.PetChangeToken;
import mineplex.core.pet.repository.token.PetExtraToken;
import mineplex.core.server.remotecall.AsyncJsonWebCall;
import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.serverdata.database.DBPool;
public class PetRepository extends MinecraftRepository
{
@ -30,37 +27,11 @@ public class PetRepository extends MinecraftRepository
public void AddPet(final PetChangeToken token)
{
new AsyncJsonWebCall(_webAddress + "Pets/AddPet").Execute(token);
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
public void run()
{
if (token.PetId == 0 || token.AccountId == 0)
return;
executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName)
, new ColumnInt("petId", token.PetId)
, new ColumnInt("accountId", token.AccountId));
}
});
}
public void RemovePet(final PetChangeToken token)
{
new AsyncJsonWebCall(_webAddress + "Pets/RemovePet").Execute(token);
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
public void run()
{
if (token.PetId == 0 || token.AccountId == 0)
return;
executeUpdate("DELETE FROM accountPets WHERE petId = ? AND accountId = ?;"
, new ColumnInt("petId", token.PetId)
, new ColumnInt("accountId", token.AccountId));
}
});
}
public List<PetExtraToken> GetPetExtras(List<PetExtraToken> petExtraTokens)
@ -71,26 +42,6 @@ public class PetRepository extends MinecraftRepository
public void UpdatePet(final PetChangeToken token)
{
new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token);
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
public void run()
{
if (token.PetId == 0 || token.AccountId == 0)
return;
int rowsChanged = executeUpdate("UPDATE accountPets SET petName = ? WHERE petId = ? AND accountId = ?;", new ColumnVarChar("petName", 32, token.PetName)
, new ColumnInt("petId", token.PetId)
, new ColumnInt("accountId", token.AccountId));
if (rowsChanged < 1)
{
executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName)
, new ColumnInt("petId", token.PetId)
, new ColumnInt("accountId", token.AccountId));
}
}
});
}
@Override

View File

@ -0,0 +1,19 @@
package mineplex.core.pet.sales;
import org.bukkit.Material;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.shop.item.SalesPackageBase;
public class PetExtraSalesPackage extends SalesPackageBase
{
public PetExtraSalesPackage(String name, Material material, int price)
{
super(name, material, (byte)0, new String[0]);
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, price);
KnownPackage = false;
OneTimePurchaseOnly = false;
}
}

View File

@ -0,0 +1,22 @@
package mineplex.core.pet.sales;
import org.bukkit.Material;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.pet.PetType;
import mineplex.core.shop.item.SalesPackageBase;
public class PetSalesPackage extends SalesPackageBase
{
@SuppressWarnings("deprecation")
public PetSalesPackage(PetType type, String tagName)
{
super(type.getName(), Material.MONSTER_EGG, (byte)type.getEntityType().getTypeId(), new String[0]);
CurrencyCostMap.put(GlobalCurrency.TREASURE_SHARD, type.getPrice());
KnownPackage = false;
setDisplayName(C.cGreen + "Purchase " + tagName);
}
}

View File

@ -1,14 +0,0 @@
package mineplex.core.pet.types;
import org.bukkit.entity.EntityType;
import mineplex.core.pet.Pet;
public class Elf extends Pet
{
public Elf()
{
super("Christmas Elf", EntityType.VILLAGER, -4);
}
}

View File

@ -1,14 +0,0 @@
package mineplex.core.pet.types;
import org.bukkit.entity.EntityType;
import mineplex.core.pet.Pet;
public class PetCoalApparition extends Pet
{
public PetCoalApparition()
{
super("Coal Apparition", EntityType.PIG_ZOMBIE, -1);
}
}

View File

@ -1,13 +0,0 @@
package mineplex.core.pet.types;
import org.bukkit.entity.EntityType;
import mineplex.core.pet.Pet;
public class Pumpkin extends Pet
{
public Pumpkin()
{
super("Pumpling", EntityType.ZOMBIE, -5);
}
}

View File

@ -1,9 +1,22 @@
package mineplex.core.powerplayclub;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.donation.DonationManager;
import mineplex.serverdata.database.DBPool;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,13 +25,10 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.*;
import java.sql.Date;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.donation.DonationManager;
import mineplex.serverdata.database.DBPool;
public class PowerPlayClubRepository implements Listener {
// Data loaded by the first ILoginProcessor, waiting for the second
@ -29,6 +39,8 @@ public class PowerPlayClubRepository implements Listener {
// giving a player his/her rewards.
private final Map<UUID, PowerPlayData> _cachedPlayerData = new HashMap<>();
private final Set<UUID> _yearlySubscriptions = new HashSet<>();
private final CoreClientManager _clientManager;
private final DonationManager _donationManager;
@ -74,6 +86,10 @@ public class PowerPlayClubRepository implements Listener {
LocalDate date = resultSet.getDate("startDate").toLocalDate();
PowerPlayData.SubscriptionDuration duration = PowerPlayData.SubscriptionDuration.valueOf(resultSet.getString("duration").toUpperCase());
subscriptions.add(new PowerPlayData.Subscription(date, duration));
if (duration.equals(PowerPlayData.SubscriptionDuration.YEAR))
{
_yearlySubscriptions.add(uuid);
}
}
// Now that we have the claims from the first processor and subscriptions from this one, combine them
@ -97,6 +113,9 @@ public class PowerPlayClubRepository implements Listener {
PowerPlayClubRewards.rewardsForMonths(cached.getUsableCosmeticMonths()).stream()
.map(PowerPlayClubRewards.PowerPlayClubItem::getPrize)
.forEach(_donationManager.Get(player)::AddUnknownSalesPackagesOwned);
// Gives Metal Man for anyone subscribed
_donationManager.Get(player).AddUnknownSalesPackagesOwned("Metal Man Morph");
}
@EventHandler
@ -104,6 +123,7 @@ public class PowerPlayClubRepository implements Listener {
{
_stageOneDataClaims.remove(event.getPlayer().getUniqueId()); // Just in case.
_cachedPlayerData.remove(event.getPlayer().getUniqueId());
_yearlySubscriptions.remove(event.getPlayer().getUniqueId());
}
public CompletableFuture<Void> addSubscription(int accountId, LocalDate date, String duration)

View File

@ -1,4 +1,4 @@
package mineplex.core.titangiveaway;
package mineplex.core.rankGiveaway;
import java.util.Random;

View File

@ -0,0 +1,61 @@
package mineplex.core.rankGiveaway.fatedgiveaway;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class FatedGiveawayAnimation implements Listener
{
private Location _location;
private Long _duration, _startTime, _worldTime;
public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start, Long duration)
{
_location = start.clone();
_duration = duration;
_startTime = System.currentTimeMillis();
Bukkit.getPluginManager().registerEvents(this, manager.getPlugin());
}
public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start)
{
this(manager, start, 11111L);
}
@EventHandler(priority = EventPriority.MONITOR)
public void tick(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (UtilTime.elapsed(_startTime, _duration))
{
remove();
return;
}
for (Player player : UtilServer.getPlayers())
{
player.playSound(_location, Sound.ORB_PICKUP, 5, 5);
UtilFirework.packetPlayFirework(player, _location, Type.BURST, Color.fromRGB(255, 105, 180), true, false);
}
}
private void remove()
{
HandlerList.unregisterAll(this);
}
}

View File

@ -0,0 +1,111 @@
package mineplex.core.rankGiveaway.fatedgiveaway;
import java.util.Random;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.rankGiveaway.redis.FatedGiveawayMessage;
import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler;
import mineplex.core.status.ServerStatusManager;
import mineplex.serverdata.Region;
import mineplex.serverdata.commands.ServerCommandManager;
public class FatedGiveawayManager extends MiniPlugin
{
private static final double RANK_FIND_CHANCE = 0.001;
private FatedGiveawayRepository _repository;
private CoreClientManager _clientManager;
private ServerStatusManager _statusManager;
private Random _random;
public FatedGiveawayManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager)
{
super("Fated Giveaway", plugin);
_repository = new FatedGiveawayRepository(plugin);
_clientManager = clientManager;
_statusManager = statusManager;
_random = new Random();
ServerCommandManager.getInstance().registerCommandType("FatedGiveawayMessage", FatedGiveawayMessage.class, new GiveawayMessageHandler(plugin));
}
public void openPumpkin(final Player player, final Runnable onSuccess)
{
double rand = _random.nextDouble();
if (!hasFated(player) && rand < RANK_FIND_CHANCE)
{
final int accountId = _clientManager.getAccountId(player);
final Region region = getRegion();
final String serverName = getServerName();
// Need to check database that we can give away a rank
runAsync(new Runnable()
{
@Override
public void run()
{
final boolean pass = _repository.canGiveaway(region);
if (pass && _repository.addFated(accountId, region, serverName))
{
runSync(new Runnable()
{
@Override
public void run()
{
giveRank(new Callback<Rank>()
{
@Override
public void run(Rank rank)
{
// TODO CHANGE RANK
if (rank == Rank.TITAN)
{
FatedGiveawayMessage message = new FatedGiveawayMessage(player.getName(), _repository.getFatedCount() + 1);
message.publish();
if (onSuccess != null) onSuccess.run();
}
}
// TODO CHANGE RANK
}, Rank.TITAN, player);
}
});
}
}
});
}
}
/**
* Confirm that the player doesn't already have FATED rank
*/
private boolean hasFated(Player player)
{
// TODO CHANGE RANK
return _clientManager.hasRank(player, Rank.TITAN);
}
public Region getRegion()
{
return _statusManager.getRegion();
}
public String getServerName()
{
return _statusManager.getCurrentServerName();
}
private void giveRank(Callback<Rank> callback, Rank rank, Player player)
{
_clientManager.Get(player).SetRank(rank, false);
_clientManager.getRepository().saveRank(callback, player.getName(), player.getUniqueId(), rank, true);
}
}

View File

@ -0,0 +1,71 @@
package mineplex.core.rankGiveaway.fatedgiveaway;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Types;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.Region;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
public class FatedGiveawayRepository extends MinecraftRepository
{
private static final String ADD_FATED = "INSERT INTO fatedGiveaway (accountId, region, serverName) VALUES (?, ?, ?)";
private int _fatedCount;
public FatedGiveawayRepository(JavaPlugin plugin)
{
super(plugin, DBPool.getAccount());
_fatedCount = 0;
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
public boolean addFated(int accountId, Region region, String serverName)
{
return 1 == executeUpdate(ADD_FATED, new ColumnInt("accountId", accountId), new ColumnVarChar("region", 10, region.name()), new ColumnVarChar("serverName", 64, serverName));
}
public boolean canGiveaway(Region region)
{
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_fatedGiveaway(?, ?, ?)}"))
{
callableStatement.setString(1, region.name());
callableStatement.registerOutParameter(2, Types.BOOLEAN);
callableStatement.registerOutParameter(3, Types.INTEGER);
callableStatement.executeUpdate();
boolean pass = callableStatement.getBoolean(2);
int fatedCount = callableStatement.getInt(3);
_fatedCount = fatedCount;
return pass;
}
catch (Exception e)
{
e.printStackTrace();
}
return false;
}
public int getFatedCount()
{
return _fatedCount;
}
}

View File

@ -0,0 +1,32 @@
package mineplex.core.rankGiveaway.redis;
import mineplex.serverdata.commands.ServerCommand;
public class FatedGiveawayMessage extends ServerCommand
{
private String _playerName;
private int _fatedCount;
public FatedGiveawayMessage(String playerName, int fatedCount)
{
_playerName = playerName;
_fatedCount = fatedCount;
}
public String getPlayerName()
{
return _playerName;
}
public int getFatedCount()
{
return _fatedCount;
}
@Override
public void run()
{
// Handled in Command Callback
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.titangiveaway.redis;
package mineplex.core.rankGiveaway.redis;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
@ -10,7 +10,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.titangiveaway.LightFlicker;
import mineplex.core.rankGiveaway.LightFlicker;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
@ -44,5 +44,22 @@ public class GiveawayMessageHandler implements CommandCallback
player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1);
}
}
else if (command instanceof FatedGiveawayMessage)
{
FatedGiveawayMessage message = ((FatedGiveawayMessage) command);
String playerName = message.getPlayerName();
int count = message.getFatedCount();
String countString = count + UtilTime.getDayOfMonthSuffix(count);
String chatMessage = C.cPurple + playerName + C.cWhite + " found Fated in a " + C.cPurple + "Thanksgiving Chicken";
UtilTextMiddle.display(C.cDPurple + C.Bold + "FATED", chatMessage, 20, 80, 20, UtilServer.getPlayers());
World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0);
LightFlicker lightFlicker = new LightFlicker(world);
lightFlicker.runTaskTimer(_plugin, 1, 1);
for (Player player : UtilServer.getPlayers())
{
player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1);
}
}
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.titangiveaway.redis;
package mineplex.core.rankGiveaway.redis;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package mineplex.core.titangiveaway.redis;
package mineplex.core.rankGiveaway.redis;
import mineplex.serverdata.commands.ServerCommand;

View File

@ -1,4 +1,4 @@
package mineplex.core.titangiveaway.redis;
package mineplex.core.rankGiveaway.redis;
import mineplex.serverdata.commands.ServerCommand;

View File

@ -1,11 +1,4 @@
package mineplex.core.titangiveaway;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
package mineplex.core.rankGiveaway.titangiveaway;
import org.bukkit.Bukkit;
import org.bukkit.Color;
@ -18,6 +11,12 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class TitanGiveawayAnimation implements Listener
{
private Location _location;

View File

@ -1,4 +1,4 @@
package mineplex.core.titangiveaway;
package mineplex.core.rankGiveaway.titangiveaway;
import java.util.Random;
@ -10,17 +10,17 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.titangiveaway.redis.GiveawayMessageHandler;
import mineplex.core.titangiveaway.redis.TitanChestGiveawayHandler;
import mineplex.core.titangiveaway.redis.TitanChestGiveawayMessage;
import mineplex.core.titangiveaway.redis.TitanGiveawayMessage;
import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler;
import mineplex.core.rankGiveaway.redis.TitanChestGiveawayHandler;
import mineplex.core.rankGiveaway.redis.TitanChestGiveawayMessage;
import mineplex.core.rankGiveaway.redis.TitanGiveawayMessage;
import mineplex.serverdata.Region;
import mineplex.serverdata.commands.ServerCommandManager;
public class TitanGiveawayManager extends MiniPlugin
{
private static final double RANK_FIND_CHANCE = 0.001;
// private static final double RANK_FIND_CHANCE = 1;
private TitanGiveawayRepository _repository;
private CoreClientManager _clientManager;

View File

@ -1,4 +1,4 @@
package mineplex.core.titangiveaway;
package mineplex.core.rankGiveaway.titangiveaway;
import java.sql.CallableStatement;
import java.sql.Connection;
@ -8,7 +8,6 @@ import mineplex.core.database.MinecraftRepository;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
import mineplex.serverdata.Region;

View File

@ -6,7 +6,6 @@ import java.util.List;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -129,8 +128,8 @@ import mineplex.core.mount.types.MountSpider;
import mineplex.core.mount.types.MountUndead;
import mineplex.core.mount.types.MountValentinesSheep;
import mineplex.core.mount.types.MountZombie;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetManager;
import mineplex.core.pet.PetType;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.rewards.ChestReward;
import mineplex.core.reward.rewards.GameAmplifierReward;
@ -242,13 +241,13 @@ public class RewardManager
addInventoryReward(Type.NORMAL, getGadget(ItemTNT.class), rarity, 250, 0, 20, 40);
//Pets
addPetReward(Type.NORMAL, EntityType.CHICKEN, rarity, 143);
addPetReward(Type.NORMAL, EntityType.COW, rarity, 500);
addPetReward(Type.NORMAL, EntityType.MUSHROOM_COW, rarity, 200);
addPetReward(Type.NORMAL, EntityType.OCELOT, rarity, 167);
addPetReward(Type.NORMAL, EntityType.PIG, rarity, 200);
addPetReward(Type.NORMAL, EntityType.SHEEP, rarity, 333);
addPetReward(Type.NORMAL, EntityType.WOLF, rarity, 125);
addPetReward(Type.NORMAL, PetType.CHICKEN, rarity, 143);
addPetReward(Type.NORMAL, PetType.COW, rarity, 500);
addPetReward(Type.NORMAL, PetType.MUSHROOM_COW, rarity, 200);
addPetReward(Type.NORMAL, PetType.OCELOT, rarity, 167);
addPetReward(Type.NORMAL, PetType.PIG, rarity, 200);
addPetReward(Type.NORMAL, PetType.SHEEP, rarity, 333);
addPetReward(Type.NORMAL, PetType.WOLF, rarity, 125);
//Music Discs
@ -543,12 +542,12 @@ public class RewardManager
addGadget(Type.FREEDOM, getGadget(MorphUncleSam.class), rarity, 5);
addGadget(Type.FREEDOM, getGadget(ParticleFreedom.class), rarity, 50);
// OMEGA
addPetReward(Type.OMEGA, EntityType.VILLAGER, rarity, 1);
addPetReward(Type.OMEGA, EntityType.ZOMBIE, rarity, 10);
addPetReward(Type.OMEGA, EntityType.PIG_ZOMBIE, rarity, 1);
addPetReward(Type.OMEGA, EntityType.RABBIT, rarity, 10);
addPetReward(Type.OMEGA, EntityType.BLAZE, rarity, 2);
// Omega items
addPetReward(Type.OMEGA, PetType.VILLAGER, rarity, 1);
addPetReward(Type.OMEGA, PetType.ZOMBIE, rarity, 10);
addPetReward(Type.OMEGA, PetType.PIG_ZOMBIE, rarity, 1);
addPetReward(Type.OMEGA, PetType.BLAZE, rarity, 2);
addPetReward(Type.OMEGA, PetType.RABBIT, rarity, 10);
addGadget(Type.OMEGA, getGadget(MorphBunny.class), rarity, 1);
addGadget(Type.OMEGA, getGadget(MorphUncleSam.class), rarity, 5);
@ -608,7 +607,7 @@ public class RewardManager
addHat(Type.OMEGA, HatType.GRINCH, rarity, 25);
// HAUNTED
addPetReward(Type.HAUNTED, EntityType.RABBIT, rarity, 100);
addPetReward(Type.HAUNTED, PetType.RABBIT, rarity, 100);
addGadget(Type.HAUNTED, getGadget(MorphGrimReaper.class), rarity, 25);
addGadget(Type.HAUNTED, getGadget(WinEffectHalloween.class), rarity, 50);
addMount(Type.HAUNTED, getMount(MountNightmareSteed.class), rarity, 60);
@ -617,7 +616,7 @@ public class RewardManager
addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.MYTHICAL, 1, 3, rarity, 50, 0));
addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ILLUMINATED, 1, 1, rarity, 30, 0));
addMount(Type.TRICK_OR_TREAT, getMount(MountZombie.class), rarity, 25);
addPetReward(Type.TRICK_OR_TREAT, EntityType.ZOMBIE, rarity, 10);
addPetReward(Type.TRICK_OR_TREAT, PetType.ZOMBIE, rarity, 10);
addGadget(Type.TRICK_OR_TREAT, getGadget(MorphPumpkinKing.class), rarity, 5);
}
@ -731,16 +730,15 @@ public class RewardManager
return reward;
}
public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight)
public PetReward addPetReward(Type type, PetType petType, RewardRarity rarity, int weight)
{
return addPetReward(type, entityType, rarity, weight, getShards(rarity));
return addPetReward(type, petType, rarity, weight, getShards(rarity));
}
public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight, int shards)
public PetReward addPetReward(Type type, PetType petType, RewardRarity rarity, int weight, int shards)
{
Pet pet = _petManager.getFactory().getPet(entityType);
PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager,
pet.getName() + " Pet", pet.getName(), entityType, rarity, weight, shards);
petType.getName() + " Pet", petType.getName(), petType, rarity, weight, shards);
addReward(type, reward);
return reward;
}

View File

@ -1,7 +1,6 @@
package mineplex.core.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -9,6 +8,7 @@ import mineplex.cache.player.PlayerCache;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.pet.PetType;
import mineplex.core.pet.repository.token.PetChangeToken;
import mineplex.core.pet.repository.token.PetToken;
import mineplex.core.reward.RewardData;
@ -22,15 +22,15 @@ public class PetReward extends UnknownPackageReward
{
private InventoryManager _inventoryManager;
private PetManager _petManager;
private EntityType _petEntity;
private PetType _petType;
public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, EntityType petEntity, RewardRarity rarity, int weight, int shardValue)
public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, PetType petType, RewardRarity rarity, int weight, int shardValue)
{
super(donationManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petEntity.getTypeId()), rarity, weight, shardValue);
super(donationManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petType.getEntityType().getTypeId()), rarity, weight, shardValue);
_petManager = petManager;
_inventoryManager = inventoryManager;
_petEntity = petEntity;
_petType = petType;
}
@Override
@ -44,16 +44,16 @@ public class PetReward extends UnknownPackageReward
token.AccountId = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId();
token.Name = player.getName();
token.PetType = _petEntity.toString();
token.PetType = _petType.toString();
token.PetName = getPackageName();
PetToken petToken = new PetToken();
petToken.PetType = token.PetType;
_petManager.getRepository().AddPet(token);
_petManager.Get(player).getPets().put(_petEntity, token.PetName);
_petManager.Get(player).getPets().put(_petType, token.PetName);
_inventoryManager.addItemToInventory(player, _petEntity.toString(), 1);
_inventoryManager.addItemToInventory(player, _petType.toString(), 1);
return getFakeRewardData(player);
}
@ -67,6 +67,6 @@ public class PetReward extends UnknownPackageReward
return false;
}
return !_petManager.Get(player).getPets().containsKey(_petEntity);
return !_petManager.Get(player).getPets().containsKey(_petType);
}
}

View File

@ -1,13 +1,5 @@
package mineplex.core.shop.page;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.item.IButton;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom;
@ -19,6 +11,15 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.item.IButton;
public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType extends ShopBase<PluginType>> extends CraftInventoryCustom implements Listener
{
protected PluginType _plugin;
@ -87,11 +88,22 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
protected void addButton(int slot, ItemStack item, IButton button)
{
if (button == null)
{
addButtonNoAction(slot, item);
return;
}
addItem(slot, item);
_buttonMap.put(slot, button);
}
protected void addButtonNoAction(int slot, ItemStack item)
{
addItem(slot, item);
}
protected void addButtonFakeCount(int slot, ItemStack item, IButton button, int fakeItemCount)
{
addItemFakeCount(slot, item, fakeItemCount);

View File

@ -12,7 +12,7 @@ import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.hologram.HologramManager;
import mineplex.core.reward.*;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.titangiveaway.redis.TitanChestGiveawayMessage;
import mineplex.core.rankGiveaway.redis.TitanChestGiveawayMessage;
import mineplex.core.treasure.animation.*;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;

View File

@ -27,7 +27,7 @@ import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.gadget.gadgets.particle.unrelated.BabyFireworkEffect;
import mineplex.core.particleeffects.BabyFireworkEffect;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;

View File

@ -45,7 +45,7 @@ import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.thank.ThankManager;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.velocity.VelocityFix;

View File

@ -1,5 +1,10 @@
package mineplex.hub;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.account.CoreClientManager;
@ -56,7 +61,7 @@ import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.thank.ThankManager;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.velocity.VelocityFix;
@ -75,10 +80,6 @@ import mineplex.minecraft.game.core.IRelation;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import static mineplex.core.Managers.require;

View File

@ -9,7 +9,7 @@ import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetFactory;
import mineplex.core.pet.PetType;
import mineplex.core.pet.repository.PetRepository;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.stats.StatsManager;
@ -45,7 +45,6 @@ public class SalesPackageManager extends MiniPlugin
private StatsManager _statsManager;
private PowerPlayClubRepository _powerPlayRepo;
private PetRepository _petRepo;
private PetFactory _petFactory;
private NautHashMap<String, SalesPackageBase> _salesPackages = new NautHashMap<String, SalesPackageBase>();
@ -60,7 +59,6 @@ public class SalesPackageManager extends MiniPlugin
_powerPlayRepo = powerPlayRepo;
_petRepo = new PetRepository(plugin, plugin.getConfig().getString("webServer"));
_petFactory = new PetFactory(_petRepo);
//Strutt20 asked me to remove some of the stuff from the menu
@ -95,9 +93,9 @@ public class SalesPackageManager extends MiniPlugin
AddSalesPackage(new HauntedChest(this));
AddSalesPackage(new TrickOrTreatChest(this));
for (mineplex.core.pet.Pet pet : _petFactory.GetPets())
for (PetType petType : PetType.values())
{
AddSalesPackage(new Pet(this, pet.getName(), pet.getPetType()));
AddSalesPackage(new Pet(this, petType.getName(), petType));
}
}
@ -138,11 +136,6 @@ public class SalesPackageManager extends MiniPlugin
return _petRepo;
}
public PetFactory getPetFactory()
{
return _petFactory;
}
public void help(Player player)
{
}

View File

@ -2,7 +2,6 @@ package mineplex.staffServer.salespackage.command;
import java.util.UUID;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.google.gson.Gson;
@ -11,8 +10,8 @@ import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetClient;
import mineplex.core.pet.PetType;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.pet.repository.token.PetChangeToken;
import mineplex.staffServer.salespackage.SalesPackageManager;
@ -33,13 +32,13 @@ public class PetCommand extends CommandBase<SalesPackageManager>
final String playerName = args[0];
int petId = Integer.parseInt(args[1]);
if ((petId < 0 || petId >= EntityType.values().length) || Plugin.getPetFactory().getPet(EntityType.values()[petId]) == null)
if (petId < 0 || petId >= PetType.values().length)
{
caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Pet Type."));
return;
}
final EntityType petType = EntityType.values()[petId];
final PetType petType = PetType.values()[petId];
Plugin.getClientManager().loadClientByName(playerName, client ->
{
@ -57,12 +56,11 @@ public class PetCommand extends CommandBase<SalesPackageManager>
}
else
{
Pet pet = Plugin.getPetFactory().getPet(petType);
PetChangeToken token = new PetChangeToken();
token.AccountId = client.getAccountId();
token.Name = playerName;
token.PetType = petType.toString();
token.PetName = pet.getName();
token.PetName = petType.getName();
Plugin.getPetRepo().AddPet(token);
Plugin.getInventoryManager().addItemToInventoryForOffline(success ->

View File

@ -1,16 +1,16 @@
package mineplex.staffServer.salespackage.salespackages;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import mineplex.core.pet.PetType;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class Pet extends SalesPackageBase
{
private String _petName;
private EntityType _petType;
private PetType _petType;
public Pet(SalesPackageManager manager, String petName, EntityType petType)
public Pet(SalesPackageManager manager, String petName, PetType petType)
{
super(manager, "1 " + petName + " Pet");
_petName = petName;

View File

@ -14,7 +14,6 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -90,9 +89,8 @@ import mineplex.core.preferences.PreferencesManager;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager;
import mineplex.core.resourcepack.ResourcePackManager;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.scoreboard.MineplexScoreboard;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.sponsorbranding.BrandingManager;
@ -102,7 +100,7 @@ import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport;
import mineplex.core.thank.ThankManager;
import mineplex.core.timing.TimingManager;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
import mineplex.core.valentines.ValentinesGiftManager;
import mineplex.core.youtube.YoutubeManager;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
@ -154,6 +152,7 @@ import nautilus.game.arcade.managers.GameStatManager;
import nautilus.game.arcade.managers.GameTestingManager;
import nautilus.game.arcade.managers.GameTournamentManager;
import nautilus.game.arcade.managers.GameWorldManager;
import nautilus.game.arcade.managers.HolidayManager;
import nautilus.game.arcade.managers.IdleManager;
import nautilus.game.arcade.managers.MiscManager;
import nautilus.game.arcade.managers.NextBestGameManager;
@ -346,9 +345,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_hologramManager = hologramManager;
_idleManager = new IdleManager(this);
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
FatedGiveawayManager fatedGiveaway = new FatedGiveawayManager(getPlugin(), clientManager, serverStatusManager);
//new HolidayManager(this, titanGiveaway);
IsHolidayEnabled = false;
new HolidayManager(this, titanGiveaway, fatedGiveaway);
IsHolidayEnabled = true;
new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager);
new GameTestingManager(this);
@ -1708,20 +1708,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _idleManager;
}
public void rewardPet(Player player, String pet, EntityType type)
{
if (!player.isOnline())
return;
PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, pet, pet, type, RewardRarity.OTHER, 0, 0);
if (reward.canGiveReward(player))
reward.giveReward(null, player, data ->
{
});
}
public void enableChampionsModules()
{
if (_registered == null || !_registered)

View File

@ -12,7 +12,6 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -34,6 +33,7 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.pet.PetType;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.updater.UpdateType;
@ -682,7 +682,7 @@ public class Halloween2016 extends Halloween
if (!player.isOnline())
continue;
PetReward pr = new PetReward(Manager.getCosmeticManager().getPetManager(), Manager.getInventoryManager(), Manager.GetDonation(), "Grim Reaper", "Grim Reaper", EntityType.BLAZE, RewardRarity.OTHER, 0, 0);
PetReward pr = new PetReward(Manager.getCosmeticManager().getPetManager(), Manager.getInventoryManager(), Manager.GetDonation(), "Grim Reaper", "Grim Reaper", PetType.BLAZE, RewardRarity.OTHER, 0, 0);
if (pr.canGiveReward(player))
{

View File

@ -4,45 +4,71 @@ import java.util.EnumMap;
import java.util.HashSet;
import java.util.Iterator;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.gadgets.particle.unrelated.HalloweenSmashedEffect;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardRarity;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.treasure.TreasureType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.particleeffects.HalloweenSmashedEffect;
import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayAnimation;
import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager;
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.TreasureType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.managers.events.SpecialEntityDeathEvent;
public class HolidayManager implements Listener
{
public enum HolidayType
{
Christmas(Material.CHEST, "Present", Sound.CAT_MEOW),
Halloween(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY),
Easter(Material.CHEST, "Egg Basket", Sound.CAT_MEOW);
CHRISTMAS(Material.CHEST, "Present", Sound.CAT_MEOW),
HALLOWEEN(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY),
EASTER(Material.CHEST, "Egg Basket", Sound.CAT_MEOW),
THANKSGIVING(null, C.cGoldB + "Thanksgiving Chicken", null);
private Material _blockType;
private String _blockName;
@ -71,29 +97,34 @@ public class HolidayManager implements Listener
}
}
private HolidayType type = HolidayType.Halloween;
private String _statName = "Halloween 2016";
private HolidayType _type = HolidayType.THANKSGIVING;
private String _statName = "Thanksgiving Chickens 2016";
ArcadeManager Manager;
private ArcadeManager _arcadeManager;
private TitanGiveawayManager _titanManager;
private FatedGiveawayManager _fatedManager;
public HashSet<Block> _active = new HashSet<Block>();
public HashSet<Block> _active = new HashSet<>();
public HashSet<org.bukkit.entity.Entity> _activeEntities = new HashSet<>();
private HashSet<Item> _eggs = new HashSet<Item>();
private HashSet<Item> _items = new HashSet<>();
private HashSet<Item> _coins = new HashSet<Item>();
private HashSet<Item> _gems = new HashSet<Item>();
private HashSet<Item> _coins = new HashSet<>();
private HashSet<Item> _gems = new HashSet<>();
private static final double CHEST_CHANCE = 0.001;
private static final double SPAWN_CHANCE = 0.01;
private static final double CHICKEN_DAMAGE = 0.5;
public long _lastSpawn = System.currentTimeMillis();
private EnumMap<RewardPool.Type, RewardPool> _rewardPools;
public HolidayManager(ArcadeManager manager, TitanGiveawayManager titanManager)
public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager, FatedGiveawayManager fatedManager)
{
Manager = manager;
_arcadeManager = arcadeManager;
_titanManager = titanManager;
_fatedManager = fatedManager;
_rewardPools = new EnumMap<>(RewardPool.Type.class);
for (RewardPool.Type type : RewardPool.Type.values())
@ -101,7 +132,7 @@ public class HolidayManager implements Listener
_rewardPools.put(type, new RewardPool());
}
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
_arcadeManager.getPluginManager().registerEvents(this, _arcadeManager.getPlugin());
}
@EventHandler
@ -134,7 +165,7 @@ public class HolidayManager implements Listener
continue;
}
if (type == HolidayType.Halloween)
if (_type.equals(HolidayType.HALLOWEEN))
{
UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4,
ViewDist.LONG, UtilServer.getPlayers());
@ -150,7 +181,7 @@ public class HolidayManager implements Listener
}
}
}
else if (type == HolidayType.Easter)
else if (_type.equals(HolidayType.EASTER))
{
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, block.getLocation().add(0.5, 0.2, 0.5), 0.3f, 0.2f, 0.3f, 0, 1,
ViewDist.LONG, UtilServer.getPlayers());
@ -161,7 +192,7 @@ public class HolidayManager implements Listener
ItemStackFactory.Instance.CreateStack(Material.EGG, (byte)0, 1, System.currentTimeMillis() + "Egg"));
egg.setVelocity(new Vector((Math.random()-0.5)*0.3, Math.random()-0.4, (Math.random()-0.5)*0.3));
_eggs.add(egg);
_items.add(egg);
block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_EGG_POP, 0.25f + (float)Math.random() * 0.75f, 0.75f + (float)Math.random() * 0.5f);
}
@ -171,12 +202,35 @@ public class HolidayManager implements Listener
sendChestPackets(block);
}
}
else if (type == HolidayType.Christmas)
else if (_type.equals(HolidayType.CHRISTMAS))
{
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0, 3,
ViewDist.LONG, UtilServer.getPlayers());
}
}
Iterator<org.bukkit.entity.Entity> entityIterator = _activeEntities.iterator();
while (entityIterator.hasNext())
{
org.bukkit.entity.Entity entity = entityIterator.next();
if (!(entity instanceof Chicken))
{
specialEntityKill(null, entity);
entityIterator.remove();
}
if (_type.equals(HolidayType.THANKSGIVING))
{
if (Math.random() > 0.90)
{
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, entity.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0, 3,
ViewDist.LONG, UtilServer.getPlayers());
}
}
}
}
@EventHandler
@ -185,25 +239,28 @@ public class HolidayManager implements Listener
if (event.getType() != UpdateType.SEC)
return;
if (Manager.GetGame() == null)
if (_arcadeManager.GetGame() == null)
return;
if (Manager.GetGameHostManager().isPrivateServer())
if (_arcadeManager.GetGameHostManager().isPrivateServer())
return;
Game game = Manager.GetGame();
Game game = _arcadeManager.GetGame();
int requirement = (int)((double)Manager.GetPlayerFull() * 0.5d);
int requirement = (int)((double) _arcadeManager.GetPlayerFull() * 0.5d);
if (UtilServer.getPlayers().length < requirement)
return;
if (game.GetState() != GameState.Live)
return;
if (game.GetType().equals(GameType.UHC))
return;
if (!UtilTime.elapsed(_lastSpawn, 90000))
return;
if (Math.random() > 0.01)
if (Math.random() > SPAWN_CHANCE)
return;
int toDrop = Math.max(1, game.GetPlayers(false).size()/6);
@ -228,10 +285,26 @@ public class HolidayManager implements Listener
return;
}
block.setType(type.getBlockType());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType());
if (_type.getBlockType() == null && _type.equals(HolidayType.THANKSGIVING))
{
// Spawns thanksgiving chicken
boolean oldValue = _arcadeManager.GetGame().CreatureAllowOverride;
_arcadeManager.GetGame().CreatureAllowOverride = true;
Chicken chicken = block.getWorld().spawn(block.getLocation().clone().add(.5, .5, .5), Chicken.class);
_arcadeManager.GetGame().CreatureAllowOverride = oldValue;
chicken.setAdult();
chicken.setCustomName(_type.getBlockName());
chicken.setCustomNameVisible(true);
chicken.setVelocity(chicken.getVelocity().multiply(15));
block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_IDLE, 1f, 1f);
_activeEntities.add(chicken);
return;
}
if (type.getBlockType() == Material.CHEST)
block.setType(_type.getBlockType());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _type.getBlockType());
if (_type.getBlockType() == Material.CHEST)
{
sendChestPackets(block);
}
@ -299,12 +372,108 @@ public class HolidayManager implements Listener
if (UtilPlayer.isSpectator(event.getPlayer()))
return;
if (Manager.GetGame() != null && !Manager.GetGame().IsAlive(event.getPlayer()))
if (_arcadeManager.GetGame() != null && !_arcadeManager.GetGame().IsAlive(event.getPlayer()))
return;
specialBlockBreak(event.getPlayer(), event.getClickedBlock());
}
@EventHandler
public void specialEntityDeath(SpecialEntityDeathEvent event)
{
if (!_type.equals(HolidayType.THANKSGIVING))
return;
if (!(event.getEntity() instanceof Chicken))
return;
if (event.getKiller() == null)
return;
Chicken chicken = (Chicken) event.getEntity();
Player killer = event.getKiller();
if (_arcadeManager.GetGame() != null && !_arcadeManager.GetGame().IsAlive(killer))
return;
if (!_activeEntities.contains(chicken))
return;
_activeEntities.remove(chicken);
specialEntityKill(killer, chicken);
killer.getWorld().playSound(killer.getLocation(), Sound.CHICKEN_HURT, 1f, 1f);
}
@EventHandler
public void specialEntityDamage(EntityDamageEvent event)
{
if (!(event.getEntity() instanceof Chicken))
return;
if (_arcadeManager.GetGame() == null)
return;
Chicken chicken = (Chicken) event.getEntity();
if (!_activeEntities.contains(chicken))
return;
if (event.getCause().equals(EntityDamageEvent.DamageCause.VOID) || event.getCause().equals(EntityDamageEvent.DamageCause.LAVA) ||
event.getCause().equals(EntityDamageEvent.DamageCause.FALL))
{
specialEntityKill(null, chicken);
_activeEntities.remove(chicken);
chicken.remove();
}
event.setCancelled(true);
}
@EventHandler
public void specialEntityDamageByEntity(EntityDamageByEntityEvent event)
{
if (!(event.getEntity() instanceof Chicken))
return;
if (!(event.getDamager() instanceof Player))
return;
if (_arcadeManager.GetGame() == null)
return;
if (UtilPlayer.isSpectator(event.getDamager()))
return;
Chicken chicken = (Chicken) event.getEntity();
if (!_activeEntities.contains(chicken))
return;
if (chicken.getHealth() <= CHICKEN_DAMAGE)
{
SpecialEntityDeathEvent specialEntityDeathEvent = new SpecialEntityDeathEvent(chicken, (Player) event.getDamager());
Bukkit.getPluginManager().callEvent(specialEntityDeathEvent);
chicken.remove();
return;
}
chicken.damage(CHICKEN_DAMAGE);
}
@EventHandler
public void cancelSpecialEntityItemDrops(ItemSpawnEvent event)
{
Material material = event.getEntity().getItemStack().getType();
if (material.equals(Material.FEATHER) || material.equals(Material.RAW_CHICKEN) || material.equals(Material.BONE))
{
if (_items.contains(event.getEntity()))
return;
event.getEntity().remove();
event.setCancelled(true);
}
}
private void specialBlockBreak(Player player, final Block block)
{
if (!_active.contains(block))
@ -312,12 +481,12 @@ public class HolidayManager implements Listener
_active.remove(block);
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _type.getBlockType());
block.setType(Material.AIR);
if (player != null && Manager.GetGame() != null)
if (player != null && _arcadeManager.GetGame() != null)
{
Manager.GetGame().AddStat(player, _statName, 1, false, true);
_arcadeManager.GetGame().AddStat(player, _statName, 1, false, true);
System.out.println("Recording Pumpkin Break for " + player.getName());
}
@ -373,7 +542,7 @@ public class HolidayManager implements Listener
if (player != null)
{
InventoryManager manager = Manager.getInventoryManager();
InventoryManager manager = _arcadeManager.getInventoryManager();
double rand = UtilMath.random.nextDouble();
if (rand < CHEST_CHANCE)
{
@ -384,7 +553,7 @@ public class HolidayManager implements Listener
.withFade(Color.BLACK).flicker(true).build();
manager.addItemToInventory(player, "Haunted Chest", 1);
HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation()
.add(.5, .5, .5), fireworkEffect, Manager.getPlugin());
.add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin());
halloweenSmashedEffect.start();
}
else
@ -394,14 +563,73 @@ public class HolidayManager implements Listener
.withFade(Color.BLACK).flicker(true).build();
manager.addItemToInventory(player, "Omega Chest", 1);
HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation()
.add(.5, .5, .5), fireworkEffect, Manager.getPlugin());
.add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin());
halloweenSmashedEffect.start();
}
}
}
//Effect
block.getWorld().playSound(block.getLocation(), type.getBlockSound(), 1f, 1f);
block.getWorld().playSound(block.getLocation(), _type.getBlockSound(), 1f, 1f);
}
private void specialEntityKill(Player player, org.bukkit.entity.Entity entity)
{
if (player != null && _arcadeManager.GetGame() != null)
{
_arcadeManager.GetGame().AddStat(player, _statName, 1, false, true);
System.out.println("Recording Entity Killong for " + player.getName());
}
//Coins
for (int i=0 ; i < 4 + Math.random()*8 ; i++)
{
Item coin = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5),
ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte)0, 1, UtilMath.r(999999) + "Coin"));
Vector vel = new Vector(
(Math.random() - 0.5) * 0.5,
0.1 + Math.random() * 0.3,
(Math.random() - 0.5) * 0.5);
coin.setVelocity(vel);
coin.setPickupDelay(20);
_coins.add(coin);
}
//Gems
for (int i=0 ; i < 4 + Math.random()*8 ; i++)
{
Item gem = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5),
ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte)0, 1, UtilMath.r(999999) + "Gem"));
Vector vel = new Vector(
(Math.random() - 0.5) * 0.5,
0.1 + Math.random() * 0.3,
(Math.random() - 0.5) * 0.5);
gem.setVelocity(vel);
gem.setPickupDelay(20);
_gems.add(gem);
}
// Fated Giveaway
if (player != null)
{
_fatedManager.openPumpkin(player, new Runnable()
{
@Override
public void run()
{
Location location = entity.getLocation().add(0.5, 0.5, 0.5);
new FatedGiveawayAnimation(_fatedManager, location, 3000L);
}
});
}
}
@EventHandler
@ -415,7 +643,7 @@ public class HolidayManager implements Listener
event.setCancelled(true);
event.getItem().remove();
Manager.GetDonation().RewardCoinsLater(type + " Coins", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount());
_arcadeManager.GetDonation().RewardCoinsLater(_type + " Coins", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount());
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
}
@ -424,12 +652,12 @@ public class HolidayManager implements Listener
event.setCancelled(true);
event.getItem().remove();
Manager.GetDonation().RewardGemsLater(type + " Gems", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount());
_arcadeManager.GetDonation().RewardGemsLater(_type + " Gems", event.getPlayer(), 4 * event.getItem().getItemStack().getAmount());
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
}
else if (_eggs.contains(event.getItem()))
else if (_items.contains(event.getItem()))
{
event.setCancelled(true);
}
@ -467,7 +695,7 @@ public class HolidayManager implements Listener
}
}
Iterator<Item> eggIterator = _eggs.iterator();
Iterator<Item> eggIterator = _items.iterator();
while (eggIterator.hasNext())
{

View File

@ -0,0 +1,42 @@
package nautilus.game.arcade.managers.events;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class SpecialEntityDeathEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Entity _entity;
private Player _killer;
public SpecialEntityDeathEvent(Entity entity, Player killer)
{
_entity = entity;
_killer = killer;
}
public Entity getEntity()
{
return _entity;
}
public Player getKiller()
{
return _killer;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}