Merge branch 'develop' of github.com:Mineplex-LLC/Minecraft-PC into update/clans

This commit is contained in:
AlexTheCoder 2016-07-11 14:50:16 -04:00
commit d3270b9289
100 changed files with 2606 additions and 1511 deletions

View File

@ -8,51 +8,51 @@ import org.bukkit.inventory.ItemStack;
public enum CountryFlag public enum CountryFlag
{ {
Brazil(DyeColor.GREEN, new Pattern(DyeColor.YELLOW, PatternType.RHOMBUS_MIDDLE), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), 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)), 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), CANADA(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
new Pattern(DyeColor.RED, PatternType.CIRCLE_MIDDLE)), 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)), 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)), 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)), 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)), 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), 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)), 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)), new Pattern(DyeColor.YELLOW, PatternType.CROSS)),
Italy(DyeColor.WHITE, 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), SENEGAL(DyeColor.YELLOW, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM),
new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)), new Pattern(DyeColor.GREEN, PatternType.CIRCLE_MIDDLE)),
France(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRIPE_TOP), new Pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM)), 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), INDIA(DyeColor.WHITE, new Pattern(DyeColor.ORANGE, PatternType.STRIPE_LEFT), new Pattern(DyeColor.GREEN, PatternType.STRIPE_RIGHT),
new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)), new Pattern(DyeColor.BLUE, PatternType.CIRCLE_MIDDLE)),
Belgium(DyeColor.YELLOW, new Pattern(DyeColor.BLACK, PatternType.STRIPE_BOTTOM), new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), 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)), ENGLAND(DyeColor.WHITE, new Pattern(DyeColor.RED, PatternType.STRAIGHT_CROSS)),
Austria(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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)), 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), SWITZERLAND(DyeColor.RED, new Pattern(DyeColor.WHITE, PatternType.STRAIGHT_CROSS), new Pattern(DyeColor.RED, PatternType.STRIPE_BOTTOM),
new Pattern(DyeColor.RED, PatternType.STRIPE_TOP)), 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)), 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)), 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 DyeColor _baseColor;
private Pattern[] _patterns; private Pattern[] _patterns;

View File

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

View File

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

View File

@ -71,7 +71,7 @@ public class YoutubeButton implements GuiItem
message = "Click here to visit our YouTube page!"; 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 @Override

View File

@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.boosters.command.BoosterCommand; import mineplex.core.boosters.command.BoosterCommand;
import mineplex.core.boosters.event.BoosterActivateEvent; import mineplex.core.boosters.event.BoosterActivateEvent;
import mineplex.core.boosters.event.BoosterExpireEvent; import mineplex.core.boosters.event.BoosterExpireEvent;
import mineplex.core.boosters.event.BoosterItemGiveEvent;
import mineplex.core.boosters.event.BoosterUpdateEvent; import mineplex.core.boosters.event.BoosterUpdateEvent;
import mineplex.core.boosters.gui.BoosterShop; import mineplex.core.boosters.gui.BoosterShop;
import mineplex.core.boosters.redis.BoosterUpdateRepository; 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.Callback;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory; 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)) 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); player.getInventory().setItem(INTERFACE_SLOT, INTERFACE_ITEM);
UtilInv.Update(player); 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 @Override
protected PlayerTipData AddPlayer(String player) protected PlayerTipData addPlayer(String player)
{ {
return new PlayerTipData(); 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 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), _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); 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(); _gadgetManager.disableAll();
_mountManager.DisableAll(); _mountManager.DisableAll();
_petManager.DisableAll(); _petManager.disableAll();
} }
public void setHideParticles(boolean b) public void setHideParticles(boolean b)

View File

@ -8,7 +8,7 @@ public class PetSorter implements Comparator<Pet>
{ {
public int compare(Pet a, Pet b) 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;
return 1; return 1;

View File

@ -23,7 +23,7 @@ public class ActivatePetButton implements IButton
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)
{ {
_page.playAcceptSound(player); _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)); _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) public void onClick(Player player, ClickType clickType)
{ {
_page.playAcceptSound(player); _page.playAcceptSound(player);
_petManager.RemovePet(player, true); _petManager.removePet(player, true);
_page.refresh(); _page.refresh();
} }
} }

View File

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

View File

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

View File

