Merge branch 'develop' of github.com:Mineplex-LLC/Minecraft-PC into ben/champions-gi-balancing

This commit is contained in:
AlexTheCoder 2016-07-11 14:46:08 -04:00
commit 30287a0832
100 changed files with 2606 additions and 1511 deletions

View File

@ -8,51 +8,51 @@ import org.bukkit.inventory.ItemStack;
public enum CountryFlag
{
Brazil(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)),
Usa(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)),
Canada(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
BRAZIL(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)),
USA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.BLUE, PatternType.SQUARE_TOP_RIGHT)),
CANADA(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
Uk(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT),
UK(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNLEFT), new Pattern(DyeColor.WHITE, PatternType.STRIPE_DOWNRIGHT),
new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.CROSS)),
Ireland(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)),
Spain(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.RED, PatternType.STRIPE_RIGHT)),
Japan(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
South_Sudan(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_RIGHT),
IRELAND(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.STRIPE_TOP), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_BOTTOM)),
SPAIN(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.RED, PatternType.STRIPE_RIGHT)),
JAPAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
SOUTH_SUDAN(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_RIGHT),
new Pattern(DyeColor.GREEN, PatternType.TRIANGLE_BOTTOM)),
Jamaica(DyeColor.GREEN, new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_TOP), new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_BOTTOM),
JAMAICA(DyeColor.GREEN, new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_TOP), new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_BOTTOM),
new Pattern(DyeColor.YELLOW, PatternType.CROSS)),
Italy(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM)),
Senegal(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM),
ITALY(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM)),
SENEGAL(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM),
new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)),
France(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM)),
India(DyeColor.WHITE, new Pattern(DyeColor.ORANGE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.GREEN, PatternType.STRIPE_RIGHT),
FRANCE(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM)),
INDIA(DyeColor.WHITE, new Pattern(DyeColor.ORANGE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.GREEN, PatternType.STRIPE_RIGHT),
new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)),
Belgium(DyeColor.YELLOW, new Pattern(DyeColor.BLACK, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
England(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS)),
Austria(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)),
Armenia(DyeColor.RED, new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_RIGHT)),
Argentina(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
Greece(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.LIGHT_BLUE, PatternType.SQUARE_BOTTOM_LEFT)),
Czech_Republic(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.BLUE, PatternType.TRIANGLE_BOTTOM)),
Romania(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
Honduras(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT)),
Algeria(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR), new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
Portugal(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.STRIPE_TOP), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
Bahrain(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.TRIANGLES_BOTTOM)),
Germany(DyeColor.RED, new Pattern(DyeColor.BLACK, PatternType.STRIPE_LEFT), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_RIGHT)),
Gabon(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT), new Pattern(DyeColor.LIME, PatternType.STRIPE_LEFT)),
Scotland(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.CROSS)),
Peru(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM)),
Tanzania(DyeColor.LIME, new Pattern(DyeColor.LIGHT_BLUE, PatternType.DIAGONAL_RIGHT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_DOWNLEFT)),
Morocco(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)),
Solomon_Islands(DyeColor.GREEN, new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_LEFT_MIRROR), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_DOWNRIGHT)),
Switzerland(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
BELGIUM(DyeColor.YELLOW, new Pattern(DyeColor.BLACK, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
ENGLAND(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS)),
AUSTRIA(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)),
ARMENIA(DyeColor.RED, new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.ORANGE, PatternType.STRIPE_RIGHT)),
ARGENTINA(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
GREECE(DyeColor.LIGHT_BLUE, new Pattern(DyeColor.WHITE, PatternType.STRIPE_SMALL), new Pattern(DyeColor.LIGHT_BLUE, PatternType.SQUARE_BOTTOM_LEFT)),
CZECH_REPUBLIC(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.BLUE, PatternType.TRIANGLE_BOTTOM)),
ROMANIA(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
HONDURAS(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT)),
ALGERIA(DyeColor.WHITE, new Pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR), new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)),
PORTUGAL(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.STRIPE_TOP), new Pattern(DyeColor.YELLOW, PatternType.CIRCLE_MIDDLE)),
BAHRAIN(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.TRIANGLES_BOTTOM)),
GERMANY(DyeColor.RED, new Pattern(DyeColor.BLACK, PatternType.STRIPE_LEFT), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_RIGHT)),
GABON(DyeColor.YELLOW, new Pattern(DyeColor.BLUE, PatternType.STRIPE_RIGHT), new Pattern(DyeColor.LIME, PatternType.STRIPE_LEFT)),
SCOTLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.CROSS)),
PERU(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM)),
TANZANIA(DyeColor.LIME, new Pattern(DyeColor.LIGHT_BLUE, PatternType.DIAGONAL_RIGHT), new Pattern(DyeColor.BLACK, PatternType.STRIPE_DOWNLEFT)),
MOROCCO(DyeColor.RED, new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)),
SOLOMON_ISLANDS(DyeColor.GREEN, new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_LEFT_MIRROR), new Pattern(DyeColor.YELLOW, PatternType.STRIPE_DOWNRIGHT)),
SWITZERLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)),
Finland(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_LEFT), new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_RIGHT),
FINLAND(DyeColor.BLUE, new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_LEFT), new Pattern(DyeColor.WHITE, PatternType.SQUARE_BOTTOM_RIGHT),
new Pattern(DyeColor.WHITE, PatternType.HALF_HORIZONTAL), new Pattern(DyeColor.BLUE, PatternType.STRIPE_CENTER)),
South_Africa(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL),
SOUTH_AFRICA(DyeColor.WHITE, new Pattern(DyeColor.BLUE, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.RED, PatternType.HALF_VERTICAL),
new Pattern(DyeColor.GREEN, PatternType.STRIPE_CENTER), new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_BOTTOM)),
Poland(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR));
POLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR));
private DyeColor _baseColor;
private Pattern[] _patterns;

View File

@ -35,7 +35,7 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
synchronized (_clientDataLock)
{
if (!_clientData.containsKey(name))
_clientData.put(name, AddPlayer(name));
_clientData.put(name, addPlayer(name));
return _clientData.get(name);
}
@ -66,5 +66,5 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
}
}
protected abstract DataType AddPlayer(String player);
protected abstract DataType addPlayer(String player);
}

View File

@ -67,7 +67,7 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
}
@Override
protected BenefitData AddPlayer(String player)
protected BenefitData addPlayer(String player)
{
return new BenefitData();
}

View File

@ -989,7 +989,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
@Override
protected BonusClientData AddPlayer(String player)
protected BonusClientData addPlayer(String player)
{
return new BonusClientData();
}

View File

@ -71,7 +71,7 @@ public class YoutubeButton implements GuiItem
message = "Click here to visit our YouTube page!";
}
new JsonMessage(C.cAquaB + message).click(ClickEvent.OPEN_URL, "https://www.youtube.com/mineplexgamesofficial").sendToPlayer(_player);
new JsonMessage(C.cAquaB + message).click(ClickEvent.OPEN_URL, "http://youtube.com/mineplexgamesofficial?sub_confirmation=1").sendToPlayer(_player);
}
@Override

View File

@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.boosters.command.BoosterCommand;
import mineplex.core.boosters.event.BoosterActivateEvent;
import mineplex.core.boosters.event.BoosterExpireEvent;
import mineplex.core.boosters.event.BoosterItemGiveEvent;
import mineplex.core.boosters.event.BoosterUpdateEvent;
import mineplex.core.boosters.gui.BoosterShop;
import mineplex.core.boosters.redis.BoosterUpdateRepository;
@ -14,6 +15,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
@ -361,6 +363,11 @@ public class BoosterManager extends MiniPlugin
{
if (_giveInterfaceItem && !UtilGear.isMat(player.getInventory().getItem(INTERFACE_SLOT), Material.EMERALD))
{
BoosterItemGiveEvent event = new BoosterItemGiveEvent(player);
UtilServer.CallEvent(event);
if (event.isCancelled())
return;
player.getInventory().setItem(INTERFACE_SLOT, INTERFACE_ITEM);
UtilInv.Update(player);

View File

@ -0,0 +1,48 @@
package mineplex.core.boosters.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when a player is about to receive a booster gem. If cancelled the player will not receive said gem
*/
public class BoosterItemGiveEvent extends Event implements Cancellable
{
private Player _player;
private boolean _cancelled;
public BoosterItemGiveEvent(Player player)
{
this._player = player;
}
public Player getPlayer()
{
return this._player;
}
public boolean isCancelled()
{
return this._cancelled;
}
public void setCancelled(boolean cancelled)
{
this._cancelled = cancelled;
}
private static final HandlerList _handlers = new HandlerList();
private static HandlerList getHandlerList()
{
return _handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
}

View File

@ -110,7 +110,7 @@ public class BoosterTipManager extends MiniDbClientPlugin<PlayerTipData>
}
@Override
protected PlayerTipData AddPlayer(String player)
protected PlayerTipData addPlayer(String player)
{
return new PlayerTipData();
}

View File

@ -51,7 +51,7 @@ public class FountainManager extends MiniPlugin
World world = Bukkit.getWorlds().get(0);//-43.5, 66, -38.5
int goal = !new File("eu.dat").exists() ? 300000000 : 5000000;
int goal = !new File("eu.dat").exists() ? 200000000 : 20000000;
_gemFountain = new Fountain(new Location(world, -32.5, 72, -23.5), new Location(world, -43.5, 67, -38.5),
C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager);
}

View File

@ -180,7 +180,7 @@ public class CosmeticManager extends MiniPlugin
{
_gadgetManager.disableAll();
_mountManager.DisableAll();
_petManager.DisableAll();
_petManager.disableAll();
}
public void setHideParticles(boolean b)

View File

@ -8,7 +8,7 @@ public class PetSorter implements Comparator<Pet>
{
public int compare(Pet a, Pet b)
{
if (a.GetPetType().getTypeId() < b.GetPetType().getTypeId())
if (a.getPetType().getTypeId() < b.getPetType().getTypeId())
return -1;
return 1;

View File

@ -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.getPetType(), player.getLocation());
_page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));
}
}

View File

@ -21,7 +21,7 @@ public class DeactivatePetButton implements IButton
public void onClick(Player player, ClickType clickType)
{
_page.playAcceptSound(player);
_petManager.RemovePet(player, true);
_petManager.removePet(player, true);
_page.refresh();
}
}

View File

@ -24,7 +24,7 @@ public class OpenPets implements IButton
else
{
_menu.playAcceptSound(player);
_menu.getPlugin().getPetManager().RemovePet(player, true);
_menu.getPlugin().getPetManager().removePet(player, true);
_menu.refresh();
}
}

View File

@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.banner.CountryFlag;
import mineplex.core.gadget.event.GadgetChangeEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -291,7 +293,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8)
{
gadgetItemStack = CountryFlag.Usa.getBanner();
gadgetItemStack = CountryFlag.USA.getBanner();
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName());
bannerMeta.setLore(meta.getLore());
@ -314,7 +316,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
if (gadget.getCost(CurrencyType.TREASURE_SHARD) == -8)
{
gadgetItemStack = CountryFlag.Usa.getBanner();
gadgetItemStack = CountryFlag.USA.getBanner();
BannerMeta bannerMeta = (BannerMeta) gadgetItemStack.getItemMeta();
bannerMeta.setDisplayName(C.cGreen + C.Bold + gadget.getName());
bannerMeta.setLore(meta.getLore());
@ -393,6 +395,9 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
playAcceptSound(player);
gadget.enable(player);
GadgetChangeEvent gadgetChangeEvent = new GadgetChangeEvent(player, gadget,
GadgetChangeEvent.GadgetState.ENABLED);
UtilServer.getPluginManager().callEvent(gadgetChangeEvent);
refresh();
}
@ -409,6 +414,9 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
playAcceptSound(player);
gadget.disable(player);
GadgetChangeEvent gadgetChangeEvent = new GadgetChangeEvent(player, gadget,
GadgetChangeEvent.GadgetState.DISABLED);
UtilServer.getPluginManager().callEvent(gadgetChangeEvent);
refresh();
}
}

View File

@ -100,7 +100,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer());
for (Mount<?> mount : getPlugin().getMountManager().getMounts())
{
if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.getName()) || mount.hasMount(getPlayer()))
if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(mount.getName()))
{
mountOwned++;
}
@ -110,17 +110,17 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
int petOwned = 0;
int petMax = 0;
for (Pet pet : getPlugin().getPetManager().GetFactory().GetPets())
for (Pet pet : getPlugin().getPetManager().getFactory().GetPets())
{
NautHashMap<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).GetPets();
if (pets != null && pets.containsKey(pet.GetPetType()))
NautHashMap<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
if (pets != null && pets.containsKey(pet.getPetType()))
{
petOwned++;
}
petMax++;
}
Creature petActive = getPlugin().getPetManager().GetPet(getPlayer());
Creature petActive = getPlugin().getPetManager().getPet(getPlayer());
GadgetType type = GadgetType.PARTICLE;
String[] lore = getLore(ownedCount.get(type), maxCount.get(type), "Show everyone how cool you are with swirly particles that follow you when you walk!", "Visible Everywhere", enabled.get(type));

View File

@ -49,7 +49,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
int slot = 19;
List<Pet> pets = new ArrayList<Pet>(getPlugin().getPetManager().GetFactory().GetPets());
List<Pet> pets = new ArrayList<Pet>(getPlugin().getPetManager().getFactory().GetPets());
Collections.sort(pets, new PetSorter());
@ -61,7 +61,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
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.getPetType()))
{
if (pet.getCost(CurrencyType.TREASURE_SHARD) == -1)
{
@ -113,21 +113,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.getPetType()))
{
String petName = getPlugin().getPetManager().Get(getPlayer()).GetPets().get(pet.GetPetType());
String petName = getPlugin().getPetManager().Get(getPlayer()).getPets().get(pet.getPetType());
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().getActivePet(getPlayer().getName()).getType() == pet.getPetType())
{
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.getPetType().getTypeId(),
pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager()));
addGlow(slot);
@ -137,8 +137,8 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Enable");
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.getPetType().getTypeId(),
pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this));
}
}
@ -156,18 +156,18 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
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.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false), new PetButton(pet, this));
}
else if (pet.getCost(CurrencyType.TREASURE_SHARD) > 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.getPetName(), 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.getPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
}
@ -178,7 +178,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
}
slot = 49;
for (PetExtra petExtra : getPlugin().getPetManager().GetFactory().GetPetExtras())
for (PetExtra petExtra : getPlugin().getPetManager().getFactory().GetPetExtras())
{
List<String> itemLore = new ArrayList<String>();
@ -233,7 +233,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
public void deactivatePet(Player player)
{
playAcceptSound(player);
getPlugin().getPetManager().RemovePet(player, true);
getPlugin().getPetManager().removePet(player, true);
refresh();
}
}

View File

@ -108,8 +108,8 @@ 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 = _pet.getPetType().toString();
token.PetId = _pet.getPetType().ordinal();
token.PetName = _tagName;
PetToken petToken = new PetToken();
@ -117,16 +117,16 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (_petPurchase)
{
getPlugin().getPetManager().GetRepository().AddPet(token);
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.GetPetType());
getPlugin().getPetManager().getRepository().AddPet(token);
getPlugin().getPetManager().addPetOwnerToQueue(getPlayer().getName(), _pet.getPetType());
}
else
{
getPlugin().getPetManager().GetRepository().UpdatePet(token);
getPlugin().getPetManager().getRepository().UpdatePet(token);
getPlugin().getPetManager().addRenamePetToQueue(getPlayer().getName(), token.PetName);
}
getPlugin().getPetManager().Get(getPlayer()).GetPets().put(_pet.GetPetType(), token.PetName);
getPlugin().getPetManager().Get(getPlayer()).getPets().put(_pet.getPetType(), token.PetName);
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), getPlayer()));
}

View File

@ -43,7 +43,7 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
}
@Override
protected PlayerCustomData AddPlayer(String player)
protected PlayerCustomData addPlayer(String player)
{
return new PlayerCustomData(_repository);
}

View File

@ -58,7 +58,7 @@ public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
}
@Override
protected DelayedTaskClient AddPlayer(String player)
protected DelayedTaskClient addPlayer(String player)
{
return new DelayedTaskClient(Bukkit.getPlayer(player));
}

View File

@ -518,7 +518,7 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
}
@Override
protected Donor AddPlayer(String player)
protected Donor addPlayer(String player)
{
return new Donor();
}

View File

@ -114,7 +114,7 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
}
@Override
protected EloClientData AddPlayer(String player)
protected EloClientData addPlayer(String player)
{
return new EloClientData();
}

View File

@ -137,7 +137,7 @@ public class Energy extends MiniClientPlugin<ClientEnergy>
}
@Override
protected ClientEnergy AddPlayer(String player)
protected ClientEnergy addPlayer(String player)
{
return new ClientEnergy();
}

View File

@ -106,7 +106,7 @@ public class FacebookManager extends MiniDbClientPlugin<FacebookClient>
}
@Override
protected FacebookClient AddPlayer(String player)
protected FacebookClient addPlayer(String player)
{
return new FacebookClient(false);
}

View File

@ -70,7 +70,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
}
@Override
protected FriendData AddPlayer(String player)
protected FriendData addPlayer(String player)
{
return new FriendData();
}

View File

@ -4,6 +4,7 @@ import java.util.*;
import java.util.function.Predicate;
import mineplex.core.gadget.commands.LockCosmeticsCommand;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom;
@ -660,10 +661,14 @@ public class GadgetManager extends MiniPlugin
}
}
public void disableAll(Player player, boolean callEvent)
public void disableAll(Player player, boolean winRooms)
{
for (GadgetType gadgetType : _gadgets.keySet())
{
if (gadgetType == GadgetType.WIN_EFFECT && winRooms)
{
continue;
}
for (Gadget gadget : _gadgets.get(gadgetType))
{
gadget.disable(player);
@ -776,7 +781,9 @@ public class GadgetManager extends MiniPlugin
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
saveGadgets(event.getPlayer());
//saveGadgets(event.getPlayer());
event.getPlayer().setWalkSpeed(0.2f);
event.getPlayer().setFlySpeed(0.1f);
disableAll(event.getPlayer(), false);
_lastMove.remove(event.getPlayer());
_playerActiveGadgetMap.remove(event.getPlayer());
@ -914,89 +921,57 @@ public class GadgetManager extends MiniPlugin
event.setCancelled(true);
}
private void saveGadgets(Player player)
@EventHandler
private void saveGadget(GadgetChangeEvent event)
{
if (player.getGameMode() == GameMode.SPECTATOR)
return;
Map<String, String> cache = new HashMap<>();
for (Gadget gadget : getAllGadgets())
Gadget gadget = event.getGadget();
if (gadget != null)
{
String value = "disabled", key = "";
GadgetType gadgetType = gadget.getGadgetType();
if (gadget.ownsGadget(player))
{
switch (gadgetType)
{
case MUSIC_DISC:
case ITEM:
case MORPH:
case BALLOON:
break;
return;
case COSTUME:
OutfitGadget outfitGadget = (OutfitGadget) gadget;
String key = "activeCostume" + outfitGadget.getSlot().getDatabaseKey();
if (cache.containsKey(key))
continue;
if (outfitGadget.isActive(player))
cache.put(key, outfitGadget.getName());
key = "activeCostume" + outfitGadget.getSlot().getDatabaseKey();
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
{
value = outfitGadget.getName();
}
break;
case GAME_MODIFIER:
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
if (gameModifierGadget.canAllowMultiple())
{
if (cache.containsKey(gadget.getName()))
continue;
cache.put(gadget.getName(), (gadget.isActive(player)) ? "enabled" : "disabled");
} else
key = gameModifierGadget.getName();
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
{
String dataKey = "activeModifier" + gameModifierGadget.getGameType().getName().replace(" ", "");
if (cache.containsKey(dataKey))
continue;
if (gadget.isActive(player))
cache.put(dataKey, gadget.getName());
}
break;
default:
if (cache.containsKey(gadgetType.getDatabaseKey()))
continue;
if (gadget.isActive(player))
cache.put(gadgetType.getDatabaseKey(), gadget.getName());
break;
}
}
}
cache = updateDefaultGadgets(cache);
_userGadgetPersistence.save(player, cache);
}
private Map<String, String> updateDefaultGadgets(Map<String, String> cache)
{
for (GadgetType gadgetType : GadgetType.values())
{
if (gadgetType == GadgetType.MUSIC_DISC || gadgetType == GadgetType.ITEM
|| gadgetType == GadgetType.MORPH || gadgetType == GadgetType.BALLOON
|| gadgetType == GadgetType.GAME_MODIFIER)
continue;
if (!cache.containsKey(gadgetType.getDatabaseKey()))
{
String key = gadgetType.getDatabaseKey();
if (gadgetType.equals(GadgetType.COSTUME))
{
for (ArmorSlot armorSlot : ArmorSlot.values())
{
key = "activeCostume" + armorSlot.getDatabaseKey();
if (!cache.containsKey(key))
{
cache.put(key, "disabled");
}
value = "enabled";
}
}
else
{
cache.put(key, "disabled");
key = "activeModifier" + gameModifierGadget.getGameType().getName().replace(" ", "");
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
{
value = gameModifierGadget.getName();
}
}
break;
default:
key = gadgetType.getDatabaseKey();
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
{
value = gadget.getName();
}
}
_userGadgetPersistence.save(event.getPlayer(), key, value);
}
return cache;
}
public boolean isKitModifierActive(KitModifier kitModifier, Player player)

View File

@ -2,12 +2,17 @@ package mineplex.core.gadget.commands;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.ClientItem;
import mineplex.core.inventory.data.Item;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -28,7 +33,7 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
// Removes all cosmetic types
if (args.length == 0)
{
addCosmetics(null, caller);
lockCosmetics(null, caller);
}
// Removes specific type
else
@ -36,7 +41,15 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
String type = args[0];
if (type.equalsIgnoreCase("all"))
{
addCosmetics(null, caller);
lockCosmetics(null, caller);
}
else if (type.equalsIgnoreCase("pet"))
{
lockPets(caller);
}
else if (type.equalsIgnoreCase("mount"))
{
lockMounts(caller);
}
else
{
@ -47,27 +60,74 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
}
else
{
addCosmetics(gadgetType, caller);
lockCosmetics(gadgetType, caller);
}
}
}
}
private void addCosmetics(GadgetType gadgetType, Player caller)
private void lockCosmetics(GadgetType gadgetType, Player caller)
{
if (gadgetType == null)
{
for (GadgetType type : GadgetType.values())
{
addCosmetics(type, caller);
lockCosmetics(type, caller);
}
lockMounts(caller);
lockPets(caller);
return;
}
int removed = 0;
for (Gadget gadget : _plugin.getGadgets(gadgetType))
{
_plugin.getDonationManager().Get(caller.getName()).RemoveUnknownSalesPackagesOwned(gadget.getName());
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name() + " cosmetics!"));
if (gadget.getGadgetType() == GadgetType.ITEM)
continue;
if (gadget.ownsGadget(caller))
{
Item clientItem = _plugin.getInventoryManager().getItem(gadget.getName());
if (clientItem == null)
continue;
_plugin.getInventoryManager().Get(caller.getName()).removeItem(new ClientItem(clientItem, 1));
removed++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name().toLowerCase()
.replace("_", " ") + "! (Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("item", removed) + ")"));
}
private void lockMounts(Player caller)
{
int removed = 0;
for (Mount<?> mount : _plugin.getMountManager().getMounts())
{
if (mount.hasMount(caller))
{
Item clientItem = _plugin.getInventoryManager().getItem(mount.getName());
if (clientItem == null)
continue;
_plugin.getInventoryManager().Get(caller.getName()).removeItem(new ClientItem(clientItem, 1));
removed++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("mount", removed) + "!"));
}
private void lockPets(Player caller)
{
int removed = 0;
for (Pet pet : _plugin.getPetManager().getFactory().GetPets())
{
if (_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType()))
{
_plugin.getPetManager().Get(caller).getPets().remove(pet.getPetType());
removed++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("pet", removed) + "!"));
}
}

View File

@ -2,15 +2,15 @@ package mineplex.core.gadget.commands;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
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.mount.MountManager;
import mineplex.core.pet.Pet;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
@ -40,6 +40,14 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
{
addCosmetics(null, caller);
}
else if (type.equalsIgnoreCase("pet"))
{
addPets(caller);
}
else if (type.equalsIgnoreCase("mount"))
{
addMounts(caller);
}
else
{
GadgetType gadgetType = GadgetType.valueOf(type);
@ -64,12 +72,54 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
{
addCosmetics(type, caller);
}
addMounts(caller);
addPets(caller);
return;
}
int added = 0;
int amount = 1;
for (Gadget gadget : _plugin.getGadgets(gadgetType))
{
_plugin.getDonationManager().Get(caller.getName()).AddUnknownSalesPackagesOwned(gadget.getName());
}
UtilPlayer.message(caller, F.main("Cosmetics", "Added all the " + gadgetType.name() + " cosmetics!"));
if (gadgetType == GadgetType.ITEM)
amount = 20;
if (!gadget.ownsGadget(caller))
{
_plugin.getInventoryManager().addItemToInventory(caller, gadget.getName(), amount);
added++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Added all the " + gadgetType.name().toLowerCase()
.replace("_", " ") + "! (Added " + C.cRed + added + C.cGray + " " +
UtilText.plural("item", added) + ")"));
}
private void addMounts(Player caller)
{
int added = 0;
for (Mount<?> mount : _plugin.getMountManager().getMounts())
{
if (!mount.hasMount(caller))
{
_plugin.getInventoryManager().addItemToInventory(caller, mount.getName(), 1);
added++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " +
UtilText.plural("mount", added) + "!"));
}
private void addPets(Player caller)
{
int added = 0;
for (Pet pet : _plugin.getPetManager().getFactory().GetPets())
{
if (!_plugin.getPetManager().Get(caller).getPets().containsKey(pet.getPetType()))
{
_plugin.getPetManager().Get(caller).getPets().put(pet.getPetType(), pet.getName());
added++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " +
UtilText.plural("pet", added) + "!"));
}
}

View File

@ -0,0 +1,60 @@
package mineplex.core.gadget.event;
import mineplex.core.gadget.types.Gadget;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when a player enables or disables a gadget manually,
* allowing it to be saved when the player changes a gadget, instead of
* when they quit or join a server
*/
public class GadgetChangeEvent extends Event
{
public enum GadgetState
{
ENABLED,
DISABLED
}
private static final HandlerList handlers = new HandlerList();
private final Player _player;
private final Gadget _gadget;
private final GadgetState _gadgetState;
public GadgetChangeEvent(Player player, Gadget gadget, GadgetState gadgetState)
{
_player = player;
_gadget = gadget;
_gadgetState = gadgetState;
}
public Player getPlayer()
{
return _player;
}
public Gadget getGadget()
{
return _gadget;
}
public GadgetState getGadgetState()
{
return _gadgetState;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,84 @@
package mineplex.core.gadget.event;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.gadget.types.Gadget;
/**
* This event is called when a gadget selects a location for a specific effect to be shown.
*/
public class GadgetSelectLocationEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private Gadget _gadget;
private Location _location;
private boolean _showMessage = true;
private boolean _cancelled = false;
public GadgetSelectLocationEvent(Player player, Gadget gadget, Location location)
{
_player = player;
_gadget = gadget;
_location = location;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Gadget getGadget()
{
return _gadget;
}
public Player getPlayer()
{
return _player;
}
public Location getLocation()
{
return _location;
}
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
public boolean isCancelled()
{
return _cancelled;
}
/**
* Whether or not a cancellation message should be displayed.
*
* @param showMessage True for the message to be shown and false for the message to be hidden/ignored.
*/
public void setShowMessage(boolean showMessage)
{
_showMessage = showMessage;
}
/**
* Returns whether or not a cancellation message can be shown.
*
* @return True if the message can be shown and false if the message should be hidden/ignored.
*/
public boolean canShowMessage()
{
return _showMessage;
}
}

View File

@ -117,7 +117,7 @@ public class ItemCoal extends ItemGadget
}
//Coal Apparition
if (!Manager.getPetManager().Get(player).GetPets().containsKey(EntityType.PIG_ZOMBIE))
if (!Manager.getPetManager().Get(player).getPets().containsKey(EntityType.PIG_ZOMBIE))
{
goal = _pet;

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -17,6 +18,7 @@ import org.bukkit.util.Vector;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
@ -32,6 +34,7 @@ import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent;
@ -105,6 +108,19 @@ public class MorphTitan extends MorphGadget
Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, loc);
Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent);
if (gadgetSelectLocationEvent.isCancelled())
{
if (gadgetSelectLocationEvent.canShowMessage())
{
UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!"));
}
return;
}
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
stand.setVisible(false);