@ -100,7 +100,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer()); Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer());
for (Mount<?> mount : getPlugin().getMountManager().getMounts()) 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++; mountOwned++;
} }
@ -110,17 +110,17 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
int petOwned = 0; int petOwned = 0;
int petMax = 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(); NautHashMap<EntityType, String> pets = getPlugin().getPetManager().Get(getPlayer()).getPets();
if (pets != null && pets.containsKey(pet.GetPetType())) if (pets != null && pets.containsKey(pet.getPetType()))
{ {
petOwned++; petOwned++;
} }
petMax++; petMax++;
} }
Creature petActive = getPlugin().getPetManager().GetPet(getPlayer()); Creature petActive = getPlugin().getPetManager().getPet(getPlayer());
GadgetType type = GadgetType.PARTICLE; 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)); 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; 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()); 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() + "!"); itemLore.add(C.cGray + "Your very own " + pet.getName() + "!");
//Chest Unlocks //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) if (pet.getCost(CurrencyType.TREASURE_SHARD) == -1)
{ {
@ -113,21 +113,21 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
} }
//Owned //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) if (petName == null)
{ {
petName = pet.getName(); 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.cBlack);
itemLore.add(C.cGreen + "Click to Disable"); itemLore.add(C.cGreen + "Click to Disable");
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.GetPetType().getTypeId(), addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(),
pet.GetPetName() + " (" + C.cWhite + petName + C.cGreen + ")", pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager())); itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager()));
addGlow(slot); addGlow(slot);
@ -137,8 +137,8 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack); itemLore.add(C.cBlack);
itemLore.add(C.cGreen + "Click to Enable"); itemLore.add(C.cGreen + "Click to Enable");
addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.GetPetType().getTypeId(), addButton(slot, new ShopItem(Material.MONSTER_EGG, (byte) pet.getPetType().getTypeId(),
pet.GetPetName() + " (" + C.cWhite + petName + C.cGreen + ")", pet.getPetName() + " (" + C.cWhite + petName + C.cGreen + ")",
itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this)); 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.cBlack);
itemLore.add(C.cGreen + "Click to Purchase"); 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) else if (pet.getCost(CurrencyType.TREASURE_SHARD) > 0)
{ {
itemLore.add(C.cBlack); itemLore.add(C.cBlack);
itemLore.add(C.cRed + "Not enough Treasure Shards."); 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 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; slot = 49;
for (PetExtra petExtra : getPlugin().getPetManager().GetFactory().GetPetExtras()) for (PetExtra petExtra : getPlugin().getPetManager().getFactory().GetPetExtras())
{ {
List<String> itemLore = new ArrayList<String>(); List<String> itemLore = new ArrayList<String>();
@ -233,7 +233,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
public void deactivatePet(Player player) public void deactivatePet(Player player)
{ {
playAcceptSound(player); playAcceptSound(player);
getPlugin().getPetManager().RemovePet(player, true); getPlugin().getPetManager().removePet(player, true);
refresh(); refresh();
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@ import java.util.*;
import java.util.function.Predicate; import java.util.function.Predicate;
import mineplex.core.gadget.commands.LockCosmeticsCommand; import mineplex.core.gadget.commands.LockCosmeticsCommand;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom; 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()) for (GadgetType gadgetType : _gadgets.keySet())
{ {
if (gadgetType == GadgetType.WIN_EFFECT && winRooms)
{
continue;
}
for (Gadget gadget : _gadgets.get(gadgetType)) for (Gadget gadget : _gadgets.get(gadgetType))
{ {
gadget.disable(player); gadget.disable(player);
@ -776,7 +781,9 @@ public class GadgetManager extends MiniPlugin
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) 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); disableAll(event.getPlayer(), false);
_lastMove.remove(event.getPlayer()); _lastMove.remove(event.getPlayer());
_playerActiveGadgetMap.remove(event.getPlayer()); _playerActiveGadgetMap.remove(event.getPlayer());
@ -914,89 +921,57 @@ public class GadgetManager extends MiniPlugin
event.setCancelled(true); event.setCancelled(true);
} }
private void saveGadgets(Player player) @EventHandler
private void saveGadget(GadgetChangeEvent event)
{ {
if (player.getGameMode() == GameMode.SPECTATOR) Gadget gadget = event.getGadget();
return; if (gadget != null)
Map<String, String> cache = new HashMap<>();
for (Gadget gadget : getAllGadgets())
{ {
String value = "disabled", key = "";
GadgetType gadgetType = gadget.getGadgetType(); GadgetType gadgetType = gadget.getGadgetType();
if (gadget.ownsGadget(player))
{
switch (gadgetType) switch (gadgetType)
{ {
case MUSIC_DISC: case MUSIC_DISC:
case ITEM: case ITEM:
case MORPH: case MORPH:
case BALLOON: case BALLOON:
break; return;
case COSTUME: case COSTUME:
OutfitGadget outfitGadget = (OutfitGadget) gadget; OutfitGadget outfitGadget = (OutfitGadget) gadget;
String key = "activeCostume" + outfitGadget.getSlot().getDatabaseKey(); key = "activeCostume" + outfitGadget.getSlot().getDatabaseKey();
if (cache.containsKey(key)) if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
continue; {
if (outfitGadget.isActive(player)) value = outfitGadget.getName();
cache.put(key, outfitGadget.getName()); }
break; break;
case GAME_MODIFIER: case GAME_MODIFIER:
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget; GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
if (gameModifierGadget.canAllowMultiple()) if (gameModifierGadget.canAllowMultiple())
{ {
if (cache.containsKey(gadget.getName())) key = gameModifierGadget.getName();
continue; if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
cache.put(gadget.getName(), (gadget.isActive(player)) ? "enabled" : "disabled");
} else
{ {
String dataKey = "activeModifier" + gameModifierGadget.getGameType().getName().replace(" ", ""); value = "enabled";
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");
}
} }
} }
else 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) 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.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType; 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.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,7 +33,7 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
// Removes all cosmetic types // Removes all cosmetic types
if (args.length == 0) if (args.length == 0)
{ {
addCosmetics(null, caller); lockCosmetics(null, caller);
} }
// Removes specific type // Removes specific type
else else
@ -36,7 +41,15 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
String type = args[0]; String type = args[0];
if (type.equalsIgnoreCase("all")) 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 else
{ {
@ -47,27 +60,74 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
} }
else else
{ {
addCosmetics(gadgetType, caller); lockCosmetics(gadgetType, caller);
} }
} }
} }
} }
private void addCosmetics(GadgetType gadgetType, Player caller) private void lockCosmetics(GadgetType gadgetType, Player caller)
{ {
if (gadgetType == null) if (gadgetType == null)
{ {
for (GadgetType type : GadgetType.values()) for (GadgetType type : GadgetType.values())
{ {
addCosmetics(type, caller); lockCosmetics(type, caller);
} }
lockMounts(caller);
lockPets(caller);
return; return;
} }
int removed = 0;
for (Gadget gadget : _plugin.getGadgets(gadgetType)) for (Gadget gadget : _plugin.getGadgets(gadgetType))
{ {
_plugin.getDonationManager().Get(caller.getName()).RemoveUnknownSalesPackagesOwned(gadget.getName()); if (gadget.getGadgetType() == GadgetType.ITEM)
} continue;
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name() + " cosmetics!")); 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.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.pet.Pet; import mineplex.core.pet.Pet;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class UnlockCosmeticsCommand extends CommandBase<GadgetManager> public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
@ -40,6 +40,14 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
{ {
addCosmetics(null, caller); addCosmetics(null, caller);
} }
else if (type.equalsIgnoreCase("pet"))
{
addPets(caller);
}
else if (type.equalsIgnoreCase("mount"))
{
addMounts(caller);
}
else else
{ {
GadgetType gadgetType = GadgetType.valueOf(type); GadgetType gadgetType = GadgetType.valueOf(type);
@ -64,12 +72,54 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
{ {
addCosmetics(type, caller); addCosmetics(type, caller);
} }
addMounts(caller);
addPets(caller);
return; return;
} }
int added = 0;
int amount = 1;
for (Gadget gadget : _plugin.getGadgets(gadgetType)) for (Gadget gadget : _plugin.getGadgets(gadgetType))
{ {
_plugin.getDonationManager().Get(caller.getName()).AddUnknownSalesPackagesOwned(gadget.getName()); if (gadgetType == GadgetType.ITEM)
} amount = 20;
UtilPlayer.message(caller, F.main("Cosmetics", "Added all the " + gadgetType.name() + " cosmetics!")); 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 //Coal Apparition
if (!Manager.getPetManager().Get(player).GetPets().containsKey(EntityType.PIG_ZOMBIE)) if (!Manager.getPetManager().Get(player).getPets().containsKey(EntityType.PIG_ZOMBIE))
{ {
goal = _pet; goal = _pet;

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -17,6 +18,7 @@ import org.bukkit.util.Vector;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; 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.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseGuardian; import mineplex.core.disguise.disguises.DisguiseGuardian;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.types.MorphGadget; import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargedEvent; 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); 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); ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
stand.setVisible(false); 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); Location loc = getBaseLocation().add(UtilAlg.getRight(dir).multiply(5)).add(0, 2, 0).subtract(dir);
loc.setDirection(getBaseLocation().subtract(loc).toVector()); 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.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.UUID;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.block.BlockFace; 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.ArmorStand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; 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.player.PlayerMoveEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -26,6 +29,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.spigotmc.event.entity.EntityDismountEvent;
/** /**
* A wrapper for different win effects * A wrapper for different win effects
@ -51,8 +55,8 @@ public abstract class WinEffectGadget extends Gadget
protected List<Player> _nonTeam; protected List<Player> _nonTeam;
/** All players on the team that didn't win + spectators which were not in the game at all. */ /** All players on the team that didn't win + spectators which were not in the game at all. */
protected List<Player> _other; protected List<Player> _other;
/** All locked players */ /** All the players that were teleported to the winroom */
protected List<Player> _locked; protected List<Player> _allPlayers;
/** /**
* @param manager The normal GadgetManager * @param manager The normal GadgetManager
@ -91,54 +95,9 @@ public abstract class WinEffectGadget extends Gadget
play(); 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() public void runFinish()
{ {
finish(); finish();
UtilServer.getPlayersCollection().forEach(p -> {unlockPlayer(p); UtilPlayer.showForAll(p); });
_player = null; _player = null;
_baseLocation = null; _baseLocation = null;
_team.clear(); _team.clear();
@ -147,8 +106,8 @@ public abstract class WinEffectGadget extends Gadget
_nonTeam = null; _nonTeam = null;
_other.clear(); _other.clear();
_other = null; _other = null;
_locked.clear(); _allPlayers.clear();
_locked = null; _allPlayers = null;
// Loads gadgets back when players are teleported to the arcade hub, after the win effect // Loads gadgets back when players are teleported to the arcade hub, after the win effect
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
@ -221,7 +180,8 @@ public abstract class WinEffectGadget extends Gadget
_other.remove(player); _other.remove(player);
_other.removeAll(team); _other.removeAll(team);
_locked = new ArrayList<>(); _allPlayers = new ArrayList<>();
_allPlayers.addAll(UtilServer.getPlayersCollection());
this._start = System.currentTimeMillis(); this._start = System.currentTimeMillis();
this._baseLocation = loc.clone(); this._baseLocation = loc.clone();
@ -245,32 +205,64 @@ public abstract class WinEffectGadget extends Gadget
*/ */
public void teleport(Location loc) public void teleport(Location loc)
{ {
loc.getBlock().setType(Material.AIR); createBarriers(loc);
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);
BukkitRunnable bRunnable = new BukkitRunnable() { BukkitRunnable bRunnable = new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
for(Player p : UtilServer.getPlayers()) { for(Player p : UtilServer.getPlayers()) {
lockPlayer(p);
UtilPlayer.hideFromAll(p); UtilPlayer.hideFromAll(p);
p.teleport(loc);
p.setGameMode(GameMode.ADVENTURE); p.setGameMode(GameMode.ADVENTURE);
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 10 * 20, 1, false, false));
p.getInventory().clear(); p.getInventory().clear();
p.teleport(loc.clone().add(.5, 0, .5));
p.setAllowFlight(false); p.setAllowFlight(false);
Manager.disableAll(p, false); p.setHealth(p.getMaxHealth());
p.setFoodLevel(20);
Manager.disableAll(p, true);
} }
} }
}; };
bRunnable.runTaskLater(UtilServer.getPlugin(), 10l); 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 * Build the win room, by default this will paste the scheamtic. Do any major setup here. This is called before the players are
* teleported. * 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 @Override
protected PlayerGiveawayData AddPlayer(String player) protected PlayerGiveawayData addPlayer(String player)
{ {
return new PlayerGiveawayData(); return new PlayerGiveawayData();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,8 @@
package mineplex.core.packethandler; package mineplex.core.packethandler;
import java.util.ArrayList; import com.mineplex.spigot.PacketProcessor;
import java.util.HashMap; import mineplex.core.MiniPlugin;
import java.util.Iterator;
import java.util.Map.Entry;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -15,16 +11,22 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.mineplex.spigot.PacketProcessor; import java.util.ArrayList;
import java.util.HashMap;
import mineplex.core.MiniPlugin; import java.util.HashSet;
import mineplex.core.common.util.NautHashMap; 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 public class PacketHandler extends MiniPlugin
{ {
private NautHashMap<Player, PacketVerifier> _playerVerifierMap = new NautHashMap<Player, PacketVerifier>(); private Map<Player, PacketVerifier> _playerVerifierMap = new HashMap<>();
private HashMap<Class, ArrayList<IPacketHandler>> _forceMainThread = new HashMap<Class, ArrayList<IPacketHandler>>();
private HashMap<Class, ArrayList<IPacketHandler>> _packetHandlers = new HashMap<Class, ArrayList<IPacketHandler>>(); 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) public PacketHandler(JavaPlugin plugin)
{ {
@ -40,18 +42,6 @@ public class PacketHandler extends MiniPlugin
.get(event.getPlayer())); .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) public boolean handlePacket(PacketInfo packetInfo)
{ {
if (!_packetHandlers.containsKey(packetInfo.getPacket().getClass())) if (!_packetHandlers.containsKey(packetInfo.getPacket().getClass()))
@ -60,7 +50,9 @@ public class PacketHandler extends MiniPlugin
return true; 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 try
{ {
@ -71,6 +63,7 @@ public class PacketHandler extends MiniPlugin
ex.printStackTrace(); ex.printStackTrace();
} }
} }
}
return !packetInfo.isCancelled(); return !packetInfo.isCancelled();
} }
@ -89,19 +82,37 @@ public class PacketHandler extends MiniPlugin
@SafeVarargs @SafeVarargs
public final void addPacketHandler(IPacketHandler packetHandler, Class<? extends Packet>... packetsToListen) 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) if (packetsToListen.length == 0)
{ {
throw new IllegalArgumentException("When registering a new packet listener, add the packets its going to listen to"); 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 * 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) Class<? extends Packet>... packetsToListen)
{ {
if (packetsToListen.length == 0) 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"); 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)
{ {
if (!_forceMainThread.containsKey(c)) _forceMainThread
{ .computeIfAbsent(c, key -> new HashSet<>())
_forceMainThread.put(c, new ArrayList()); .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)); PacketProcessor.addPacket(c, forceMainThread || _forceMainThread.containsKey(c));
} }
} }
public void removePacketHandler(IPacketHandler packetHandler) 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()) 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.containsKey(entry.getKey()) && _forceMainThread.get(entry.getKey()).remove(packetHandler))
{ {
if (_forceMainThread.get(entry.getKey()).isEmpty()) 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; KnownPackage = false;
} }
public EntityType GetPetType() public EntityType getPetType()
{ {
return _petType; return _petType;
} }
public void Update(PetSalesToken petToken) public void update(PetSalesToken petToken)
{ {
_name = petToken.Name; _name = petToken.Name;
} }
public String GetPetName() public String getPetName()
{ {
return _name; return _name;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -50,8 +50,8 @@ public class PetReward extends UnknownPackageReward
PetToken petToken = new PetToken(); PetToken petToken = new PetToken();
petToken.PetType = token.PetType; petToken.PetType = token.PetType;
_petManager.GetRepository().AddPet(token); _petManager.getRepository().AddPet(token);
_petManager.Get(player).GetPets().put(_petEntity, token.PetName); _petManager.Get(player).getPets().put(_petEntity, token.PetName);
_inventoryManager.addItemToInventory(player, _petEntity.toString(), 1); _inventoryManager.addItemToInventory(player, _petEntity.toString(), 1);
@ -67,6 +67,6 @@ public class PetReward extends UnknownPackageReward
return false; 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 @Override
protected PlayerStats AddPlayer(String player) protected PlayerStats addPlayer(String player)
{ {
return new PlayerStats(); return new PlayerStats();
} }

View File

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

View File

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

View File

@ -40,6 +40,19 @@ public class BuyChestButton implements IButton
@Override @Override
public void onClick(final Player player, ClickType clickType) 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) if (!_page.getPlugin().hasItemsToGivePlayer(TreasureType.ILLUMINATED.getRewardPool(), player)
&& _chestType == TreasureType.ILLUMINATED) && _chestType == TreasureType.ILLUMINATED)
{ {

View File

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

View File

@ -2,7 +2,10 @@ package mineplex.core.youtube;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -14,6 +17,7 @@ import java.time.ZonedDateTime;
public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient> public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
{ {
private static final int REWARD_MESSAGE_DELAY_SECONDS = 30;
private final YoutubeRepository _repository; private final YoutubeRepository _repository;
private final DonationManager _donationManager; private final DonationManager _donationManager;
@ -48,7 +52,11 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
} }
YoutubeClient client = Get(player); YoutubeClient client = Get(player);
client.setClickDate(ZonedDateTime.now(ZoneOffset.UTC).toLocalDate()); 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 @Override
@ -68,7 +76,7 @@ public class YoutubeManager extends MiniDbClientPlugin<YoutubeClient>
} }
@Override @Override
protected YoutubeClient AddPlayer(String player) protected YoutubeClient addPlayer(String player)
{ {
return new YoutubeClient(null); return new YoutubeClient(null);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -322,7 +322,7 @@ public class ClassManager extends MiniClientPlugin<ClientClass> implements IClas
} }
@Override @Override
protected ClientClass AddPlayer(String player) protected ClientClass addPlayer(String player)
{ {
return new ClientClass(this, _skillFactory, _itemFactory, _clientManager.Get(player), _donationManager.Get(player), null); 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 _damageeBrute = false;
private boolean _damageToLevel = true; private boolean _damageToLevel = true;
private boolean _arrowShow = true; private boolean _arrowShow = true;
private boolean _projectileDamageSelf = false;
public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile, Location knockbackOrigin, public CustomDamageEvent(LivingEntity damagee, LivingEntity damager, Projectile projectile, Location knockbackOrigin,
DamageCause cause, double damage, boolean knockback, boolean ignoreRate, boolean ignoreArmor, String initialSource, 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; 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) public void setShowArrows(boolean show)
{ {
_arrowShow = show; _arrowShow = show;

View File

@ -8,24 +8,6 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.EntityEffect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -48,6 +30,24 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector; 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 public class DamageManager extends MiniPlugin
{ {
private CombatManager _combatManager; private CombatManager _combatManager;
@ -231,16 +231,20 @@ public class DamageManager extends MiniPlugin
@EventHandler @EventHandler
public void onEntityCombust(EntityCombustByEntityEvent event) public void onEntityCombust(EntityCombustByEntityEvent event)
{ {
if (!_enabled)
return;
if (!(event.getCombuster() instanceof Player || event.getCombuster() instanceof Arrow)) if (!(event.getCombuster() instanceof Player || event.getCombuster() instanceof Arrow))
return; return;
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(priority = EventPriority.HIGHEST) /**
public void removeDemArrowsCrazyMan(EntityDamageEvent event) * Removes arrows after hit, especially in cases where arrows may bounce, like if the damage was cancelled.
{ */
if (event.isCancelled()) @EventHandler(priority = EventPriority.MONITOR)
public void removeArrows(EntityDamageEvent event)
{ {
Projectile projectile = GetProjectile(event); Projectile projectile = GetProjectile(event);
@ -250,6 +254,20 @@ public class DamageManager extends MiniPlugin
projectile.remove(); 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) private boolean GoldPower(LivingEntity damager)
@ -316,6 +334,12 @@ public class DamageManager extends MiniPlugin
return; return;
} }
if (event.GetProjectile() != null && event.GetDamageeEntity().equals(event.GetProjectile().getShooter()) && !event.getProjectileDamageSelf())
{
event.SetCancelled("Self Projectile Damage");
return;
}
if (event.GetDamageePlayer() != null) if (event.GetDamageePlayer() != null)
{ {
Player damagee = event.GetDamageePlayer(); Player damagee = event.GetDamageePlayer();
@ -375,6 +399,10 @@ public class DamageManager extends MiniPlugin
Player damagee = event.GetDamageePlayer(); Player damagee = event.GetDamageePlayer();
if (damagee != null) if (damagee != null)
{ {
if (event.GetDamage() <= 0)
{
return;
}
if (getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()) > 0) if (getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()) > 0)
{ {
event.AddMult("Ench Prot", damagee.getName(), getTotalEnchantReduction(damagee.getInventory().getArmorContents(), event.GetCause()), false); 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); Player player = event.GetDamagerPlayer(true);
if (player != null) if (player != null)
{ {
if (player.equals(event.GetDamageeEntity()) && !event.getProjectileDamageSelf()) return;
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 0.5f, 0.5f); 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) if (event.GetDamageeEntity().getHealth() <= 0)
return; return;
if (event.GetProjectile() != null &&
event.GetDamageeEntity().equals(event.GetProjectile().getShooter()) &&
!event.getProjectileDamageSelf())
return;
//Player Conditions //Player Conditions
if (event.GetDamageePlayer() != null) if (event.GetDamageePlayer() != null)
{ {
@ -510,14 +545,21 @@ public class DamageManager extends MiniPlugin
origin = event.GetDamagerEntity(true).getLocation(); origin = event.GetDamagerEntity(true).getLocation();
if (event.getKnockbackOrigin() != null) if (event.getKnockbackOrigin() != null)
origin = event.getKnockbackOrigin(); origin = event.getKnockbackOrigin();
else if (event.GetProjectile() != null)
origin = event.GetProjectile().getLocation();
//Vec //Vec
Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation()); Vector trajectory = UtilAlg.getTrajectory2d(origin, event.GetDamageeEntity().getLocation());
trajectory.multiply(0.6 * knockback); trajectory.multiply(0.6 * knockback);
trajectory.setY(Math.abs(trajectory.getY())); 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 //Apply
double vel = 0.2 + trajectory.length() * 0.8; 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 KitProgressionManager _kitProgressionManager;
private ProgressingKitManager _progressionKitManager; private ProgressingKitManager _progressionKitManager;
private BoosterManager _boosterManager; private BoosterManager _boosterManager;
private GameSpectatorManager _spectatorManager;
private IncognitoManager _incognitoManager; private IncognitoManager _incognitoManager;
@ -290,7 +291,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager); 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); _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 GameLootManager(this, petManager, _bonusManager.getRewardManager());
new GameSpectatorManager(this); _spectatorManager = new GameSpectatorManager(this);
_gameWorldManager = new GameWorldManager(this); _gameWorldManager = new GameWorldManager(this);
new MiscManager(this); new MiscManager(this);
_hologramManager = hologramManager; _hologramManager = hologramManager;
@ -1705,4 +1706,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
return _kitProgressionManager; return _kitProgressionManager;
} }
public GameSpectatorManager getGameSpectatorManager()
{
return _spectatorManager;
}
} }

View File

@ -22,6 +22,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.kit.*; import nautilus.game.arcade.kit.*;
import nautilus.game.arcade.managers.GameLobbyManager; import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.chat.ChatStatData;
@ -311,8 +312,6 @@ public abstract class Game implements Listener
public boolean AllowEntitySpectate = true; public boolean AllowEntitySpectate = true;
public boolean PlayerTeamSelection = false;
public boolean TeamMode = false; public boolean TeamMode = false;
public boolean TeamPerSpawn = false; public boolean TeamPerSpawn = false;
@ -332,6 +331,8 @@ public abstract class Game implements Listener
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>(); private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
public WinEffectManager WinEffectManager = new WinEffectManager(); public WinEffectManager WinEffectManager = new WinEffectManager();
private Map<Class<? extends Module>, Module> _modules = new HashMap<>();
public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
{ {
Manager = manager; Manager = manager;
@ -418,6 +419,20 @@ public abstract class Game implements Listener
System.out.println("Loading " + GetName() + "..."); 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) public void setKits(Kit[] kits)
{ {
_kits = kits; _kits = kits;
@ -1897,157 +1912,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 @EventHandler
public void CustomTeamGeneration(GameStateChangeEvent event) public void CustomTeamGeneration(GameStateChangeEvent event)
{ {
@ -2271,4 +2135,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.Creature;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
public class GameTeam public class GameTeam
{ {
@ -192,7 +193,11 @@ public class GameTeam
{ {
for(Player other : UtilServer.getPlayers()) 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); 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.")); 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.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import nautilus.game.arcade.game.modules.TeamModule;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -40,7 +41,9 @@ public class TeamBuild extends Build
super(manager, GameType.Brawl); super(manager, GameType.Brawl);
TeamMode = true; TeamMode = true;
PlayerTeamSelection = true;
registerModule(new TeamModule());
TeamPerSpawn = true; TeamPerSpawn = true;
FillTeamsInOrderToCount = 2; FillTeamsInOrderToCount = 2;

View File

@ -2139,6 +2139,12 @@ public class MineStrike extends TeamGame
//Revive Dead Players //Revive Dead Players
for (Player player : GetPlayers(false)) for (Player player : GetPlayers(false))
{
if (Manager.isVanished(player))
{
continue;
}
if (!IsAlive(player)) if (!IsAlive(player))
{ {
SetPlayerState(player, PlayerState.IN); SetPlayerState(player, PlayerState.IN);
@ -2156,6 +2162,7 @@ public class MineStrike extends TeamGame
if (GetKit(player) != null) if (GetKit(player) != null)
GetKit(player).ApplyKit(player); GetKit(player).ApplyKit(player);
} }
}
//Remove Scope //Remove Scope
for (Player player : GetPlayers(false)) for (Player player : GetPlayers(false))
@ -2319,6 +2326,11 @@ public class MineStrike extends TeamGame
if (GetState() == GameState.Recruit || GetState() == GameState.Loading) if (GetState() == GameState.Recruit || GetState() == GameState.Loading)
return; return;
if (Manager.isVanished(event.getPlayer()))
{
return;
}
//Target Team //Target Team
GameTeam targetTeam = null; GameTeam targetTeam = null;
if (GetTeamList().get(0).GetPlayers(false).size() < GetTeamList().get(1).GetPlayers(false).size()) 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; continue;
// Damage Event // 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), DamageCause.CUSTOM, 1 + (players.get(player) * 18),
true, true, false, _thrower.getName(), getName()); 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.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState; 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.DeathBomberStatTracker;
import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker; import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker;
import nautilus.game.arcade.stats.SkywarsTNTStatTracker; import nautilus.game.arcade.stats.SkywarsTNTStatTracker;
@ -79,9 +80,10 @@ public class TeamSkywars extends Skywars
DontAllowOverfill = true; DontAllowOverfill = true;
PlayerTeamSelection = true;
TeamMode = true; TeamMode = true;
TeamPerSpawn = true; TeamPerSpawn = true;
registerModule(new TeamModule());
} }
@Override @Override

View File

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

View File

@ -55,7 +55,6 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.ArmorStand; 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!")); 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 @EventHandler
@ -1695,6 +1701,39 @@ public class SpeedBuilders extends SoloGame
UtilAction.velocity(event.getPlayer(), new Vector(0, 1, 0)); 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 @Override
public void EndCheck() public void EndCheck()
{ {

View File

@ -324,6 +324,12 @@ public class RecreationData
score++; 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 //Fix for corner stair shape
if (currentBlock.getState().getData() instanceof Stairs && expectedState.getData() instanceof Stairs) 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.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker; import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker; import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
@ -59,7 +60,8 @@ public class TeamSurvivalGames extends SurvivalGames
DontAllowOverfill = true; DontAllowOverfill = true;
TeamMode = true; TeamMode = true;
PlayerTeamSelection = true;
registerModule(new TeamModule());
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this), registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
new KillsWithinTimeLimitStatTracker(this, 3, 60, "Bloodlust"), 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; 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)); player.setFlySpeed((float) Math.min(1, speed));
// Bump // 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<>(); players = new ArrayList<>();
for (String s : _players) for (String s : _players)
{ {
players.add(Bukkit.getPlayer(s)); Player player = Bukkit.getPlayer(s);
if (!_plugin.isVanished(player))
{
players.add(player);
}
} }
} }
else else
@ -56,7 +61,7 @@ public abstract class PlayerPage extends BasePage
int slot = 9; int slot = 9;
for (Player player : players) 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) }); 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)); addButton(slot, head, new Button(slot, player));

View File

@ -41,18 +41,7 @@ public class SpectatorButton implements IButton
if(clickType == ClickType.RIGHT) if(clickType == ClickType.RIGHT)
{ {
_player.closeInventory(); _player.closeInventory();
_player.teleport(_target.getLocation().add(0, 1, 0)); _arcadeManager.getGameSpectatorManager().setSpectating(_player, _target);
_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);
} }
else else
{ {

View File

@ -30,6 +30,7 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk; import nautilus.game.arcade.kit.SmashPerk;
public class PerkBoneRush extends SmashPerk implements IThrown public class PerkBoneRush extends SmashPerk implements IThrown
@ -151,6 +152,18 @@ public class PerkBoneRush extends SmashPerk implements IThrown
double damage = 0.7; double damage = 0.7;
String reason = GetName(); 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)) if (isSuperActive(damager))
{ {
damage = 3; damage = 3;

View File

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

View File

@ -21,8 +21,10 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.SmashPerk; import nautilus.game.arcade.kit.SmashPerk;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -165,6 +167,15 @@ public class PerkCreeperExplode extends SmashPerk
if (UtilMath.offset(player.getLocation(), spawn) < 14) if (UtilMath.offset(player.getLocation(), spawn) < 14)
spawnIterator.remove(); 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 //Damage

View File

@ -3,11 +3,8 @@ package nautilus.game.arcade.kit.perks;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import org.bukkit.Color;
import org.bukkit.EntityEffect; import org.bukkit.EntityEffect;
import org.bukkit.FireworkEffect;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; 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.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -30,7 +26,6 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.SmashPerk; import nautilus.game.arcade.kit.SmashPerk;
import nautilus.game.arcade.kit.perks.data.FireflyData; import nautilus.game.arcade.kit.perks.data.FireflyData;
@ -93,7 +88,7 @@ public class PerkFirefly extends SmashPerk
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
_tick = (_tick + 1)%1000; _tick++;
Iterator<FireflyData> dataIterator = _data.iterator(); Iterator<FireflyData> dataIterator = _data.iterator();
@ -148,7 +143,7 @@ public class PerkFirefly extends SmashPerk
other.playEffect(EntityEffect.HURT); 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)) 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.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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; import nautilus.game.arcade.kit.SmashPerk;
public class PerkInferno extends 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.NautHashMap;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -74,7 +75,7 @@ public class PerkLeap extends Perk
if (event.getPlayer().getItemInHand() == null) if (event.getPlayer().getItemInHand() == null)
return; return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) if (!UtilItem.isAxe(event.getPlayer().getItemInHand()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -96,7 +97,7 @@ public class PerkLeap extends Perk
} }
//Energy //Energy
if (!Recharge.Instance.use(player, _name, _recharge, true, true)) if (!Recharge.Instance.use(player, _name, _recharge, false, true))
return; return;
//Use Use //Use Use