View File

@ -146,7 +146,7 @@ public class WinEffectLavaTrap extends WinEffectGadget
Location loc = getBaseLocation().add(UtilAlg.getRight(dir).multiply(5)).add(0, 2, 0).subtract(dir);
loc.setDirection(getBaseLocation().subtract(loc).toVector());
teleport(loc);
super.teleport(loc);
}
}

View File

@ -2,11 +2,11 @@ package mineplex.core.gadget.types;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
import mineplex.core.common.util.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.*;
import org.bukkit.Color;
import org.bukkit.block.BlockFace;
@ -14,7 +14,10 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -26,6 +29,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.spigotmc.event.entity.EntityDismountEvent;
/**
* A wrapper for different win effects
@ -51,8 +55,8 @@ public abstract class WinEffectGadget extends Gadget
protected List<Player> _nonTeam;
/** All players on the team that didn't win + spectators which were not in the game at all. */
protected List<Player> _other;
/** All locked players */
protected List<Player> _locked;
/** All the players that were teleported to the winroom */
protected List<Player> _allPlayers;
/**
* @param manager The normal GadgetManager
@ -91,54 +95,9 @@ public abstract class WinEffectGadget extends Gadget
play();
}
/**
* Lock the player. Disabling any jump or walk movement
* @param p The player to lock in place
*/
public void lockPlayer(Player p)
{
_locked.add(p);
p.setWalkSpeed(0);
p.setFlySpeed(0);
}
/**
* Unlock the player, allowing the player to walk and jump as normal again.
* @param p The player to unlock
*/
public void unlockPlayer(Player p)
{
if (_locked.contains(p))
_locked.remove(p);
p.setWalkSpeed(0.2f);
p.setFlySpeed(0.1f);
}
@EventHandler
public void onMove(PlayerMoveEvent event)
{
for(PotionEffect p : event.getPlayer().getActivePotionEffects())
{
if(p.getType().equals(PotionEffectType.JUMP))
{
if(p.getAmplifier() == 250)
{
if(event.getTo().clone().subtract(event.getFrom()).lengthSquared() > 0)
{
Location loc = event.getPlayer().getLocation().getBlock().getLocation().add(0.5, 0, 0.5);
loc.setDirection(event.getTo().getDirection());
event.setTo(loc);
}
return;
}
}
}
}
public void runFinish()
{
finish();
UtilServer.getPlayersCollection().forEach(p -> {unlockPlayer(p); UtilPlayer.showForAll(p); });
_player = null;
_baseLocation = null;
_team.clear();
@ -147,8 +106,8 @@ public abstract class WinEffectGadget extends Gadget
_nonTeam = null;
_other.clear();
_other = null;
_locked.clear();
_locked = null;
_allPlayers.clear();
_allPlayers = null;
// Loads gadgets back when players are teleported to the arcade hub, after the win effect
for (Player player : UtilServer.getPlayers())
{
@ -221,7 +180,8 @@ public abstract class WinEffectGadget extends Gadget
_other.remove(player);
_other.removeAll(team);
_locked = new ArrayList<>();
_allPlayers = new ArrayList<>();
_allPlayers.addAll(UtilServer.getPlayersCollection());
this._start = System.currentTimeMillis();
this._baseLocation = loc.clone();
@ -245,32 +205,64 @@ public abstract class WinEffectGadget extends Gadget
*/
public void teleport(Location loc)
{
loc.getBlock().setType(Material.AIR);
loc.getBlock().getRelative(BlockFace.UP).setType(Material.AIR);
loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.EAST).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.WEST).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.NORTH).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.clone().add(0, 2, 0).getBlock().setType(Material.BARRIER);
createBarriers(loc);
BukkitRunnable bRunnable = new BukkitRunnable() {
@Override
public void run() {
for(Player p : UtilServer.getPlayers()) {
lockPlayer(p);
UtilPlayer.hideFromAll(p);
p.teleport(loc);
p.setGameMode(GameMode.ADVENTURE);
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 10 * 20, 1, false, false));
p.getInventory().clear();
p.teleport(loc.clone().add(.5, 0, .5));
p.setAllowFlight(false);
Manager.disableAll(p, false);
p.setHealth(p.getMaxHealth());
p.setFoodLevel(20);
Manager.disableAll(p, true);
}
}
};
bRunnable.runTaskLater(UtilServer.getPlugin(), 10l);
}
/**
* Updates players inventory
* @param event
*/
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!isRunning())
return;
for (Player player : _allPlayers)
{
player.getInventory().clear();
}
}
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event)
{
if (isRunning())
{
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDamage(EntityDamageEvent event)
{
if (isRunning())
{
event.setCancelled(true);
}
}
/**
* Build the win room, by default this will paste the scheamtic. Do any major setup here. This is called before the players are
* teleported.
@ -357,4 +349,69 @@ public abstract class WinEffectGadget extends Gadget
}
}
private void createBarriers(Location baseLocation)
{
// FLOOR
Location floorBase = baseLocation.clone().subtract(0, 1, 0);
setBarrierBlock(floorBase);
setBarrierBlock(floorBase.clone().add(1, 0, 0));
setBarrierBlock(floorBase.clone().add(0, 0, 1));
setBarrierBlock(floorBase.clone().subtract(1, 0, 0));
setBarrierBlock(floorBase.clone().subtract(0, 0, 1));
setBarrierBlock(floorBase.clone().add(1, 0, 1));
setBarrierBlock(floorBase.clone().add(1, 0, -1));
setBarrierBlock(floorBase.clone().add(-1, 0, 1));
setBarrierBlock(floorBase.clone().subtract(1, 0, 1));
// WALLS
floorBase.add(0, 2, 0);
setBarrierBlock(floorBase.clone().add(2, 0, 0));
setBarrierBlock(floorBase.clone().add(2, 0, 1));
setBarrierBlock(floorBase.clone().add(2, 0, -1));
setBarrierBlock(floorBase.clone().subtract(2, 0, 0));
setBarrierBlock(floorBase.clone().subtract(2, 0, 1));
setBarrierBlock(floorBase.clone().subtract(2, 0, -1));
setBarrierBlock(floorBase.clone().add(0, 0, 2));
setBarrierBlock(floorBase.clone().add(1, 0, 2));
setBarrierBlock(floorBase.clone().add(-1, 0, 2));
setBarrierBlock(floorBase.clone().subtract(0, 0, 2));
setBarrierBlock(floorBase.clone().subtract(1, 0, 2));
setBarrierBlock(floorBase.clone().subtract(-1, 0, 2));
// CEILING
floorBase.add(0, 2, 0);
setBarrierBlock(floorBase);
setBarrierBlock(floorBase.clone().add(1, 0, 0));
setBarrierBlock(floorBase.clone().add(0, 0, 1));
setBarrierBlock(floorBase.clone().subtract(1, 0, 0));
setBarrierBlock(floorBase.clone().subtract(0, 0, 1));
setBarrierBlock(floorBase.clone().add(1, 0, 1));
setBarrierBlock(floorBase.clone().add(1, 0, -1));
setBarrierBlock(floorBase.clone().add(-1, 0, 1));
setBarrierBlock(floorBase.clone().subtract(1, 0, 1));
// CHANGES MIDDLE TO AIR
floorBase.subtract(1, 3, 1);
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 3; y++)
{
for (int z = 0; z < 3; z++)
{
floorBase.clone().add(x, y, z).getBlock().setType(Material.AIR);
}
}
}
}
private void setBarrierBlock(Location blockLocation)
{
if (blockLocation.getBlock().getType() == Material.AIR)
blockLocation.getBlock().setType(Material.BARRIER);
}
}

View File

@ -173,7 +173,7 @@ public class GiveawayManager extends MiniDbClientPlugin<PlayerGiveawayData>
}
@Override
protected PlayerGiveawayData AddPlayer(String player)
protected PlayerGiveawayData addPlayer(String player)
{
return new PlayerGiveawayData();
}

View File

@ -80,7 +80,7 @@ public class IgnoreManager extends MiniDbClientPlugin<IgnoreData>
}
@Override
protected IgnoreData AddPlayer(String player)
protected IgnoreData addPlayer(String player)
{
return new IgnoreData();
}

View File

@ -191,7 +191,7 @@ public class IncognitoManager extends MiniDbClientPlugin<IncognitoClient>
UtilPlayer.message(player, " ");
}
protected IncognitoClient AddPlayer(String player)
protected IncognitoClient addPlayer(String player)
{
return new IncognitoClient();
}

View File

@ -342,7 +342,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
}
@Override
protected ClientInventory AddPlayer(String player)
protected ClientInventory addPlayer(String player)
{
return new ClientInventory();
}

View File

@ -87,7 +87,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
}
@Override
protected ClientMessage AddPlayer(String player)
protected ClientMessage addPlayer(String player)
{
Set(player, new ClientMessage());
return Get(player);

View File

@ -40,7 +40,7 @@ public class Movement extends MiniClientPlugin<ClientMovement>
}
@Override
protected ClientMovement AddPlayer(String player)
protected ClientMovement addPlayer(String player)
{
return new ClientMovement();
}

View File

@ -1,12 +1,8 @@
package mineplex.core.packethandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import com.mineplex.spigot.PacketProcessor;
import mineplex.core.MiniPlugin;
import net.minecraft.server.v1_8_R3.Packet;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -15,16 +11,22 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.mineplex.spigot.PacketProcessor;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class PacketHandler extends MiniPlugin
{
private NautHashMap<Player, PacketVerifier> _playerVerifierMap = new NautHashMap<Player, PacketVerifier>();
private HashMap<Class, ArrayList<IPacketHandler>> _forceMainThread = new HashMap<Class, ArrayList<IPacketHandler>>();
private HashMap<Class, ArrayList<IPacketHandler>> _packetHandlers = new HashMap<Class, ArrayList<IPacketHandler>>();
private Map<Player, PacketVerifier> _playerVerifierMap = new HashMap<>();
private Map<Class<? extends Packet>, Set<IPacketHandler>> _forceMainThread = new HashMap<>();
private Map<Class<? extends Packet>, Map<ListenerPriority, List<IPacketHandler>>> _packetHandlers = new HashMap<>();
public PacketHandler(JavaPlugin plugin)
{
@ -40,18 +42,6 @@ public class PacketHandler extends MiniPlugin
.get(event.getPlayer()));
}
public boolean handlePacket(Player player, Packet packet)
{
if (!_playerVerifierMap.containsKey(player))
{
return true;
}
PacketVerifier verifier = _playerVerifierMap.get(player);
return handlePacket(new PacketInfo(player, packet, verifier));
}
public boolean handlePacket(PacketInfo packetInfo)
{
if (!_packetHandlers.containsKey(packetInfo.getPacket().getClass()))
@ -60,7 +50,9 @@ public class PacketHandler extends MiniPlugin
return true;
}
for (IPacketHandler handler : _packetHandlers.get(packetInfo.getPacket().getClass()))
for (Entry<ListenerPriority, List<IPacketHandler>> entry : _packetHandlers.get(packetInfo.getPacket().getClass()).entrySet())
{
for (IPacketHandler handler : entry.getValue())
{
try
{
@ -71,6 +63,7 @@ public class PacketHandler extends MiniPlugin
ex.printStackTrace();
}
}
}
return !packetInfo.isCancelled();
}
@ -89,19 +82,37 @@ public class PacketHandler extends MiniPlugin
@SafeVarargs
public final void addPacketHandler(IPacketHandler packetHandler, Class<? extends Packet>... packetsToListen)
{
addPacketHandler(packetHandler, ListenerPriority.NORMAL, false, packetsToListen);
}
@SafeVarargs
public final void addPacketHandler(IPacketHandler packetHandler, boolean forceMainThread, Class<? extends Packet>... packetsToListen)
{
if (packetsToListen.length == 0)
{
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to");
}
addPacketHandler(packetHandler, false, packetsToListen);
addPacketHandler(packetHandler, ListenerPriority.NORMAL, forceMainThread, packetsToListen);
}
@SafeVarargs
public final void addPacketHandler(IPacketHandler packetHandler, ListenerPriority priority, Class<? extends Packet>... packetsToListen)
{
if (packetsToListen.length == 0)
{
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to");
}
addPacketHandler(packetHandler, priority, false, packetsToListen);
}
/**
* This should only be used for incoming packets
*/
public void addPacketHandler(IPacketHandler packetHandler, boolean forceMainThread,
@SafeVarargs
public final void addPacketHandler(IPacketHandler packetHandler, ListenerPriority priority, boolean forceMainThread,
Class<? extends Packet>... packetsToListen)
{
if (packetsToListen.length == 0)
@ -109,38 +120,50 @@ public class PacketHandler extends MiniPlugin
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to");
}
for (Class c : packetsToListen)
for (Class<? extends Packet> c : packetsToListen)
{
if (forceMainThread)
{
if (!_forceMainThread.containsKey(c))
{
_forceMainThread.put(c, new ArrayList());
_forceMainThread
.computeIfAbsent(c, key -> new HashSet<>())
.add(packetHandler);
}
_forceMainThread.get(c).add(packetHandler);
}
_packetHandlers
.computeIfAbsent(c, key -> new TreeMap<>())
.computeIfAbsent(priority, key -> new ArrayList<>())
.add(packetHandler);
if (!_packetHandlers.containsKey(c))
{
_packetHandlers.put(c, new ArrayList());
}
_packetHandlers.get(c).add(packetHandler);
PacketProcessor.addPacket(c, forceMainThread || _forceMainThread.containsKey(c));
}
}
public void removePacketHandler(IPacketHandler packetHandler)
{
Iterator<Entry<Class, ArrayList<IPacketHandler>>> itel = _packetHandlers.entrySet().iterator();
Iterator<Entry<Class<? extends Packet>, Map<ListenerPriority, List<IPacketHandler>>>> itel = _packetHandlers.entrySet().iterator();
while (itel.hasNext())
{
Entry<Class, ArrayList<IPacketHandler>> entry = itel.next();
Entry<Class<? extends Packet>, Map<ListenerPriority, List<IPacketHandler>>> entry = itel.next();
if (entry.getValue().remove(packetHandler))
Set<ListenerPriority> removedFrom = new HashSet<>();
for (Entry<ListenerPriority, List<IPacketHandler>> ent : entry.getValue().entrySet())
{
if (ent.getValue().remove(packetHandler))
{
removedFrom.add(ent.getKey());
}
}
for (ListenerPriority priority : removedFrom)
{
if (entry.getValue().get(priority).isEmpty())
{
entry.getValue().remove(priority);
}
}
if (_forceMainThread.containsKey(entry.getKey()) && _forceMainThread.get(entry.getKey()).remove(packetHandler))
{
if (_forceMainThread.get(entry.getKey()).isEmpty())
@ -157,5 +180,9 @@ public class PacketHandler extends MiniPlugin
}
}
}
public enum ListenerPriority
{
HIGH, NORMAL, LOW
}
}

View File

@ -24,17 +24,17 @@ public class Pet extends SalesPackageBase
KnownPackage = false;
}
public EntityType GetPetType()
public EntityType getPetType()
{
return _petType;
}
public void Update(PetSalesToken petToken)
public void update(PetSalesToken petToken)
{
_name = petToken.Name;
}
public String GetPetName()
public String getPetName()
{
return _name;
}

View File

@ -11,7 +11,7 @@ public class PetClient
private NautHashMap<EntityType, String> _pets;
private int _petNameTagCount;
public void Load(ClientPetToken token)
public void load(ClientPetToken token)
{
_pets = new NautHashMap<EntityType, String>();
@ -26,7 +26,7 @@ public class PetClient
_petNameTagCount = Math.max(0, token.PetNameTagCount);
}
public NautHashMap<EntityType, String> GetPets()
public NautHashMap<EntityType, String> getPets()
{
return _pets;
}

View File

@ -128,7 +128,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (player != null && player.isOnline())
{
AddPetOwner(player, _petOwnerQueue.get(playerName), player.getLocation());
addPetOwner(player, _petOwnerQueue.get(playerName), player.getLocation());
}
}
@ -160,24 +160,24 @@ 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(EntityType.WITHER))
Get(p).getPets().put(EntityType.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(EntityType.SKELETON))
Get(p).getPets().put(EntityType.SKELETON, "Guardian");
}
}
public void AddPetOwner(Player player, EntityType entityType, Location location)
public void addPetOwner(Player player, EntityType entityType, Location location)
{
if (_activePetOwners.containsKey(player.getName()))
{
if (_activePetOwners.get(player.getName()).getType() != entityType)
{
RemovePet(player, true);
removePet(player, true);
}
else
return;
@ -214,10 +214,10 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
//Named Pet
if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0)
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
{
//pet.setCustomNameVisible(true);
pet.setCustomName(Get(player).GetPets().get(entityType));
pet.setCustomName(Get(player).getPets().get(entityType));
}
if (pet instanceof Zombie)
@ -245,9 +245,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
DisguiseGuardian disguise = new DisguiseGuardian(pet);
if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0)
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
{
disguise.setName(Get(player).GetPets().get(entityType));
disguise.setName(Get(player).getPets().get(entityType));
}
_disguiseManager.disguise(disguise);
@ -265,12 +265,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
UtilEnt.Vegetate(pet);
}
public Creature GetPet(Player player)
public Creature getPet(Player player)
{
return _activePetOwners.get(player.getName());
}
public void RemovePet(final Player player, boolean removeOwner)
public void removePet(final Player player, boolean removeOwner)
{
if (_activePetOwners.containsKey(player.getName()))
{
@ -303,7 +303,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
RemovePet(event.getPlayer(), true);
removePet(event.getPlayer(), true);
}
@EventHandler
@ -336,7 +336,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (player != null && player.isOnline())
{
RemovePet(player, true);
removePet(player, true);
}
}
}
@ -438,25 +438,25 @@ public class PetManager extends MiniClientPlugin<PetClient>
}
@EventHandler
public void OnClientWebResponse(ClientWebResponseEvent event)
public void onClientWebResponse(ClientWebResponseEvent event)
{
ClientPetTokenWrapper token = new Gson().fromJson(event.GetResponse(), ClientPetTokenWrapper.class);
Get(token.Name).Load(token.DonorToken);
Get(token.Name).load(token.DonorToken);
}
@Override
protected PetClient AddPlayer(String player)
protected PetClient addPlayer(String player)
{
return new PetClient();
}
public PetFactory GetFactory()
public PetFactory getFactory()
{
return _petFactory;
}
public PetRepository GetRepository()
public PetRepository getRepository()
{
return _repository;
}
@ -471,15 +471,15 @@ public class PetManager extends MiniClientPlugin<PetClient>
return _activePetOwners.get(name);
}
public void DisableAll()
public void disableAll()
{
for (Player player : UtilServer.getPlayers())
RemovePet(player, true);
removePet(player, true);
}
public void DisableAll(Player player)
public void disableAll(Player player)
{
RemovePet(player, true);
removePet(player, true);
}
public Collection<Creature> getPets()

View File

@ -51,7 +51,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
}
@Override
protected PlayerPollData AddPlayer(String player)
protected PlayerPollData addPlayer(String player)
{
return new PlayerPollData();
}

View File

@ -59,7 +59,7 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
}
@Override
protected UserPreferences AddPlayer(String player)
protected UserPreferences addPlayer(String player)
{
return new UserPreferences();
}

View File

@ -33,7 +33,7 @@ public class KitProgressionManager extends MiniClientPlugin<PlayerKit>
@Override
protected PlayerKit AddPlayer(String player)
protected PlayerKit addPlayer(String player)
{
return null;
}

View File

@ -864,7 +864,7 @@ public class RewardManager
{
if (!displayName.contains("Uncle Sam"))
{
display = CountryFlag.Usa.getBanner();
display = CountryFlag.USA.getBanner();
}
}
UnknownPackageReward reward =
@ -929,7 +929,7 @@ public class RewardManager
public PetReward addPetReward(Type type, EntityType entityType, RewardRarity rarity, int weight, int shards)
{
Pet pet = _petManager.GetFactory().getPet(entityType);
Pet pet = _petManager.getFactory().getPet(entityType);
PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager,
pet.getName() + " Pet", pet.getName(), entityType, rarity, weight, shards);
addReward(type, reward);

View File

@ -50,8 +50,8 @@ public class PetReward extends UnknownPackageReward
PetToken petToken = new PetToken();
petToken.PetType = token.PetType;
_petManager.GetRepository().AddPet(token);
_petManager.Get(player).GetPets().put(_petEntity, token.PetName);
_petManager.getRepository().AddPet(token);
_petManager.Get(player).getPets().put(_petEntity, token.PetName);
_inventoryManager.addItemToInventory(player, _petEntity.toString(), 1);
@ -67,6 +67,6 @@ public class PetReward extends UnknownPackageReward
return false;
}
return !_petManager.Get(player).GetPets().containsKey(_petEntity);
return !_petManager.Get(player).getPets().containsKey(_petEntity);
}
}

View File

@ -307,7 +307,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
}
@Override
protected PlayerStats AddPlayer(String player)
protected PlayerStats addPlayer(String player)
{
return new PlayerStats();
}

View File

@ -49,7 +49,7 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
}
@Override
protected TaskClient AddPlayer(String playerName)
protected TaskClient addPlayer(String playerName)
{
return new TaskClient();
}

View File

@ -80,7 +80,7 @@ public class TournamentManager extends MiniDbClientPlugin<ClientTournamentData>
}
@Override
protected ClientTournamentData AddPlayer(String player)
protected ClientTournamentData addPlayer(String player)
{
return new ClientTournamentData();
}

View File

@ -40,6 +40,19 @@ public class BuyChestButton implements IButton
@Override
public void onClick(final Player player, ClickType clickType)
{
if (_chestType == TreasureType.FREEDOM)
{
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
else
{
player.sendMessage(F.main("Treasure", "This chest is no longer available for purchases!"));
return;
}
}
if (!_page.getPlugin().hasItemsToGivePlayer(TreasureType.ILLUMINATED.getRewardPool(), player)
&& _chestType == TreasureType.ILLUMINATED)
{

View File

@ -13,6 +13,7 @@ import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -166,13 +167,11 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
freedomLore.add(C.cGray + "carved this chest himself from the wood");
freedomLore.add(C.cGray + "of the apple tree he cut down...");
freedomLore.add(" ");
if (freedomCount > 0)
if (freedomCount > 0 && !hasAllFreedomItems(getPlayer()))
freedomLore.add(ChatColor.RESET + C.cGreen + "Click to Open!");
else
{
freedomLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "35000 Treasure Shards");
freedomLore.add(" ");
freedomLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
freedomLore.add(C.cRed + "This item is no longer available!");
}
freedomLore.add(" ");
freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/7 Unlocked");
@ -188,8 +187,13 @@ public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
addItem(40, shards);
addChest(11, christmas, TreasureType.CHRISTMAS, christmasCount);
if (!hasAllFreedomItems(getPlayer()))
if (!hasAllFreedomItems(getPlayer()) && freedomCount >= 1)
addChest(13, freedom, TreasureType.FREEDOM, freedomCount);
else
{
freedom = new ShopItem(Material.INK_SACK, DyeColor.SILVER.getData(), C.cRed + C.Bold + "Freedom " + C.cBlue + C.Bold + "Treasure", freedomLore.toArray(new String[0]), 0, true, false);
addChest(13, freedom, TreasureType.FREEDOM, freedomCount);
}
addChest(15, illuminated, TreasureType.ILLUMINATED, illuminatedCount);
addChest(20, basic, TreasureType.OLD, basicCount);
addChest(22, heroic, TreasureType.ANCIENT, heroicCount);

View File

@ -2,7 +2,10 @@ package mineplex.core.youtube;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@ -14,6 +17,7 @@ import java.time.ZonedDateTime;
public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
{
private static final int REWARD_MESSAGE_DELAY_SECONDS = 30;
private final YoutubeRepository _repository;
private final DonationManager _donationManager;
@ -48,7 +52,11 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
}
YoutubeClient client = Get(player);
client.setClickDate(ZonedDateTime.now(ZoneOffset.UTC).toLocalDate());
_repository.attemptYoutube(player, client, () -> _donationManager.RewardCoinsLater("YouTube", player, 250));
_repository.attemptYoutube(player, client, () ->
{
_donationManager.RewardCoinsLater("YouTube", player, 250);
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem("250 Treasure Shards") + " for watching the YouTube video")), REWARD_MESSAGE_DELAY_SECONDS * 20L);
});
}
@Override
@ -68,7 +76,7 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
}
@Override
protected YoutubeClient AddPlayer(String player)
protected YoutubeClient addPlayer(String player)
{
return new YoutubeClient(null);
}

View File

@ -1000,7 +1000,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
@Override
protected ClientClan AddPlayer(String player)
protected ClientClan addPlayer(String player)
{
return new ClientClan();
}

View File

@ -204,7 +204,7 @@ public class MurderManager extends MiniClientPlugin<ClientMurder>
}
@Override
protected ClientMurder AddPlayer(String player)
protected ClientMurder addPlayer(String player)
{
return new ClientMurder();
}

View File

@ -45,7 +45,7 @@ public class Playtime extends MiniClientPlugin<PlayingClient>
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Set(event.getPlayer(), AddPlayer(event.getPlayer().getName()));
Set(event.getPlayer(), addPlayer(event.getPlayer().getName()));
}
@EventHandler
@ -73,7 +73,7 @@ public class Playtime extends MiniClientPlugin<PlayingClient>
}
@Override
protected PlayingClient AddPlayer(String player)
protected PlayingClient addPlayer(String player)
{
return new PlayingClient(Bukkit.getPlayer(player), TaskManager.Instance);
}

View File

@ -135,6 +135,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private IncognitoManager _incognito;
private ValentinesManager _valentinesManager;
private BonusManager _bonusManager;
private JumpManager _jumpManager;
// private HalloweenSpookinessManager _halloweenManager;
// private TrickOrTreatManager _trickOrTreatManager;
@ -181,7 +182,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_parkour = new ParkourManager(this, donationManager, taskManager);
new WorldManager(this);
new JumpManager(this);
_jumpManager = new JumpManager(this);
//new TournamentInviter(this);
@ -786,7 +787,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
@Override
protected HubClient AddPlayer(String player)
protected HubClient addPlayer(String player)
{
return new HubClient(player);
}
@ -1072,4 +1073,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
return _incognito;
}
public JumpManager getJumpManager()
{
return _jumpManager;
}
}

View File

@ -27,7 +27,7 @@ public class MailManager extends MiniClientPlugin<PlayerMailData> implements Not
}
@Override
protected PlayerMailData AddPlayer(String player)
protected PlayerMailData addPlayer(String player)
{
return new PlayerMailData();
}

View File

@ -1,11 +1,13 @@
package mineplex.hub.modules;
import org.bukkit.Bukkit;
import java.util.HashSet;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.util.Vector;
@ -28,6 +30,7 @@ import mineplex.hub.HubManager;
public class JumpManager extends MiniPlugin
{
public HubManager Manager;
private HashSet<String> _preparedDoubleJump = new HashSet<>();
public JumpManager(HubManager manager)
{
@ -66,6 +69,7 @@ public class JumpManager extends MiniPlugin
vec.setY(Math.abs(vec.getY()));
//Velocity
_preparedDoubleJump.add(player.getName());
UtilAction.velocity(player, vec, 1.4, false, 0, 0.2, 1, true);
//Sound
@ -105,8 +109,20 @@ public class JumpManager extends MiniPlugin
{
player.setAllowFlight(true);
player.setFlying(false);
_preparedDoubleJump.remove(player.getName());
}
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
_preparedDoubleJump.remove(event.getPlayer().getName());
}
public boolean hasDoubleJumped(Player player)
{
return _preparedDoubleJump.contains(player.getName());
}
}

View File