View File

@ -13,8 +13,6 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg; 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.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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.SmashPerk;
import nautilus.game.arcade.kit.perks.data.NightLivingDeadData; import nautilus.game.arcade.kit.perks.data.NightLivingDeadData;
@ -126,6 +125,16 @@ public class PerkNightLivingDead extends SmashPerk
{ {
if (data.Zombies.contains(event.getEntity())) 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())) if (data.Player.equals(event.getTarget()))
{ {
event.setCancelled(true); event.setCancelled(true);

View File

@ -33,6 +33,7 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown; import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser; import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk; import nautilus.game.arcade.kit.SmashPerk;
public class PerkPigBaconBounce extends SmashPerk implements IThrown public class PerkPigBaconBounce extends SmashPerk implements IThrown
@ -109,6 +110,18 @@ public class PerkPigBaconBounce extends SmashPerk implements IThrown
if (target == null) if (target == null)
return; 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 //Damage Event
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null,
DamageCause.CUSTOM, 4, true, true, false, 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.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.SmashPerk; import nautilus.game.arcade.kit.SmashPerk;
public class PerkSlimeRocket extends SmashPerk implements IThrown public class PerkSlimeRocket extends SmashPerk implements IThrown
@ -208,6 +209,17 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown
if (!_owner.containsKey(event.getEntity())) if (!_owner.containsKey(event.getEntity()))
return; 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())) if (_owner.get(event.getEntity()).equals(event.getTarget()))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -225,6 +237,18 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown
Slime slime = (Slime)data.getThrown(); 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 //Damage Event
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null,
DamageCause.PROJECTILE, 3 + slime.getSize() * 3, true, true, false, DamageCause.PROJECTILE, 3 + slime.getSize() * 3, true, true, false,
@ -275,6 +299,16 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown
//if (owner != null) //if (owner != null)
// event.SetDamager(owner); This gives knockback from wrong direction :( // 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())) 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.HashMap;
import java.util.Iterator; 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.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -17,20 +28,10 @@ import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent; 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 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() public PerkWitherImage()
{ {
@ -67,7 +68,7 @@ public class PerkWitherImage extends SmashPerk
if (!Kit.HasKit(player)) if (!Kit.HasKit(player))
return; return;
if (!_images.containsKey(player)) if (!_ownerToSkeleton.containsKey(player))
{ {
if (!Recharge.Instance.use(player, GetName(), 12000, true, true)) if (!Recharge.Instance.use(player, GetName(), 12000, true, true))
return; return;
@ -94,7 +95,8 @@ public class PerkWitherImage extends SmashPerk
UtilAction.velocity(skel, player.getLocation().getDirection(), 1.6, false, 0, 0.2, 10, true); 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); 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)) if (!Recharge.Instance.use(player, "Wither Swap", 2000, true, false))
return; return;
Skeleton skel = _images.get(player); Skeleton skel = _ownerToSkeleton.get(player);
Location loc = skel.getLocation(); Location loc = skel.getLocation();
skel.teleport(player.getLocation()); skel.teleport(player.getLocation());
@ -126,10 +128,24 @@ public class PerkWitherImage extends SmashPerk
@EventHandler @EventHandler
public void entityTarget(EntityTargetEvent event) public void entityTarget(EntityTargetEvent event)
{ {
if (_images.containsKey(event.getTarget())) if (_skeletonToOwner.containsKey(event.getEntity()))
if (_images.get(event.getTarget()).equals(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); event.setCancelled(true);
} }
}
if (_ownerToSkeleton.get(event.getTarget()).equals(event.getEntity()))
{
event.setCancelled(true);
}
}
}
@EventHandler @EventHandler
public void damage(CustomDamageEvent event) public void damage(CustomDamageEvent event)
@ -137,13 +153,13 @@ public class PerkWitherImage extends SmashPerk
Player damagee = event.GetDamageePlayer(); Player damagee = event.GetDamageePlayer();
if (damagee == null) return; if (damagee == null) return;
if (!_images.containsKey(damagee)) if (!_ownerToSkeleton.containsKey(damagee.getUniqueId()))
return; return;
LivingEntity damager = event.GetDamagerEntity(false); LivingEntity damager = event.GetDamagerEntity(false);
if (damager == null) return; if (damager == null) return;
if (_images.get(damagee).equals(damager)) if (_ownerToSkeleton.get(damagee.getUniqueId()).equals(damager))
event.SetCancelled("Wither Image"); event.SetCancelled("Wither Image");
} }
@ -153,12 +169,12 @@ public class PerkWitherImage extends SmashPerk
LivingEntity damager = event.GetDamagerEntity(true); LivingEntity damager = event.GetDamagerEntity(true);
if (damager == null) return; if (damager == null) return;
if (!_images.containsValue(damager)) if (!_ownerToSkeleton.containsValue(damager))
return; 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.SetDamager(player);
event.setKnockbackOrigin(damager.getLocation()); event.setKnockbackOrigin(damager.getLocation());
@ -173,12 +189,12 @@ public class PerkWitherImage extends SmashPerk
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
Iterator<Player> playerIterator = _images.keySet().iterator(); Iterator<Player> playerIterator = _ownerToSkeleton.keySet().iterator();
while (playerIterator.hasNext()) while (playerIterator.hasNext())
{ {
Player player = playerIterator.next(); Player player = playerIterator.next();
Skeleton skel = _images.get(player); Skeleton skel = _ownerToSkeleton.get(player);
if (!player.isValid() || !skel.isValid() || skel.getTicksLived() > 160) if (!player.isValid() || !skel.isValid() || skel.getTicksLived() > 160)
{ {
@ -195,7 +211,8 @@ public class PerkWitherImage extends SmashPerk
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void clean(PlayerDeathEvent event) public void clean(PlayerDeathEvent event)
{ {
Skeleton skel = _images.remove(event.getEntity()); Skeleton skel = _ownerToSkeleton.remove(event.getEntity());
_skeletonToOwner.remove(skel);
if (skel != null) if (skel != null)
{ {

View File

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

View File

@ -948,7 +948,8 @@ public class GameLobbyManager implements Listener
public void Combust(EntityCombustEvent event) public void Combust(EntityCombustEvent event)
{ {
for (LobbyEnt ent : _kits.values()) 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); event.setCancelled(true);
return; return;

View File

@ -1,8 +1,22 @@
package nautilus.game.arcade.managers; package nautilus.game.arcade.managers;
import java.util.Collections;
import java.util.HashSet;
import java.util.List; 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.GameMode;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -10,6 +24,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent; 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.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState; 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; ArcadeManager Manager;
public GameSpectatorManager(ArcadeManager manager) public GameSpectatorManager(ArcadeManager manager)
@ -35,6 +52,8 @@ public class GameSpectatorManager implements Listener
Manager = manager; Manager = manager;
Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
Manager.getPacketHandler().addPacketHandler(this, PacketHandler.ListenerPriority.HIGH, PacketPlayOutNamedEntitySpawn.class);
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
@ -214,38 +233,50 @@ public class GameSpectatorManager implements Listener
} }
} }
private void setSpectating(Player player, Entity target) public 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()
{ {
if (Manager.GetGame().IsAlive(player)) 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; 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.setGameMode(GameMode.SPECTATOR);
player.setSpectatorTarget(target); player.setSpectatorTarget(target);
if (ptarget != null) if (playerTarget != null)
UtilTextBottom.display(C.cGray + "You are spectating " + F.elem(Manager.GetGame().GetTeam(ptarget).GetColor() + ptarget.getName()) + ".", player); 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.")); 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) @EventHandler(priority = EventPriority.LOW)
@ -262,4 +293,51 @@ public class GameSpectatorManager implements Listener
if (!Manager.GetGame().IsAlive(player)) if (!Manager.GetGame().IsAlive(player))
event.setCancelled(true); 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() public WinEffectGadget getWinEffect()
{ {
GadgetManager manager = _game.getArcadeManager().getCosmeticManager().getGadgetManager(); GadgetManager manager = _game.getArcadeManager().getCosmeticManager().getGadgetManager();
Gadget gadget = manager.getActive(_winner, GadgetType.WIN_EFFECT); Gadget winEffect = manager.getGadget(WinEffectPodium.class);
if(gadget == null) gadget = manager.getGadget(WinEffectPodium.class); for (Gadget gadget : manager.getGadgets(GadgetType.WIN_EFFECT))
return (WinEffectGadget) gadget; {
if (gadget.isActive(_winner))
{
winEffect = gadget;
}
}
return (WinEffectGadget) winEffect;
} }
} }