@ -197,7 +197,7 @@ public class KothManager extends MiniPlugin
Manager.GetGadget().disableAll(player, outfit);
Manager.GetMount().DisableAll(player);
Manager.getPetManager().DisableAll(player);
Manager.getPetManager().disableAll(player);
}
else
{

View File

@ -3,9 +3,9 @@ package mineplex.hub.modules;
import java.util.ArrayList;
import java.util.HashSet;
import org.bukkit.Color;
import org.bukkit.EntityEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Bat;
@ -20,6 +20,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
@ -37,8 +38,10 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.gadgets.outfit.OutfitTeam;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
@ -50,7 +53,7 @@ import mineplex.hub.HubManager;
public class SoccerManager extends MiniPlugin
{
public HubManager Manager;
private HubManager _hubManager;
private HashSet<Player> _active = new HashSet<Player>();
@ -71,10 +74,10 @@ public class SoccerManager extends MiniPlugin
private Location _cornerBlueGoalA;
private Location _cornerBlueGoalB;
int _blueGoals = 0;
int _redGoals = 0;
private int _blueGoals = 0;
private int _redGoals = 0;
int _insideGoalTicks = 0;
private int _insideGoalTicks = 0;
private Slime _ball;
private Vector _ballVel;
@ -89,29 +92,29 @@ public class SoccerManager extends MiniPlugin
protected Location _lastLoc;
protected ArrayList<Vector> _velHistory = new ArrayList<Vector>();
public SoccerManager(HubManager manager, GadgetManager gadgets)
public SoccerManager(HubManager hubManager, GadgetManager gadgetManager)
{
super("Football Manager", manager.getPlugin());
super("Football Manager", hubManager.getPlugin());
Manager = manager;
_hubManager = hubManager;
_cornerFieldPlayerA = new Location(Manager.GetSpawn().getWorld(), 28.5,70,-27.5);
_cornerFieldPlayerB = new Location(Manager.GetSpawn().getWorld(), 50.5,100,-65.5);
_cornerFieldPlayerA = new Location(hubManager.GetSpawn().getWorld(), 28.5,70,-27.5);
_cornerFieldPlayerB = new Location(hubManager.GetSpawn().getWorld(), 50.5,100,-65.5);
_cornerGoalPlayerA = new Location(Manager.GetSpawn().getWorld(), 35.5,70,-24.5);
_cornerGoalPlayerB = new Location(Manager.GetSpawn().getWorld(), 43.5,100,-68.5);
_cornerGoalPlayerA = new Location(hubManager.GetSpawn().getWorld(), 35.5,70,-24.5);
_cornerGoalPlayerB = new Location(hubManager.GetSpawn().getWorld(), 43.5,100,-68.5);
_cornerFieldA = new Location(Manager.GetSpawn().getWorld(), 29.75,70,-28.75);
_cornerFieldB = new Location(Manager.GetSpawn().getWorld(), 49.25,100,-64.25);
_cornerFieldA = new Location(hubManager.GetSpawn().getWorld(), 29.75,70,-28.75);
_cornerFieldB = new Location(hubManager.GetSpawn().getWorld(), 49.25,100,-64.25);
_cornerRedGoalA = new Location(Manager.GetSpawn().getWorld(), 36.75,70,-64.25);
_cornerRedGoalB = new Location(Manager.GetSpawn().getWorld(), 42.25,73.5,-67.25);
_cornerRedGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-64.25);
_cornerRedGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-67.25);
_cornerBlueGoalA = new Location(Manager.GetSpawn().getWorld(), 36.75,70,-25.75);
_cornerBlueGoalB = new Location(Manager.GetSpawn().getWorld(), 42.25,73.5,-28.75);
_cornerBlueGoalA = new Location(hubManager.GetSpawn().getWorld(), 36.75,70,-25.75);
_cornerBlueGoalB = new Location(hubManager.GetSpawn().getWorld(), 42.25,73.5,-28.75);
//Store Gadgets
for (Gadget gadget : gadgets.getGadgets(GadgetType.COSTUME))
for (Gadget gadget : gadgetManager.getGadgets(GadgetType.COSTUME))
{
if (gadget instanceof OutfitTeam)
{
@ -470,9 +473,9 @@ public class SoccerManager extends MiniPlugin
outfit.add("Team Pants");
outfit.add("Team Boots");
Manager.GetGadget().disableAll(player, outfit);
Manager.GetMount().DisableAll(player);
Manager.getPetManager().DisableAll(player);
_hubManager.GetGadget().disableAll(player, outfit);
_hubManager.GetMount().DisableAll(player);
_hubManager.getPetManager().disableAll(player);
}
else
{
@ -481,9 +484,9 @@ public class SoccerManager extends MiniPlugin
}
}
public boolean isSoccerMode(Player player)
public boolean isSoccerMode(Entity entity)
{
return _active.contains(player);
return _active.contains(entity);
}
@EventHandler
@ -510,6 +513,35 @@ public class SoccerManager extends MiniPlugin
event.setCancelled(true);
}
@EventHandler
public void disableStacker(StackerEvent event)
{
if (isSoccerMode(event.getEntity()))
{
event.setCancelled(true);
}
}
@EventHandler
public void disableGuardianLazer(GadgetSelectLocationEvent event)
{
if (UtilAlg.inBoundingBox(event.getLocation(), _cornerFieldA, _cornerFieldB))
{
event.setCancelled(true);
}
}
@EventHandler
public void disableVelocity(PlayerVelocityEvent event)
{
// Disable velocity but allow double jumping.
if (isSoccerMode(event.getPlayer()) && !_hubManager.getJumpManager().hasDoubleJumped(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{

View File

@ -948,7 +948,7 @@ public class ServerManager extends MiniDbClientPlugin<SimpleClanToken> implement
}
@Override
protected SimpleClanToken AddPlayer(String player)
protected SimpleClanToken addPlayer(String player)
{
return new SimpleClanToken();
}

View File

@ -322,7 +322,7 @@ public class ClassManager extends MiniClientPlugin<ClientClass> implements IClas
}
@Override
protected ClientClass AddPlayer(String player)
protected ClientClass addPlayer(String player)
{
return new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(player), _donationManager.Get(player), null);
}

View File

@ -44,6 +44,7 @@ public class CustomDamageEvent extends Event implements Cancellable
private boolean _damageeBrute = false;
private boolean _damageToLevel = true;
private boolean _arrowShow = true;
private boolean _projectileDamageSelf = false;
public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile, Location knockbackOrigin,
DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor, String initialSource,
@ -169,6 +170,27 @@ public class CustomDamageEvent extends Event implements Cancellable
return _projectile;
}
public boolean getProjectileDamageSelf()
{
return _projectileDamageSelf;
}
public void setProjectileDamageSelf(boolean projectileDamageSelf)
{
_projectileDamageSelf = projectileDamageSelf;
if(!projectileDamageSelf)
{
_cancellers.remove("Self Projectile Damage");
}
else
{
if(!_cancellers.contains("Self Projectile Damage"))
{
_cancellers.add("Self Projectile Damage");
}
}
}
public void setShowArrows(boolean show)
{
_arrowShow = show;

View File

@ -8,24 +8,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.npc.NpcManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.compatibility.NpcProtectListener;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.EntityEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -48,6 +30,24 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.npc.NpcManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.compatibility.NpcProtectListener;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityLiving;
public class DamageManager extends MiniPlugin
{
private CombatManager _combatManager;
@ -231,16 +231,20 @@ public class DamageManager extends MiniPlugin
@EventHandler
public void onEntityCombust(EntityCombustByEntityEvent event)
{
if (!_enabled)
return;
if (!(event.getCombuster() instanceof Player || event.getCombuster() instanceof Arrow))
return;
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void removeDemArrowsCrazyMan(EntityDamageEvent event)
{
if (event.isCancelled())
/**
* Removes arrows after hit, especially in cases where arrows may bounce, like if the damage was cancelled.
*/
@EventHandler(priority = EventPriority.MONITOR)
public void removeArrows(EntityDamageEvent event)
{
Projectile projectile = GetProjectile(event);
@ -250,6 +254,20 @@ public class DamageManager extends MiniPlugin
projectile.remove();
}
}
/**
* Removes arrows after hit, especially in cases where arrows may bounce, like if the damage was cancelled.
*/
@EventHandler(priority = EventPriority.MONITOR)
public void removeArrows(CustomDamageEvent event)
{
Projectile projectile = event.GetProjectile();
if (projectile instanceof Arrow)
{
projectile.teleport(new Location(projectile.getWorld(), 0, 0, 0));
projectile.remove();
}
}
/*
private boolean GoldPower(LivingEntity damager)
@ -316,6 +334,12 @@ public class DamageManager extends MiniPlugin
return;
}
if (event.GetProjectile() != null && event.GetDamageeEntity().equals(event.GetProjectile().getShooter()) && !event.getProjectileDamageSelf())
{
event.SetCancelled("Self Projectile Damage");
return;
}
if (event.GetDamageePlayer() != null)
{
Player damagee = event.GetDamageePlayer();
@ -375,6 +399,10 @@ public class DamageManager extends MiniPlugin
Player damagee = event.GetDamageePlayer();
if (damagee != null)
{
if (event.GetDamage() <= 0)
{
return;
}
if (getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()) > 0)
{
event.AddMult("Ench Prot", damagee.getName(), getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()), false);
@ -432,6 +460,8 @@ public class DamageManager extends MiniPlugin
Player player = event.GetDamagerPlayer(true);
if (player != null)
{
if (player.equals(event.GetDamageeEntity()) && !event.getProjectileDamageSelf()) return;
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 0.5f, 0.5f);
}
}
@ -456,6 +486,11 @@ public class DamageManager extends MiniPlugin
if (event.GetDamageeEntity().getHealth() <= 0)
return;
if (event.GetProjectile() != null &&
event.GetDamageeEntity().equals(event.GetProjectile().getShooter()) &&
!event.getProjectileDamageSelf())
return;
//Player Conditions
if (event.GetDamageePlayer() != null)
{
@ -510,14 +545,21 @@ public class DamageManager extends MiniPlugin
origin = event.GetDamagerEntity(true).getLocation();
if (event.getKnockbackOrigin() != null)
origin = event.getKnockbackOrigin();
else if (event.GetProjectile() != null)
origin = event.GetProjectile().getLocation();
//Vec
Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation());
trajectory.multiply(0.6 * knockback);
trajectory.setY(Math.abs(trajectory.getY()));
//Special handling for projectiles
if(event.GetProjectile() != null && event.getKnockbackOrigin() == null)
{
trajectory = event.GetProjectile().getVelocity();
trajectory.setY(0);
trajectory.multiply(0.6 * knockback / trajectory.length());
trajectory.setY(0.5);
}
//Apply
double vel = 0.2 + trajectory.length() * 0.8;

View File

@ -172,6 +172,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private KitProgressionManager _kitProgressionManager;
private ProgressingKitManager _progressionKitManager;
private BoosterManager _boosterManager;
private GameSpectatorManager _spectatorManager;
private IncognitoManager _incognitoManager;
@ -290,7 +291,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), boosterManager);
new GameLootManager(this, petManager, _bonusManager.getRewardManager());
new GameSpectatorManager(this);
_spectatorManager = new GameSpectatorManager(this);
_gameWorldManager = new GameWorldManager(this);
new MiscManager(this);
_hologramManager = hologramManager;
@ -1705,4 +1706,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _kitProgressionManager;
}
public GameSpectatorManager getGameSpectatorManager()
{
return _spectatorManager;
}
}

View File

@ -24,6 +24,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.kit.*;
import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.managers.chat.ChatStatData;
@ -314,8 +315,6 @@ public abstract class Game implements Listener
public boolean AllowEntitySpectate = true;
public boolean PlayerTeamSelection = false;
public boolean TeamMode = false;
public boolean TeamPerSpawn = false;
@ -335,6 +334,8 @@ public abstract class Game implements Listener
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
public WinEffectManager WinEffectManager = new WinEffectManager();
private Map<Class<? extends Module>, Module> _modules = new HashMap<>();
public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
{
Manager = manager;
@ -421,6 +422,20 @@ public abstract class Game implements Listener
System.out.println("Loading " + GetName() + "...");
}
public void registerModule(Module module)
{
if (!_modules.containsKey(module.getClass()))
{
module.initialize(this);
_modules.put(module.getClass(), module);
UtilServer.RegisterEvents(module);
}
else
{
throw new IllegalStateException("Module " + module.getClass() + " is already registered");
}
}
public void setKits(Kit[] kits)
{
_kits = kits;
@ -1912,157 +1927,6 @@ public abstract class Game implements Listener
}
}
@EventHandler(priority = EventPriority.HIGH)
public void teamSelectInteract(PlayerInteractEntityEvent event)
{
if (!PlayerTeamSelection)
return;
if (GetState() != GameState.Recruit)
return;
if (event.getRightClicked() == null)
return;
if (!(event.getRightClicked() instanceof Player))
return;
Player player = event.getPlayer();
//Observer
if (Manager.IsObserver(player))
{
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
return;
}
selectTeamMate(player, (Player) event.getRightClicked());
}
@EventHandler
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
{
if (!PlayerTeamSelection)
return;
if (GetState() != GameState.Recruit)
return;
if (!event.getMessage().toLowerCase().startsWith("/team "))
return;
event.setCancelled(true);
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1],
true);
if (target == null)
return;
//Observer
if (Manager.IsObserver(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(),
F.main("Game", "Spectators cannot partake in games."));
return;
}
if (event.getPlayer().equals(target))
return;
selectTeamMate(event.getPlayer(), target);
}
public void selectTeamMate(Player player, Player ally)
{
//Accept Invite
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
{
//Remove Prefs
_teamReqs.remove(player);
_teamReqs.remove(ally);
//Inform
UtilPlayer.message(player,
F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
UtilPlayer.message(ally,
F.main("Game", player.getName() + " accepted your Team Request!"));
//Leave Old Teams
if (GetTeam(player) != null)
GetTeam(player).DisbandTeam();
if (GetTeam(ally) != null)
GetTeam(ally).DisbandTeam();
//Get Team
GameTeam team = getEmptyTeam();
if (team == null)
return;
//Join Team
SetPlayerTeam(player, team, true);
SetPlayerTeam(ally, team, true);
}
//Send Invite
else
{
//Already on Team with Target
if (GetTeam(player) != null)
if (GetTeam(player).HasPlayer(ally))
return;
//Inform Player
UtilPlayer.message(player,
F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
//Inform Target
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
{
UtilPlayer.message(ally,
F.main("Game", player.getName() + " sent you a Team Request!"));
UtilPlayer.message(ally, F.main("Game",
"Type " + F.elem("/team " + player.getName()) + " to accept!"));
}
//Add Pref
_teamReqs.put(player, ally);
}
}
@EventHandler
public void teamQuit(PlayerQuitEvent event)
{
if (!PlayerTeamSelection)
return;
if (GetState() != GameState.Recruit)
return;
Player player = event.getPlayer();
if (GetTeam(player) != null)
GetTeam(player).DisbandTeam();
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
while (teamIter.hasNext())
{
Player sender = teamIter.next();
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
teamIter.remove();
}
}
public GameTeam getEmptyTeam()
{
for (GameTeam team : GetTeamList())
{
if (team.GetPlayers(false).isEmpty())
return team;
}
return null;
}
@EventHandler
public void CustomTeamGeneration(GameStateChangeEvent event)
{
@ -2286,4 +2150,17 @@ public abstract class Game implements Listener
{
}
public void cleanupModules()
{
for (Module module : this._modules.values())
{
module.cleanup();
HandlerList.unregisterAll(module);
}
}
public <T extends Module> T getModule(Class<T> clazz)
{
return clazz.cast(_modules.get(clazz));
}
}

View File

@ -24,6 +24,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Creature;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
public class GameTeam
{
@ -192,7 +193,11 @@ public class GameTeam
{
for(Player other : UtilServer.getPlayers())
{
other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name + _name.toUpperCase()).removePlayer(player);
Team team = other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name + _name.toUpperCase());
if (team != null)
{
team.removePlayer(player);
}
other.getScoreboard().getTeam(Host.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
}
UtilPlayer.message(player, F.main("Team", _color + C.Bold + getDisplayName() + " Team was disbanded."));

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import nautilus.game.arcade.game.modules.TeamModule;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
@ -40,7 +41,9 @@ public class TeamBuild extends Build
super(manager, GameType.Brawl);
TeamMode = true;
PlayerTeamSelection = true;
registerModule(new TeamModule());
TeamPerSpawn = true;
FillTeamsInOrderToCount = 2;

View File

@ -2139,6 +2139,12 @@ public class MineStrike extends TeamGame
//Revive Dead Players
for (Player player : GetPlayers(false))
{
if (Manager.isVanished(player))
{
continue;
}
if (!IsAlive(player))
{
SetPlayerState(player, PlayerState.IN);
@ -2156,6 +2162,7 @@ public class MineStrike extends TeamGame
if (GetKit(player) != null)
GetKit(player).ApplyKit(player);
}
}
//Remove Scope
for (Player player : GetPlayers(false))
@ -2319,6 +2326,11 @@ public class MineStrike extends TeamGame
if (GetState() == GameState.Recruit || GetState() == GameState.Loading)
return;
if (Manager.isVanished(event.getPlayer()))
{
return;
}
//Target Team
GameTeam targetTeam = null;
if (GetTeamList().get(0).GetPlayers(false).size() < GetTeamList().get(1).GetPlayers(false).size())

View File

@ -52,7 +52,13 @@ public class HighExplosive extends Grenade
continue;
// Damage Event
game.Manager.GetDamage().NewDamageEvent(player, _thrower, null, ent.getLocation(),
Player damager = null;
if (game.IsAlive(_thrower))
{
damager = _thrower;
}
game.Manager.GetDamage().NewDamageEvent(player, damager, null, ent.getLocation(),
DamageCause.CUSTOM, 1 + (players.get(player) * 18),
true, true, false, _thrower.getName(), getName());

View File

@ -19,6 +19,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.stats.DeathBomberStatTracker;
import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker;
import nautilus.game.arcade.stats.SkywarsTNTStatTracker;
@ -79,9 +80,10 @@ public class TeamSkywars extends Skywars
DontAllowOverfill = true;
PlayerTeamSelection = true;
TeamMode = true;
TeamPerSpawn = true;
registerModule(new TeamModule());
}
@Override

View File

@ -15,6 +15,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.FreeKitWinStatTracker;
import nautilus.game.arcade.stats.KillFastStatTracker;
@ -55,7 +56,8 @@ public class TeamSuperSmash extends SuperSmash
DontAllowOverfill = true;
TeamMode = true;
PlayerTeamSelection = true;
registerModule(new TeamModule());
registerStatTrackers(
new WinWithoutDyingStatTracker(this, "MLGPro"),

View File

@ -55,7 +55,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.ArmorStand;
@ -1541,6 +1540,13 @@ public class SpeedBuilders extends SoloGame
UtilPlayer.message(event.getPlayer(), F.main("Build", "Cannot build outside your area!"));
}
else
{
if (liquid.getType() == Material.STATIONARY_WATER || liquid.getType() == Material.WATER)
{
event.setCancelled(true);
}
}
}
@EventHandler
@ -1695,6 +1701,39 @@ public class SpeedBuilders extends SoloGame
UtilAction.velocity(event.getPlayer(), new Vector(0, 1, 0));
}
@EventHandler
public void fixDoorToggling(PlayerInteractEvent event)
{
if (!IsLive())
return;
if (_state != SpeedBuildersState.BUILDING)
return;
if (!_buildRecreations.containsKey(event.getPlayer()))
return;
if (_perfectBuild.containsKey(event.getPlayer()))
{
event.setCancelled(true);
return;
}
if (event.getPlayer().getItemInHand() == null)
{
event.setCancelled(true);
return;
}
Block block = event.getClickedBlock().getRelative(event.getBlockFace());
if (!_buildRecreations.get(event.getPlayer()).inBuildArea(block))
{
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Build", "Cannot build outside your area!"));
}
}
@Override
public void EndCheck()
{

View File

@ -324,6 +324,12 @@ public class RecreationData
score++;
}
//Fix for glowing redstone ore
if ((expectedState.getType() == Material.REDSTONE_ORE && currentBlock.getType() == Material.GLOWING_REDSTONE_ORE) || (expectedState.getType() == Material.GLOWING_REDSTONE_ORE && currentBlock.getType() == Material.REDSTONE_ORE))
{
score++;
}
//Fix for corner stair shape
if (currentBlock.getState().getData() instanceof Stairs && expectedState.getData() instanceof Stairs)
{

View File

@ -17,6 +17,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
@ -59,7 +60,8 @@ public class TeamSurvivalGames extends SurvivalGames
DontAllowOverfill = true;
TeamMode = true;
PlayerTeamSelection = true;
registerModule(new TeamModule());
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"),

View File

@ -0,0 +1,385 @@
package nautilus.game.arcade.game.games.uhc.helpers;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.timing.TimingManager;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.uhc.UHC;
import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkProviderServer;
import net.minecraft.server.v1_8_R3.ChunkRegionLoader;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.spigotmc.AsyncCatcher;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import static nautilus.game.arcade.game.games.uhc.UHC.VIEW_DISTANCE;
public class ChunkLoadingThread extends Thread implements Listener
{
private Game _game;
private volatile boolean _isDecorating = false;
private AtomicInteger _actual = new AtomicInteger();
private AtomicInteger _expected = new AtomicInteger(23000); // Most likely it'll be around 23000
private Set<net.minecraft.server.v1_8_R3.Entity> _entities = new HashSet<>();
public ChunkLoadingThread(Game game)
{
super("Chunk Loader");
this._game = game;
UtilServer.RegisterEvents(this);
}
public void run()
{
WorldServer worldServer = ((CraftWorld) _game.WorldData.World).getHandle();
Location spawn = _game.WorldData.World.getSpawnLocation();
Map<Long, Chunk> loaded = new ConcurrentHashMap<>();
Map<Long, NBTTagCompound> compounds = new ConcurrentHashMap<>();
try
{
TimingManager.start("UHC Chunk Loading");
ChunkProviderServer chunkProviderServer = worldServer.chunkProviderServer;
Field chunkLoaderField = chunkProviderServer.getClass().getDeclaredField("chunkLoader");
chunkLoaderField.setAccessible(true);
ChunkRegionLoader loader = (ChunkRegionLoader) chunkLoaderField.get(chunkProviderServer);
// Step 1: Read all the required chunks from the disk
// We're going to read all the required chunks from disk async
{
Set<Long> coordPairs = new HashSet<>();
// Special case for 0, 0
{
int x = spawn.getBlockX() >> 4;
int z = spawn.getBlockZ() >> 4;
for (int dx = -VIEW_DISTANCE; dx <= VIEW_DISTANCE; dx++)
{
for (int dz = -VIEW_DISTANCE; dz <= VIEW_DISTANCE; dz++)
{
coordPairs.add(LongHash.toLong(x + dx, z + dz));
}
}
}
// All the team spawns
{
for (int i = 0; i < _game.GetTeamList().size(); i++)
{
GameTeam team = _game.GetTeamList().get(i);
for (Location l : team.GetSpawns())
{
int x = l.getChunk().getX();
int z = l.getChunk().getZ();
for (int dx = -VIEW_DISTANCE; dx <= VIEW_DISTANCE; dx++)
{
for (int dz = -VIEW_DISTANCE; dz <= VIEW_DISTANCE; dz++)
{
coordPairs.add(LongHash.toLong(x + dx, z + dz));
}
}
}
}
}
AtomicBoolean lockCompleted = new AtomicBoolean(false);
Object lock = new Object();
// Hop back onto the main thread
_game.getArcadeManager().runSync(() ->
{
for (Chunk chunk : new ArrayList<>(chunkProviderServer.chunks.values()))
{
chunk.bukkitChunk.unload(true, false);
}
lockCompleted.set(true);
synchronized(lock)
{
lock.notifyAll();
}
});
if (!lockCompleted.get())
{
synchronized (lock)
{
lock.wait();
}
}
if (!lockCompleted.get())
{
throw new IllegalStateException("Lock was not completed");
}
// Sigh... I don't want this to be here but it needs to be set somewhere...
// Multiply by 3 because there are 3 stages
_expected.set(coordPairs.size() * 3);
// Load them now
ExecutorService chunkLoaders = Executors.newFixedThreadPool(UHC.THREADS_FOR_CHUNK_LOADING);
for (long coord : coordPairs)
{
chunkLoaders.submit(() ->
{
int x = LongHash.msw(coord);
int z = LongHash.lsw(coord);
try
{
Object[] data = loader.loadChunk(worldServer, x, z);
if (data != null)
{
NBTTagCompound compound = (NBTTagCompound) data[1];
net.minecraft.server.v1_8_R3.Chunk chunk = (net.minecraft.server.v1_8_R3.Chunk) data[0];
loaded.put(coord, chunk);
compounds.put(coord, compound);
}
else
{
System.out.println("Failed to load chunk " + x + "," + z);
}
}
catch (Throwable t)
{
t.printStackTrace();
}
finally
{
_actual.getAndIncrement();
}
});
}
chunkLoaders.shutdown();
// We've got plenty of time to wait
System.out.println("Finished submitting tasks to executor, waiting...");
chunkLoaders.awaitTermination(1, TimeUnit.DAYS);
System.out.println("Loaded: " + loaded.size() + " and coords: " + coordPairs.size());
coordPairs.clear();
}
// Step 2: Recreate structures, update neighbors, load entities
// This step should be super quick so there's no point in scheduling it elsewhere
// Code is plain copypasted from ChunkIOProvider
{
for (net.minecraft.server.v1_8_R3.Chunk chunk : loaded.values())
{
NBTTagCompound compound = compounds.get(LongHash.toLong(chunk.locX, chunk.locZ));
loader.loadEntities(chunk, compound.getCompound("Level"), worldServer);
chunk.setLastSaved(chunkProviderServer.world.getTime());
if (chunkProviderServer.chunkProvider != null)
{
chunkProviderServer.chunkProvider.recreateStructures(chunk, chunk.locX, chunk.locZ);
}
for (int x = -2; x < 3; ++x)
{
for (int z = -2; z < 3; ++z)
{
if (x != 0 || z != 0)
{
net.minecraft.server.v1_8_R3.Chunk neighbor = loaded.get(LongHash.toLong(chunk.locX + x, chunk.locZ + z));
if (neighbor != null)
{
neighbor.setNeighborLoaded(-x, -z);
chunk.setNeighborLoaded(x, z);
}
}
}
}
_actual.getAndIncrement();
}
}
AtomicBoolean lockCompleted = new AtomicBoolean(false);
Object lock = new Object();
// Hop back onto the main thread
_game.getArcadeManager().runSync(() ->
{
// We want to add all the chunks to the chunkmap so that the server is not out of sync
for (Map.Entry<Long, net.minecraft.server.v1_8_R3.Chunk> ent : loaded.entrySet())
{
ent.getValue().addEntities();
chunkProviderServer.chunks.put(ent.getKey(), ent.getValue());
ChunkLoadEvent event = new ChunkLoadEvent(ent.getValue().bukkitChunk, true);
UtilServer.CallEvent(event);
}
lockCompleted.set(true);
synchronized (lock)
{
lock.notifyAll();
}
});
if (!lockCompleted.get())
{
synchronized (lock)
{
lock.wait();
}
}
if (!lockCompleted.get())
{
throw new IllegalStateException("Lock was not completed");
}
// Step 3: Decorate the chunks. This step must be performed async as otherwise the server lags way too hard
// Notes: Do not allow the server to tick the world. If this is allowed EntityTracker will raise CME
// NextTickList will also raise errors
// And worst case the server will crash
{
// Live life on the edge
AsyncCatcher.enabled = false;
_isDecorating = true;
int ct = 0;
for (net.minecraft.server.v1_8_R3.Chunk chunk : loaded.values())
{
chunk.loadNearby(chunkProviderServer, chunkProviderServer, chunk.locX, chunk.locZ);
ct++;
if (ct % 100 == 0)
{
System.out.println(ct);
}
_actual.getAndIncrement();
}
TimingManager.stop("UHC Chunk Loading");
_isDecorating = false;
AsyncCatcher.enabled = true;
System.out.println("Expected: " + _expected.get() + ", actual: " + _actual.get());
_game.getArcadeManager().runSync(() ->
{
for (Chunk chunk : chunkProviderServer.chunks.values())
{
// Clear
for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) {
if (x == 0 && z == 0) {
continue;
}
chunk.setNeighborUnloaded(x, z);
}
}
}
for (Chunk chunk : chunkProviderServer.chunks.values())
{
// Refresh
for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) {
if (x == 0 && z == 0) {
continue;
}
Chunk neighbor = chunkProviderServer.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
if (neighbor != null) {
neighbor.setNeighborLoaded(-x, -z);
chunk.setNeighborLoaded(x, z);
}
}
}
}
for (net.minecraft.server.v1_8_R3.Entity entity : _entities)
{
entity.dead = false;
worldServer.addEntity(entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN);
}
_entities.clear();
// You may tick again
worldServer.getMinecraftServer().worlds.add(worldServer);
// Well, if they're not equal, not much we can do. We've hit the end
_actual.set(_expected.get());
});
}
loaded.clear();
compounds.clear();
UtilServer.Unregister(this);
}
catch (Throwable t)
{
t.printStackTrace();
}
}
@EventHandler
public void on(EntitySpawnEvent event)
{
// Don't allow entity spawns while decorating, period
if (_isDecorating)
{
if (event.getLocation().getWorld().getUID() == _game.WorldData.World.getUID())
{
_entities.add(((CraftEntity) event.getEntity()).getHandle());
event.setCancelled(true);
}
}
}
public void flagDone()
{
_actual.set(_expected.get());
}
public boolean isDone()
{
return _actual.get() == _expected.get();
}
public int getPercentageComplete()
{
return UtilMath.clamp((int) ((_actual.get() * 1.0 / _expected.get()) * 100), 0, 100);
}
public String getProgress()
{
return getPercentageComplete() + "%";
}
public void flagStop()
{
this.interrupt();
}
}

View File

@ -0,0 +1,239 @@
package nautilus.game.arcade.game.games.uhc.helpers;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.timing.TimingManager;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.uhc.UHC;
import net.minecraft.server.v1_8_R3.BiomeCache;
import net.minecraft.server.v1_8_R3.ChunkProviderServer;
import net.minecraft.server.v1_8_R3.FileIOThread;
import net.minecraft.server.v1_8_R3.IChunkProvider;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.WorldChunkManager;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class WorldGenThread extends Thread
{
private UHC _game;
private volatile boolean _mapLoaded = false;
private volatile int _chunksPerTick = 1;
private volatile boolean _stopGen = false;
private int _chunkTotal;
private int _chunkX = 0;
private int _chunkZ = 0;
private int _chunksLoaded = 0;
private int _currentBorder = 1000;
public WorldGenThread(UHC game)
{
super("WorldGen Thread");
this._game = game;
_chunkX = (int) -(_currentBorder / 16);
_chunkZ = (int) -(_currentBorder / 16);
_chunkTotal = (int) ((_currentBorder * 2 / 16) * (_currentBorder * 2 / 16));
}
public void run()
{
try
{
Field fileIOThreadB = FileIOThread.class.getDeclaredField("b");
fileIOThreadB.setAccessible(true);
// This list is the list of chunks to be saved on the File IO Thread
List list = (List) fileIOThreadB.get(FileIOThread.a());
net.minecraft.server.v1_8_R3.WorldServer worldServer = ((CraftWorld) _game.WorldData.World).getHandle();
WorldChunkManager manager = worldServer.getWorldChunkManager();
Field biomeCacheField = manager.getClass().getDeclaredField("d");
biomeCacheField.setAccessible(true);
// A thread safe BiomeCache
// The implementation is literally a copy/paste from the original BiomeCache, but with some synchronization
// Reason being while the server is ticking the world (for some reason, if you want to dig through the entire Arcade codebase go for it)
// it stores stuff in the BiomeCache, and chunk gen needs that BiomeCache info too
// Causing desynchronization in the cache
biomeCacheField.set(manager, new BiomeCache(manager)
{
private final Object _lock = new Object();
private long _lastCleanTime; // b -> _lastCleanTime
private Map<Long, BiomeCacheBlock> _blockByCoord = new HashMap<>(); // LongHashMap -> HashMap, c -> _blockByCoord
private List<BiomeCache.BiomeCacheBlock> _blocks = new ArrayList<>(); // d -> _blocks
@Override
public BiomeCache.BiomeCacheBlock a(int x, int z)
{
x >>= 4;
z >>= 4;
long var3 = hash(x, z);
BiomeCache.BiomeCacheBlock var5 = this._blockByCoord.get(var3);
if (var5 == null)
{
var5 = new BiomeCache.BiomeCacheBlock(x, z);
synchronized (_lock)
{
this._blockByCoord.put(var3, var5);
this._blocks.add(var5);
}
}
var5.e = MinecraftServer.az();
return var5;
}
@Override
public void a()
{
long currentTime = MinecraftServer.az();
long deltaTime = currentTime - this._lastCleanTime;
if (deltaTime > 7500L || deltaTime < 0L)
{
this._lastCleanTime = currentTime;
synchronized (_lock)
{
for (int i = 0; i < this._blocks.size(); ++i)
{
BiomeCache.BiomeCacheBlock biomeCacheBlock = (BiomeCache.BiomeCacheBlock) this._blocks.get(i);
long var7 = currentTime - biomeCacheBlock.e;
if (var7 > 30000L || var7 < 0L)
{
this._blocks.remove(i--);
this._blockByCoord.remove(hash(biomeCacheBlock.c, biomeCacheBlock.d));
}
}
}
}
}
private long hash(int x, int z)
{
return (long) x & 4294967295L | ((long) z & 4294967295L) << 32;
}
});
ChunkProviderServer cps = worldServer.chunkProviderServer;
IChunkProvider icp = cps.chunkProvider;
System.out.println("Using chunk provider " + icp.getClass());
TimingManager.start("Map Generation");
long start = System.currentTimeMillis();
long last = start;
while (!_stopGen)
{
long now = System.currentTimeMillis();
if ((now - last) >= 10 * 1000)
{
_game.Announce(C.cGreen + C.Bold + "Generating Map: " + C.cWhite + getMapLoadETA() + " Remaining...", false);
last = now;
}
long hash = LongHash.toLong(_chunkX, _chunkZ);
// This is just a shortcut to how the Minecraft server would have generated a chunk if it doesn't exist.
// This should always create a chunk because we're not loading any chunks beforehand...
// /me looks at new maintainer
net.minecraft.server.v1_8_R3.Chunk chunk = icp.getOrCreateChunk(_chunkX, _chunkZ);
// Run the copypasted code for chunk saving.
cps.saveChunk(chunk);
cps.saveChunkNOP(chunk);
cps.unloadQueue.remove(_chunkX, _chunkZ);
cps.chunks.remove(hash);
if (_chunkX < _currentBorder / 16)
{
_chunkX++;
}
else if (_chunkZ < _currentBorder / 16)
{
_chunkX = (int) -(_currentBorder / 16);
_chunkZ++;
}
else
{
_mapLoaded = true;
System.out.println("Map Loading Finished! Took " + TimeUnit.MILLISECONDS.toSeconds(now - start) + " seconds");
break;
}
_chunksLoaded++;
_chunksPerTick = (int) (_chunksLoaded / ((now - start) / 50.0));
}
TimingManager.stop("Map Generation");
if (_stopGen)
{
return;
}
TimingManager.start("Map Saving");
// Wait for all the chunks to save (but do we need this?)
while (!list.isEmpty())
{
Thread.sleep(100);
}
TimingManager.stop("Map Saving");
_game.getArcadeManager().runSync(_game::generateSpawns);
}
catch (Throwable t)
{
// todo proper exception handling
// maybe force shutdown?
t.printStackTrace();
}
}
public void flagStop()
{
this._stopGen = true;
}
public String getMapLoadETA()
{
int chunksToGo = _chunkTotal - _chunksLoaded;
return UtilTime.MakeStr((long) ((double) chunksToGo / (double) (_chunksPerTick * 20) * 1000d), 1);
}
public boolean isMapLoaded()
{
return this._mapLoaded;
}
public int getPercentageComplete()
{
return UtilMath.clamp((int) ((_chunksLoaded * 1.0 / _chunkTotal) * 100), 0, 100);
}
public String getProgress()
{
return getPercentageComplete() + "%";
}
}

View File

@ -634,6 +634,11 @@ public class WitherGame extends TeamGame implements IBlockRestorer
speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006;
}
if (speed < 0.01) //This is to stop players having negative speed when they go under the map
{
speed = 0.01;
}
player.setFlySpeed((float) Math.min(1, speed));
// Bump

View File

@ -0,0 +1,29 @@
package nautilus.game.arcade.game.modules;
import nautilus.game.arcade.game.Game;
import org.bukkit.event.Listener;
public abstract class Module implements Listener
{
// The game this module belongs to
private Game _game;
public void initialize(Game game)
{
if (_game != null)
{
throw new IllegalArgumentException("Attempting to initialize module which has already been initialized for " + _game);
}
this._game = game;
}
public void cleanup()
{
}
public Game getGame()
{
return this._game;
}
}

View File

@ -0,0 +1,164 @@
package nautilus.game.arcade.game.modules;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.UUID;
public class TeamModule extends Module
{
private BiMap<UUID, UUID> _teamReqs = HashBiMap.create();
@EventHandler(priority = EventPriority.HIGH)
public void teamSelectInteract(PlayerInteractEntityEvent event)
{
if (getGame().GetState() != Game.GameState.Recruit)
return;
if (event.getRightClicked() == null)
return;
if (!(event.getRightClicked() instanceof Player))
return;
Player player = event.getPlayer();
//Observer
if (getGame().getArcadeManager().IsObserver(player))
{
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
return;
}
selectTeamMate(player, (Player) event.getRightClicked());
}
@EventHandler
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().toLowerCase().startsWith("/team "))
return;
event.setCancelled(true);
if (getGame().GetState() != Game.GameState.Recruit)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot send team requests while the game is live"));
return;
}
//Observer
if (getGame().getArcadeManager().IsObserver(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
return;
}
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
if (target == null)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "That player is not online"));
return;
}
if (event.getPlayer().equals(target))
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You can't team with yourself!"));
return;
}
selectTeamMate(event.getPlayer(), target);
}
private void selectTeamMate(Player player, Player ally)
{
//Accept Invite
if (_teamReqs.containsKey(ally.getUniqueId()) && _teamReqs.get(ally.getUniqueId()).equals(player.getUniqueId()))
{
//Remove Prefs
_teamReqs.remove(player.getUniqueId());
_teamReqs.remove(ally.getUniqueId());
//Inform
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
//Leave Old Teams
if (getGame().GetTeam(player) != null)
getGame().GetTeam(player).DisbandTeam();
if (getGame().GetTeam(ally) != null)
getGame().GetTeam(ally).DisbandTeam();
//Get Team
GameTeam team = getEmptyTeam();
if (team == null)
return;
team.setDisplayName(player.getName() + " & " + ally.getName());
//Join Team
getGame().SetPlayerTeam(player, team, true);
getGame().SetPlayerTeam(ally, team, true);
}
//Send Invite
else
{
//Already on Team with Target
if (getGame().GetTeam(player) != null)
if (getGame().GetTeam(player).HasPlayer(ally))
return;
//Inform Player
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
//Inform Target
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
{
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
}
//Add Pref
_teamReqs.put(player.getUniqueId(), ally.getUniqueId());
}
}
@EventHandler
public void teamQuit(PlayerQuitEvent event)
{
if (getGame().GetState() != Game.GameState.Recruit)
return;
Player player = event.getPlayer();
if (getGame().GetTeam(player) != null)
getGame().GetTeam(player).DisbandTeam();
_teamReqs.remove(player.getUniqueId());
_teamReqs.inverse().remove(player.getUniqueId());
}
private GameTeam getEmptyTeam()
{
for (GameTeam team : getGame().GetTeamList())
{
if (team.GetPlayers(false).isEmpty())
return team;
}
return null;
}
}

View File

@ -44,7 +44,12 @@ public abstract class PlayerPage extends BasePage
players = new ArrayList<>();
for (String s : _players)
{
players.add(Bukkit.getPlayer(s));
Player player = Bukkit.getPlayer(s);
if (!_plugin.isVanished(player))
{
players.add(player);
}
}
}
else
@ -56,7 +61,7 @@ public abstract class PlayerPage extends BasePage
int slot = 9;
for (Player player : players)
{
if (showPlayer(player))
if (showPlayer(player) && !_plugin.isVanished(player))
{
ItemStack head = getPlayerHead(player.getName(), C.cGreen + C.Bold + player.getName(), new String[]{ ChatColor.RESET + C.cGray + getDisplayString(player) });
addButton(slot, head, new Button(slot, player));

View File

@ -41,18 +41,7 @@ public class SpectatorButton implements IButton
if(clickType == ClickType.RIGHT)
{
_player.closeInventory();
_player.teleport(_target.getLocation().add(0, 1, 0));
_arcadeManager.runSyncLater(new Runnable()
{
@Override
public void run()
{
_player.setGameMode(GameMode.SPECTATOR);
_player.setSpectatorTarget(_target);
UtilTextBottom.display(C.cYellow + "You are spectating " + F.game(_target.getName()), player);
UtilPlayer.message(_player, F.main("Game", "Sneak to stop spectating"));
}
}, 3);
_arcadeManager.getGameSpectatorManager().setSpectating(_player, _target);
}
else
{

View File

@ -30,6 +30,7 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk;
public class PerkBoneRush extends SmashPerk implements IThrown
@ -151,6 +152,18 @@ public class PerkBoneRush extends SmashPerk implements IThrown
double damage = 0.7;
String reason = GetName();
if (Manager.GetGame() instanceof TeamSuperSmash && target instanceof Player && data.getThrower() instanceof Player)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
Player targetPlayer = (Player) target;
Player throwerPlayer = (Player) data.getThrower();
if(smash.GetTeam(targetPlayer).equals(smash.GetTeam(throwerPlayer)))
{
return;
}
}
if (isSuperActive(damager))
{
damage = 3;

View File

@ -39,10 +39,7 @@ public class PerkCreeperElectricity extends Perk
if (event.IsCancelled())
return;
if (event.GetCause() == DamageCause.ENTITY_ATTACK)
return;
if (event.GetCause() == DamageCause.FIRE_TICK)
if (event.GetCause() == DamageCause.ENTITY_ATTACK || event.GetCause() == DamageCause.FIRE_TICK || event.GetCause() == DamageCause.STARVATION)
return;
Player damagee = event.GetDamageePlayer();

View File

@ -21,8 +21,10 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.SmashPerk;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -165,6 +167,15 @@ public class PerkCreeperExplode extends SmashPerk
if (UtilMath.offset(player.getLocation(), spawn) < 14)
spawnIterator.remove();
}
//If all spawns have been destroyed revert to using the spectator spawn
for (GameTeam team : Manager.GetGame().GetTeamList())
{
if (team.GetSpawns().isEmpty())
{
team.GetSpawns().add(Manager.GetGame().GetSpectatorLocation());
}
}
}
//Damage

View File

@ -3,11 +3,8 @@ package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Color;
import org.bukkit.EntityEffect;
import org.bukkit.FireworkEffect;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
@ -19,7 +16,6 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
@ -30,7 +26,6 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.SmashPerk;
import nautilus.game.arcade.kit.perks.data.FireflyData;
@ -93,7 +88,7 @@ public class PerkFirefly extends SmashPerk
if (event.getType() != UpdateType.TICK)
return;
_tick = (_tick + 1)%1000;
_tick++;
Iterator<FireflyData> dataIterator = _data.iterator();
@ -148,7 +143,7 @@ public class PerkFirefly extends SmashPerk
other.playEffect(EntityEffect.HURT);
if (_tick == 0)
if (_tick % 12 == 0)
{
if (Recharge.Instance.use(other, GetName() + " hit by " + data.Player.getName(), 2000, false, false))
{

View File

@ -20,7 +20,8 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk;
public class PerkInferno extends SmashPerk
@ -119,4 +120,23 @@ public class PerkInferno extends SmashPerk
}
}
@EventHandler
public void onCustomDamage(CustomDamageEvent event)
{
if (Manager.GetGame() instanceof TeamSuperSmash)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
if (event.GetDamagerPlayer(true) == null)
{
return;
}
if (smash.GetTeam(event.GetDamagerPlayer(true)).equals(smash.GetTeam(event.GetDamageePlayer())))
{
event.GetDamageeEntity().setFireTicks(0);
event.SetCancelled("Team Damage");
}
}
}
}

View File

@ -14,6 +14,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
@ -74,7 +75,7 @@ public class PerkLeap extends Perk
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
if (!UtilItem.isAxe(event.getPlayer().getItemInHand()))
return;
Player player = event.getPlayer();
@ -96,7 +97,7 @@ public class PerkLeap extends Perk
}
//Energy
if (!Recharge.Instance.use(player, _name, _recharge, true, true))
if (!Recharge.Instance.use(player, _name, _recharge, false, true))
return;
//Use Use

View File

@ -13,8 +13,6 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
@ -22,6 +20,7 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk;
import nautilus.game.arcade.kit.perks.data.NightLivingDeadData;
@ -126,6 +125,16 @@ public class PerkNightLivingDead extends SmashPerk
{
if (data.Zombies.contains(event.getEntity()))
{
if (Manager.GetGame() instanceof TeamSuperSmash && event.getTarget() instanceof Player)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
Player targetPlayer = (Player) event.getTarget();
if (smash.GetTeam(data.Player).equals(smash.GetTeam(targetPlayer)))
{
event.setCancelled(true);
}
}
if (data.Player.equals(event.getTarget()))
{
event.setCancelled(true);

View File

@ -33,6 +33,7 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk;
public class PerkPigBaconBounce extends SmashPerk implements IThrown
@ -109,6 +110,18 @@ public class PerkPigBaconBounce extends SmashPerk implements IThrown
if (target == null)
return;
if (Manager.GetGame() instanceof TeamSuperSmash && target instanceof Player && data.getThrower() instanceof Player)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
Player targetPlayer = (Player) target;
Player throwerPlayer = (Player) data.getThrower();
if(smash.GetTeam(targetPlayer).equals(smash.GetTeam(throwerPlayer)))
{
return;
}
}
//Damage Event
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null,
DamageCause.CUSTOM, 4, true, true, false,

View File

@ -33,6 +33,7 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk;
public class PerkSlimeRocket extends SmashPerk implements IThrown
@ -208,6 +209,17 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown
if (!_owner.containsKey(event.getEntity()))
return;
if (Manager.GetGame() instanceof TeamSuperSmash && event.getTarget() instanceof Player)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
Player targetPlayer = (Player) event.getTarget();
if (smash.GetTeam(_owner.get(event.getEntity())).equals(smash.GetTeam(targetPlayer)))
{
event.setCancelled(true);
}
}
if (_owner.get(event.getEntity()).equals(event.getTarget()))
{
event.setCancelled(true);
@ -225,6 +237,18 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown
Slime slime = (Slime)data.getThrown();
if (Manager.GetGame() instanceof TeamSuperSmash && target instanceof Player && data.getThrower() instanceof Player)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
Player targetPlayer = (Player) target;
Player throwerPlayer = (Player) data.getThrower();
if(smash.GetTeam(targetPlayer).equals(smash.GetTeam(throwerPlayer)))
{
return;
}
}
//Damage Event
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null,
DamageCause.PROJECTILE, 3 + slime.getSize() * 3, true, true, false,
@ -275,6 +299,16 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown
//if (owner != null)
// event.SetDamager(owner); This gives knockback from wrong direction :(
if (Manager.GetGame() instanceof TeamSuperSmash)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
if (smash.GetTeam(owner).equals(smash.GetTeam(event.GetDamageePlayer())))
{
event.SetCancelled("Team Damage");
return;
}
}
if (owner != null && owner.equals(event.GetDamageeEntity()))
{

View File

@ -2,6 +2,17 @@ package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk;
import org.bukkit.Location;
import org.bukkit.Material;
@ -17,20 +28,10 @@ import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.SmashPerk;
public class PerkWitherImage extends SmashPerk
{
private HashMap<Player, Skeleton> _images = new HashMap<Player, Skeleton>();
private HashMap<Player, Skeleton> _ownerToSkeleton = new HashMap<Player, Skeleton>();
private HashMap<Skeleton, Player> _skeletonToOwner = new HashMap<Skeleton, Player>();
public PerkWitherImage()
{
@ -67,7 +68,7 @@ public class PerkWitherImage extends SmashPerk
if (!Kit.HasKit(player))
return;
if (!_images.containsKey(player))
if (!_ownerToSkeleton.containsKey(player))
{
if (!Recharge.Instance.use(player, GetName(), 12000, true, true))
return;
@ -94,7 +95,8 @@ public class PerkWitherImage extends SmashPerk
UtilAction.velocity(skel, player.getLocation().getDirection(), 1.6, false, 0, 0.2, 10, true);
_images.put(player, skel);
_ownerToSkeleton.put(player, skel);
_skeletonToOwner.put(skel, player);
Recharge.Instance.use(player, "Wither Swap", 500, false, false);
@ -109,7 +111,7 @@ public class PerkWitherImage extends SmashPerk
if (!Recharge.Instance.use(player, "Wither Swap", 2000, true, false))
return;
Skeleton skel = _images.get(player);
Skeleton skel = _ownerToSkeleton.get(player);
Location loc = skel.getLocation();
skel.teleport(player.getLocation());
@ -126,10 +128,24 @@ public class PerkWitherImage extends SmashPerk
@EventHandler
public void entityTarget(EntityTargetEvent event)
{
if (_images.containsKey(event.getTarget()))
if (_images.get(event.getTarget()).equals(event.getEntity()))
if (_skeletonToOwner.containsKey(event.getEntity()))
{
if (Manager.GetGame() instanceof TeamSuperSmash && event.getTarget() instanceof Player)
{
TeamSuperSmash smash = (TeamSuperSmash) Manager.GetGame();
Player targetPlayer = (Player) event.getTarget();
if(smash.GetTeam(_skeletonToOwner.get(event.getEntity())).equals(smash.GetTeam(targetPlayer)))
{
event.setCancelled(true);
}
}
if (_ownerToSkeleton.get(event.getTarget()).equals(event.getEntity()))
{
event.setCancelled(true);
}
}
}
@EventHandler
public void damage(CustomDamageEvent event)
@ -137,13 +153,13 @@ public class PerkWitherImage extends SmashPerk
Player damagee = event.GetDamageePlayer();
if (damagee == null) return;
if (!_images.containsKey(damagee))
if (!_ownerToSkeleton.containsKey(damagee.getUniqueId()))
return;
LivingEntity damager = event.GetDamagerEntity(false);
if (damager == null) return;
if (_images.get(damagee).equals(damager))
if (_ownerToSkeleton.get(damagee.getUniqueId()).equals(damager))
event.SetCancelled("Wither Image");
}
@ -153,12 +169,12 @@ public class PerkWitherImage extends SmashPerk
LivingEntity damager = event.GetDamagerEntity(true);
if (damager == null) return;
if (!_images.containsValue(damager))
if (!_ownerToSkeleton.containsValue(damager))
return;
for (Player player : _images.keySet())
for (Player player : _ownerToSkeleton.keySet())
{
if (_images.get(player).equals(damager))
if (_ownerToSkeleton.get(player).equals(damager))
{
event.SetDamager(player);
event.setKnockbackOrigin(damager.getLocation());
@ -173,12 +189,12 @@ public class PerkWitherImage extends SmashPerk
if (event.getType() != UpdateType.FAST)
return;
Iterator<Player> playerIterator = _images.keySet().iterator();
Iterator<Player> playerIterator = _ownerToSkeleton.keySet().iterator();
while (playerIterator.hasNext())
{
Player player = playerIterator.next();
Skeleton skel = _images.get(player);
Skeleton skel = _ownerToSkeleton.get(player);
if (!player.isValid() || !skel.isValid() || skel.getTicksLived() > 160)
{
@ -195,7 +211,8 @@ public class PerkWitherImage extends SmashPerk
@EventHandler(priority = EventPriority.LOWEST)
public void clean(PlayerDeathEvent event)
{
Skeleton skel = _images.remove(event.getEntity());
Skeleton skel = _ownerToSkeleton.remove(event.getEntity());
_skeletonToOwner.remove(skel);
if (skel != null)
{

View File

@ -105,6 +105,7 @@ public class GameCreationManager implements Listener
{
Game game = gameIterator.next();
game.cleanupModules();
game.disable();
HandlerList.unregisterAll(game);

View File

@ -948,7 +948,8 @@ public class GameLobbyManager implements Listener
public void Combust(EntityCombustEvent event)
{
for (LobbyEnt ent : _kits.values())
if (event.getEntity().equals(ent.GetEnt()))
if (event.getEntity().getWorld().getUID().equals(ent.GetEnt().getWorld().getUID()) &&
event.getEntity().equals(ent.GetEnt()))
{
event.setCancelled(true);
return;

View File

@ -1,8 +1,22 @@
package nautilus.game.arcade.managers;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.NetworkManager;
import net.minecraft.server.v1_8_R3.PacketPlayOutCamera;
import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.WorldSettings;
import org.bukkit.GameMode;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -10,6 +24,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
@ -26,8 +41,10 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
public class GameSpectatorManager implements Listener
public class GameSpectatorManager implements Listener, IPacketHandler
{
private Set<UUID> _pendingSpectate = Collections.synchronizedSet(new HashSet<>());
ArcadeManager Manager;
public GameSpectatorManager(ArcadeManager manager)
@ -35,6 +52,8 @@ public class GameSpectatorManager implements Listener
Manager = manager;
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
Manager.getPacketHandler().addPacketHandler(this, PacketHandler.ListenerPriority.HIGH, PacketPlayOutNamedEntitySpawn.class);
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
@ -214,38 +233,50 @@ public class GameSpectatorManager implements Listener
}
}
private void setSpectating(Player player, Entity target)
{
player.setGameMode(GameMode.SURVIVAL);
player.teleport(target.getLocation().add(0, 1, 0));
player.getInventory().setHeldItemSlot(5);
Manager.runSyncLater(new Runnable()
{
@Override
public void run()
public void setSpectating(Player player, Entity target)
{
if (Manager.GetGame().IsAlive(player))
return;
Player ptarget = null;
if (target instanceof Player)
ptarget = (Player) target;
if (ptarget != null)
{
if (!Manager.GetGame().IsAlive(ptarget))
return;
}
Player playerTarget = null;
if (target instanceof Player)
{
playerTarget = (Player) target;
if (!Manager.GetGame().IsAlive(playerTarget))
{
return;
}
}
_pendingSpectate.add(target.getUniqueId());
player.teleport(target.getLocation().add(0, 1, 0));
// If the player already has the entity loaded, we have to set it now
// todo
// In the future, we could do some really cool stuff where we listen to all incoming and outgoing
// spawn/destroy packets and track whether the client has loaded the entity in memory
// However, that approach has the risk of desynchronization at which point we're screwed
player.setGameMode(GameMode.SPECTATOR);
player.setSpectatorTarget(target);
if (ptarget != null)
UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(Manager.GetGame().GetTeam(ptarget).GetColor() + ptarget.getName()) + ".", player);
if (playerTarget != null)
UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(Manager.GetGame().GetTeam(playerTarget).GetColor() + playerTarget.getName()) + ".", player);
UtilPlayer.message(player, F.main("Game", "Sneak to stop spectating."));
}
}, 1);
// And if the player did have the entity loaded, we also need to clean up after ourselves
// 20 ticks should be more than enough time considering we're just waiting for the server to attempt to
// send the packet
// and even if the server was lagging, the scheduler should be lagging too
Manager.runSyncLater(() ->
{
_pendingSpectate.remove(target.getUniqueId());
}, 20L);
}
@EventHandler(priority = EventPriority.LOW)
@ -262,4 +293,51 @@ public class GameSpectatorManager implements Listener
if (!Manager.GetGame().IsAlive(player))
event.setCancelled(true);
}
@Override
public void handle(PacketInfo packetInfo)
{
if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn)
{
PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket();
if (_pendingSpectate.remove(packet.b))
{
// Handle Minestrike spam race condition
if (Manager.GetGame().IsAlive(packetInfo.getPlayer()))
{
return;
}
packetInfo.setCancelled(true);
EntityPlayer ep = ((CraftPlayer) packetInfo.getPlayer()).getHandle();
NetworkManager manager = ep.playerConnection.networkManager;
manager.a(packet, future ->
{
Manager.runSync(() ->
{
PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(packetInfo.getPlayer(), GameMode.SPECTATOR);
UtilServer.CallEvent(event);
if(event.isCancelled()) {
return;
}
ep.playerInteractManager.setGameMode(WorldSettings.EnumGamemode.getById(GameMode.SPECTATOR.getValue()));
ep.fallDistance = 0.0F;
manager.a(new PacketPlayOutCamera(ep), future1 ->
{
manager.a(new PacketPlayOutGameStateChange(3, (float)GameMode.SPECTATOR.getValue()), future2 ->
{
PacketPlayOutCamera p1 = new PacketPlayOutCamera();
p1.a = packet.a;
manager.handle(p1);
});
});
});
});
}
}
}
}

View File

@ -74,9 +74,15 @@ public class WinEffectManager
public WinEffectGadget getWinEffect()
{
GadgetManager manager = _game.getArcadeManager().getCosmeticManager().getGadgetManager();
Gadget gadget = manager.getActive(_winner, GadgetType.WIN_EFFECT);
if(gadget == null) gadget = manager.getGadget(WinEffectPodium.class);
return (WinEffectGadget) gadget;
Gadget winEffect = manager.getGadget(WinEffectPodium.class);
for (Gadget gadget : manager.getGadgets(GadgetType.WIN_EFFECT))
{
if (gadget.isActive(_winner))
{
winEffect = gadget;
}
}
return (WinEffectGadget) winEffect;
}
}