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

This commit is contained in:
Sam 2017-04-06 18:20:41 +01:00
commit 5c00ca712f
63 changed files with 1806 additions and 675 deletions

View File

@ -56,6 +56,8 @@ public class UtilColor
return 13;
case DARK_AQUA:
return 9;
case DARK_RED:
return 12;
case DARK_PURPLE:
return 10;
case GOLD:

View File

@ -51,6 +51,7 @@ import org.bukkit.util.Vector;
public class UtilEnt
{
public static final String FLAG_NO_REMOVE = "noremove";
public static final String FLAG_ENTITY_COMPONENT = "component";
//Custom Entity Names
private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>();

View File

@ -372,11 +372,12 @@ public class UtilParticle
int count, ViewDist dist, Player... players)
{
PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true);
int distValue = dist.getDist() * dist.getDist();
for (Player player : players)
{
// Out of range for player
if (UtilMath.offset(player.getLocation(), location) > dist.getDist())
if (UtilMath.offsetSquared(player.getLocation(), location) > distValue)
continue;
UtilPlayer.sendPacket(player, packet);

View File

@ -1133,6 +1133,18 @@ public class UtilPlayer
player.spigot().sendMessage(textComponent);
}
public static void closeInventoryIfOpen(Player player)
{
if (hasOpenInventory(player))
player.closeInventory();
}
public static boolean hasOpenInventory(Player player)
{
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
return entityPlayer.activeContainer != entityPlayer.defaultContainer;
}
/*
* Returns whether the UUID belongs to a slim skin
*/

View File

@ -0,0 +1,126 @@
package mineplex.core;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
import net.minecraft.server.v1_8_R3.PacketPlayInHeldItemSlot;
import net.minecraft.server.v1_8_R3.PacketPlayInRightClick;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutCloseWindow;
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
/**
* Why do we need this you ask?
* <p>
* In 1.8.x, Mojang added Twitch integration, and in standard Mojang fashion completely broke inventory handling.
* <p>
* Specifically, you are able to close an inventory and not actually trigger an InventoryCloseEvent. This kinda breaks
* literally anything relying on that event.
* <p>
* So we just add lots of strict checks to make sure they can't do much without closing the inventory
*/
@ReflectivelyCreateMiniPlugin
public class TwitchIntegrationFix extends MiniPlugin implements IPacketHandler
{
private final Map<UUID, Location> _inventoryOpenedAt = new HashMap<>();
private final Map<UUID, Long> _inventoryOpenedAtTime = new HashMap<>();
private TwitchIntegrationFix()
{
super("Twitch Integration Fix");
require(PacketHandler.class).addPacketHandler(this, true,
PacketPlayOutOpenWindow.class,
PacketPlayOutCloseWindow.class,
PacketPlayInRightClick.class,
PacketPlayInBlockPlace.class,
PacketPlayInArmAnimation.class,
PacketPlayInBlockDig.class,
PacketPlayInHeldItemSlot.class,
PacketPlayInUseEntity.class,
PacketPlayInFlying.PacketPlayInPosition.class,
PacketPlayInFlying.PacketPlayInPositionLook.class
);
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
_inventoryOpenedAt.remove(event.getPlayer().getUniqueId());
_inventoryOpenedAtTime.remove(event.getPlayer().getUniqueId());
}
@Override
public void handle(PacketInfo packetInfo)
{
EntityPlayer entityPlayer = ((CraftPlayer) packetInfo.getPlayer()).getHandle();
if (packetInfo.getPacket() instanceof PacketPlayOutOpenWindow)
{
_inventoryOpenedAt.put(packetInfo.getPlayer().getUniqueId(), packetInfo.getPlayer().getLocation());
_inventoryOpenedAtTime.put(packetInfo.getPlayer().getUniqueId(), entityPlayer.playerConnection.networkManager.packetCount);
}
else if (packetInfo.getPacket() instanceof PacketPlayOutCloseWindow)
{
_inventoryOpenedAt.remove(packetInfo.getPlayer().getUniqueId());
_inventoryOpenedAtTime.remove(packetInfo.getPlayer().getUniqueId());
}
else if (packetInfo.getPacket() instanceof PacketPlayInRightClick ||
packetInfo.getPacket() instanceof PacketPlayInBlockPlace ||
packetInfo.getPacket() instanceof PacketPlayInArmAnimation ||
packetInfo.getPacket() instanceof PacketPlayInBlockDig ||
packetInfo.getPacket() instanceof PacketPlayInHeldItemSlot ||
packetInfo.getPacket() instanceof PacketPlayInUseEntity
)
{
// Impossible to do while inventory is open
if (entityPlayer.activeContainer != entityPlayer.defaultContainer && _inventoryOpenedAtTime.containsKey(packetInfo.getPlayer().getUniqueId()))
{
long openedTime = _inventoryOpenedAtTime.get(packetInfo.getPlayer().getUniqueId());
if (entityPlayer.playerConnection.networkManager.packetCount - openedTime > 5)
{
System.out.println("Impossible packet: " + packetInfo.getPacket().getClass());
packetInfo.getPlayer().closeInventory();
}
}
}
else if (packetInfo.getPacket() instanceof PacketPlayInFlying)
{
if (entityPlayer.activeContainer != entityPlayer.defaultContainer)
{
if (_inventoryOpenedAt.containsKey(packetInfo.getPlayer().getUniqueId()))
{
Location openedAt = _inventoryOpenedAt.get(packetInfo.getPlayer().getUniqueId());
if (!packetInfo.getPlayer().getWorld().equals(openedAt.getWorld()))
{
packetInfo.getPlayer().closeInventory();
}
else
{
double distance = packetInfo.getPlayer().getLocation().distanceSquared(openedAt);
// You get a 9 block radius before you're considered too far away
if (distance > 9 * 9)
{
packetInfo.getPlayer().closeInventory();
}
}
}
}
}
}
}

View File

@ -61,7 +61,7 @@ public class AnimationCarl extends Animation
if(((String) _type).contentEquals("RANK"))
{
for (int i = 50; i < 60; i++)
{
{
Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
_items.add(shard);

View File

@ -147,12 +147,12 @@ public class MorphVillager extends MorphGadget implements IThrown
{
if (_gems.contains(event.getItem()))
{
event.setCancelled(true);
event.getItem().remove();
Manager.getDonationManager().rewardCurrency(GlobalCurrency.GEM, event.getPlayer(), getName() + " Pickup", 16);
Manager.getDonationManager().rewardCurrency(GlobalCurrency.GEM, event.getPlayer(), getName() + " Pickup", 16 * event.getItem().getItemStack().getAmount());
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
event.setCancelled(true);
event.getItem().remove();
}
}

View File

@ -17,6 +17,7 @@ import org.bukkit.util.Vector;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
@ -36,6 +37,9 @@ import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.inventory.ClientItem;
import mineplex.core.inventory.data.Item;
import mineplex.core.mount.DragonMount;
import mineplex.core.mount.Mount;
import mineplex.core.mount.types.MountDragon;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -59,6 +63,12 @@ public class MorphWither extends MorphGadget
@Override
public void enableCustom(final Player player, boolean message)
{
Mount<?> mount = Manager.getMountManager().getActive(player);
if (mount instanceof DragonMount)
{
UtilPlayer.message(player, F.main("Gadget", "You cannot enable the " + F.elem(mount.getName()) + " and the " + F.elem(getName()) + " at the same time"));
Manager.getMountManager().DeregisterAll(player);
}
this.applyArmor(player, message);
player.setMaxHealth(300);

View File

@ -232,6 +232,7 @@ public abstract class WinEffectGadget extends Gadget
public void run() {
for(Player p : UtilServer.getPlayers()) {
UtilPlayer.hideFromAll(p);
p.eject();
p.teleport(loc);
p.setGameMode(GameMode.ADVENTURE);
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 10 * 20, 1, false, false));

View File

@ -41,7 +41,9 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class MessageManager extends MiniClientPlugin<ClientMessage>
@ -55,7 +57,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
private PreferencesManager _preferences;
private Punish _punish;
private Chat _chat;
private ArrayList<String> _randomMessage;
private List<String> _randomMessage;
private String _serverName;
public MessageManager(JavaPlugin plugin, IncognitoManager incognitoManager, CoreClientManager clientManager, PreferencesManager preferences,
@ -301,44 +303,50 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
@Override
public void enable()
{
_randomMessage = new ArrayList<String>();
_randomMessage.clear();
_randomMessage.add("Hello, do you have any wild boars for purchase?");
_randomMessage.add("There's a snake in my boot!");
_randomMessage.add("Monk, I need a Monk!");
_randomMessage.add("Hi, I'm from planet minecraft, op me plz dooooood!");
_randomMessage.add("Somebody's poisoned the waterhole!");
_randomMessage.add("MORE ORBZ MORE ORBZ MORE ORBZ MORE ORBZ!");
_randomMessage.add("Chiss is a chiss and chiss chiss.");
_randomMessage.add("*_*");
_randomMessage.add("#swag");
_randomMessage.add("Everything went better then I thought.");
_randomMessage.add("HAVE A CHICKEN!");
_randomMessage.add("follow me, i have xrays");
_randomMessage.add("I'm making a java");
_randomMessage.add("Do you talk to strangers? I have candy if it helps.");
_randomMessage.add("Solid 2.9/10");
_randomMessage.add("close your eyes to sleep");
_randomMessage.add("I crashed because my internet ran out.");
_randomMessage.add("I saw morgan freeman on a breaking bad ad on a bus.");
_randomMessage.add("Where is the volume control?");
_randomMessage.add("I saw you playing on youtube with that guy and stuff.");
_randomMessage.add("Your worms must be worse than useless.");
_randomMessage.add("meow");
_randomMessage.add("7");
_randomMessage.add("Don't you wish your girlfriend was hot like me?");
_randomMessage.add("how do you play mindcrafts?");
_randomMessage.add("7 cats meow meow meow meow meow meow meow");
_randomMessage.add("For King Jonalon!!!!!");
_randomMessage.add("Do you like apples?");
_randomMessage.add("I'm Happy Happy Happy.");
_randomMessage.add("kthxbye");
_randomMessage.add("i like pie.");
_randomMessage.add("Do you play Clash of Clans?");
_randomMessage.add("Mmm...Steak!");
_randomMessage.add("Poop! Poop everywhere!");
_randomMessage.add("I'm so forgetful. Like I was going to say somethin...wait what were we talking about?");
_randomMessage.add("Mmm...Steak!");
_randomMessage = Arrays.asList(
"The FitnessGram™ Pacer Test is a multistage aerobic capacity test that progressively gets more difficult as it continues",
"do you feel it now mr krabs?!",
"hisssssssss",
"what's a leader?",
"what guardians?",
"rawr!",
"where were you when the emus won the great emu war?",
"Hello, do you have any wild boars for purchase?",
"There's a snake in my boot!",
"Monk, I need a Monk!",
"Hi, I'm from planet minecraft, op me plz dooooood!",
"Somebody's poisoned the waterhole!",
"MORE ORBZ MORE ORBZ MORE ORBZ MORE ORBZ!",
"Chiss is a chiss and chiss chiss.",
"*_*",
"#swag",
"Everything went better then I thought.",
"HAVE A CHICKEN!",
"follow me, i have xrays",
"I'm making a java",
"Solid 2.9/10",
"close your eyes to sleep",
"I crashed because my internet ran out.",
"I saw morgan freeman on a breaking bad ad on a bus.",
"Where is the volume control?",
"I saw you playing on youtube with that guy and stuff.",
"Your worms must be worse than useless.",
"meow",
"7",
"Don't you wish your girlfriend was hot like me?",
"how do you play mindcrafts?",
"7 cats meow meow meow meow meow meow meow",
"For King Jonalon!!!!!",
"Do you like apples?",
"I'm Happy Happy Happy.",
"kthxbye",
"i like pie.",
"Do you play Clash of Clans?",
"Mmm...Steak!",
"Poop! Poop everywhere!",
"I'm so forgetful. Like I was going to say somethin...wait what were we talking about?",
"Mmm...Steak!"
);
}
public CoreClientManager GetClientManager()
@ -354,11 +362,6 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
return _randomMessage.get(UtilMath.r(_randomMessage.size()));
}
public ArrayList<String> GetRandomMessages()
{
return _randomMessage;
}
public void Help(Player caller)
{
Help(caller, null);
@ -641,4 +644,9 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
{
return _incognitoManager;
}
public PreferencesManager getPreferences()
{
return this._preferences;
}
}

View File

@ -22,8 +22,8 @@ public class AdminCommand extends CommandBase<MessageManager>
public void Execute(Player caller, String[] args)
{
if (args == null || args.length == 0)
{
Plugin.Help(caller);
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: " + F.elem("/a <message>")));
}
else
{

View File

@ -10,6 +10,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
import mineplex.core.preferences.Preference;
public class MessageAdminCommand extends CommandBase<MessageManager>
{
@ -27,7 +28,24 @@ public class MessageAdminCommand extends CommandBase<MessageManager>
}
else
{
String message = args.length > 1 ? F.combine(args, 1, null, false) : Plugin.GetRandomMessage();
// Parse Message
String message;
if (args.length > 1)
{
message = F.combine(args, 1, null, false);
}
else
{
if (Plugin.getPreferences().get(caller).isActive(Preference.RANDOM_MESSAGES))
{
message = Plugin.GetRandomMessage();
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Cat got your tongue?"));
return;
}
}
Plugin.sendMessage(caller, args[0], message, false, true);
}
}

View File

@ -10,6 +10,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
import mineplex.core.preferences.Preference;
public class MessageCommand extends CommandBase<MessageManager>
{
@ -35,7 +36,15 @@ public class MessageCommand extends CommandBase<MessageManager>
}
else
{
message = Plugin.GetRandomMessage();
if (Plugin.getPreferences().get(caller).isActive(Preference.RANDOM_MESSAGES))
{
message = Plugin.GetRandomMessage();
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Cat got your tongue?"));
return;
}
}
Plugin.sendMessage(caller, args[0], message, false, false);

View File

@ -7,6 +7,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
import mineplex.core.preferences.Preference;
public class ResendAdminCommand extends CommandBase<MessageManager>
{
@ -19,8 +20,8 @@ public class ResendAdminCommand extends CommandBase<MessageManager>
public void Execute(Player caller, String[] args)
{
if (args == null || args.length == 0)
{
Plugin.Help(caller);
{
UtilPlayer.message(caller, F.help(Plugin.getName(), "/ra [message]", GetRequiredRank()));
}
else
{
@ -41,7 +42,15 @@ public class ResendAdminCommand extends CommandBase<MessageManager>
}
else
{
message = Plugin.GetRandomMessage();
if (Plugin.getPreferences().get(caller).isActive(Preference.RANDOM_MESSAGES))
{
message = Plugin.GetRandomMessage();
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Cat got your tongue?"));
return;
}
}
Plugin.sendMessage(caller, lastTo, message, true, true);

View File

@ -3,8 +3,13 @@ package mineplex.core.mount;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.Managers;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.MorphWither;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
public class DragonMount extends Mount<DragonData>
{
@ -18,6 +23,14 @@ public class DragonMount extends Mount<DragonData>
@Override
public void enableCustom(final Player player)
{
GadgetManager gadgetManager = Managers.get(GadgetManager.class);
Gadget morph = gadgetManager.getActive(player, GadgetType.MORPH);
if (morph instanceof MorphWither)
{
UtilPlayer.message(player, F.main("Gadget", "You cannot enable the " + F.elem(getName()) + " and the " + F.elem(morph.getName()) + " at the same time"));
morph.disable(player, true);
}
player.leaveVehicle();
player.eject();

View File

@ -178,7 +178,12 @@ public class MountCart extends Mount<SingleEntityMountData<Minecart>>
@EventHandler
public void cancelBreak(VehicleDamageEvent event)
{
if (getActive().values().contains(event.getVehicle()))
event.setCancelled(true);
for (SingleEntityMountData<Minecart> data : getActive().values())
{
if (data.getEntity().equals(event.getVehicle()))
{
event.setCancelled(true);
}
}
}
}

View File

@ -298,9 +298,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
DisguiseGuardian disguise = new DisguiseGuardian(pet);
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
disguise.setName(Get(player).getPets().get(entityType));
disguise.setName(Get(player).getPets().get(petType));
disguise.setCustomNameVisible(true);
}
@ -315,9 +315,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
Zombie zombie = pet.getWorld().spawn(pet.getLocation(), Zombie.class);
zombie.setBaby(true);
zombie.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
zombie.setCustomName(Get(player).getPets().get(entityType));
zombie.setCustomName(Get(player).getPets().get(petType));
zombie.setCustomNameVisible(true);
}
disguise.getEntity().getBukkitEntity().setPassenger(zombie);
@ -330,9 +330,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
disguiseZombie.setChestplate(new ItemStack(Material.BANNER));
disguiseZombie.setHeldItem(new ItemStack(Material.WOOD_HOE));
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
disguiseZombie.setName(Get(player).getPets().get(entityType));
disguiseZombie.setName(Get(player).getPets().get(petType));
disguiseZombie.setCustomNameVisible(true);
}
@ -352,9 +352,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
UtilEnt.silence(zombie, true);
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
zombie.setCustomName(Get(player).getPets().get(entityType));
zombie.setCustomName(Get(player).getPets().get(petType));
zombie.setCustomNameVisible(true);
}
}
@ -367,9 +367,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
disguiseVillager.setBaby();
disguiseVillager.setHeldItem(new ItemStack(Material.BOW));
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
disguiseVillager.setName(Get(player).getPets().get(entityType));
disguiseVillager.setName(Get(player).getPets().get(petType));
disguiseVillager.setCustomNameVisible(true);
}
@ -384,9 +384,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
UtilEnt.silence(zombie, true);
if (Get(player).getPets().get(entityType) != null && Get(player).getPets().get(entityType).length() > 0)
if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0)
{
zombie.setCustomName(Get(player).getPets().get(entityType));
zombie.setCustomName(Get(player).getPets().get(petType));
zombie.setCustomNameVisible(true);
}

View File

@ -46,7 +46,9 @@ public enum Preference
COMMUNITY_INVITES(true, PreferenceCategory.SOCIAL, Material.BOOK, "Show Community Invites"),
PARTY_DISPLAY_INVENTORY_UI(true, PreferenceCategory.SOCIAL, Material.CHEST, "Display Parties GUI")
PARTY_DISPLAY_INVENTORY_UI(true, PreferenceCategory.SOCIAL, Material.CHEST, "Display Parties GUI"),
RANDOM_MESSAGES(true, PreferenceCategory.USER, Material.COMMAND, "Send random messages", "Got nothing to say? We got you covered!")
;
private static final Map<Integer, Preference> PREFERENCE_MAP = Maps.newHashMap();

View File

@ -10,6 +10,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.TwitchIntegrationFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -242,6 +243,7 @@ public class Hub extends JavaPlugin implements IRelation
{
require(AprilFoolsTreasureHunt.class);
}
require(TwitchIntegrationFix.class);
}
@Override

View File

@ -15,6 +15,7 @@ import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.TimingsFix;
import mineplex.core.TwitchIntegrationFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -202,6 +203,7 @@ public class Arcade extends JavaPlugin
require(TwoFactorAuth.class);
new WebsiteLinkManager(this, _clientManager);
require(TwitchIntegrationFix.class);
AprilFoolsManager.getInstance();

View File

@ -42,6 +42,7 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
@ -88,6 +89,7 @@ import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.build.Build;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders;
import nautilus.game.arcade.game.modules.AntiExpOrbModule;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.ChampionsKit;
@ -470,6 +472,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed
};
System.out.println("Loading " + GetName() + "...");
new AntiExpOrbModule().register(this);
}
// You should never use this so please don't. Use Module.register instead
@ -1125,7 +1129,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
}
else if (!(kit instanceof ChampionsKit))
{
player.closeInventory();
UtilPlayer.closeInventoryIfOpen(player);
}
}

View File

@ -1,6 +0,0 @@
package nautilus.game.arcade.game.games.bridge;
public class BattleCryManager
{
}

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.game.games.bridge;
import com.google.common.collect.Lists;
import mineplex.core.common.Rank;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
@ -13,13 +12,22 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.DebugCommand;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimationType;
import nautilus.game.arcade.game.games.bridge.animation.custom.CustomBridgeAnimation;
import nautilus.game.arcade.game.games.bridge.animation.custom.RadiusCustomBridgeAnimation;
import nautilus.game.arcade.game.games.bridge.animation.custom.RandomCustomBridgeAnimation;
import nautilus.game.arcade.game.games.bridge.kits.*;
import nautilus.game.arcade.game.modules.WorldBorderModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBomber;
import nautilus.game.arcade.kit.perks.PerkDestructor;
import nautilus.game.arcade.ore.OreHider;
import nautilus.game.arcade.ore.OreObsfucation;
import nautilus.game.arcade.stats.*;
@ -38,14 +46,19 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class Bridge extends TeamGame implements OreObsfucation
{
@ -54,29 +67,19 @@ public class Bridge extends TeamGame implements OreObsfucation
*/
private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE };
//Bridge Timer
private int _bridgeTime = 600000;
/**
* The number of milliseconds from the game start time til the bridges should be built.
*/
private static final long BRIDGE_TIME = TimeUnit.MINUTES.toMillis(10);
private static final String CUSTOM_BRIDGE_KEY = "TYPE";
//Bridge
private long _bridgeTime = BRIDGE_TIME;
private boolean _bridgesDown = false;
//Wood Bridge
private ArrayList<Location> _woodBridge = new ArrayList<Location>();
private HashMap<Location, Integer> _woodBridgeBlocks = null;
//Lava Bridge
private ArrayList<Location> _lavaBridge = new ArrayList<Location>();
private ArrayList<Location> _lavaSource = new ArrayList<Location>();
//Lilly Pad Bridge
private NautHashMap<Location, Long> _lillyPads = new NautHashMap<Location, Long>();
private BridgeAnimation _animation;
private CustomBridgeAnimation[] _customAnimations;
//Mushrooms
private NautHashMap<Location, Long> _mushroomStem = new NautHashMap<Location, Long>();
private NautHashMap<Location, Long> _mushroomTop = new NautHashMap<Location, Long>();
private boolean _stemsGrown = false;
//Ice
private ArrayList<Location> _iceBridge = new ArrayList<Location>();
private HashSet<BridgePart> _bridgeParts = new HashSet<BridgePart>();
//Animals
@ -97,14 +100,16 @@ public class Bridge extends TeamGame implements OreObsfucation
private int _buildHeight = -1;
//Player Respawn
private HashSet<String> _usedLife = new HashSet<String>();
private Set<String> _usedLife = new HashSet<>();
//Tourney Mode
private boolean _tournament;
private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>();
private long _tournamentKillMessageTimer = 0;
private final Map<GameTeam, Location> _averageSpawns = new HashMap<>();
@SuppressWarnings("unchecked")
public Bridge(ArcadeManager manager)
{
this(manager, GameType.Bridge);
@ -135,7 +140,6 @@ public class Bridge extends TeamGame implements OreObsfucation
new KitApple(manager),
new KitBerserker(manager),
new KitBrawler(manager),
new KitMammoth(manager),
new KitArcher(manager),
new KitMiner(manager),
new KitBomber(manager),
@ -154,36 +158,14 @@ public class Bridge extends TeamGame implements OreObsfucation
"The last team alive wins!"
});
List<Kit> kits = Lists.newArrayList(GetKits());
List<Kit> finalKits = Lists.newArrayList(kits);
boolean foundBrawler = false;
for(int i = 0; i < kits.size(); i++)
{
Kit kit = kits.get(i);
if(kit.GetName().equalsIgnoreCase("Brawler"))
{
if(!foundBrawler)
{
foundBrawler = true;
}
else
{
finalKits.remove(i);
}
}
}
setKits(finalKits.toArray(new Kit[finalKits.size()]));
_ore = new OreHider();
// Flags
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000;
GameTimeout = Manager.IsTournamentServer() ? TimeUnit.MINUTES.toMillis(90) : TimeUnit.MINUTES.toMillis(60);
Manager.GetExplosion().SetLiquidDamage(false);
this.StrictAntiHack = true;
StrictAntiHack = true;
DamageSelf = true;
@ -204,11 +186,7 @@ public class Bridge extends TeamGame implements OreObsfucation
WorldTimeSet = 2000;
WorldWaterDamage = 0;
WorldBoundaryKill = false;
new CompassModule()
.setGiveCompassToAlive(true)
.register(this);
WorldBoundaryKill = true;
DeathDropItems = true;
@ -229,62 +207,145 @@ public class Bridge extends TeamGame implements OreObsfucation
"Killing yourself counts as -1 team kill.",
"Team with the most kills wins!"
};
_tournament = true;
}
_customAnimations = new CustomBridgeAnimation[] {
new RandomCustomBridgeAnimation(this),
new RadiusCustomBridgeAnimation(this)
};
new CompassModule()
.setGiveCompassToAlive(true)
.register(this);
_tournament = Manager.IsTournamentServer();
// So that we can be 110% sure
for (Kit kit : GetKits())
{
if (kit instanceof KitDestructor)
{
((KitDestructor) kit).SetEnabled(false);
break;
}
}
registerDebugCommand(new DebugCommand("bridge", getArcadeManager().getGameCommandRank())
{
@Override
public void Execute(Player caller, String[] args)
{
caller.sendMessage(F.main("Debug", "Spawning the bridges."));
_bridgeTime = 3000;
}
});
registerDebugCommand(new DebugCommand("bridgeinfo", getArcadeManager().getGameCommandRank())
{
@Override
public void Execute(Player caller, String[] args)
{
if (_animation == null || !(_animation instanceof CustomBridgeAnimation))
{
caller.sendMessage(F.main("Debug", "The bridge animation for this map isn't a custom one."));
return;
}
caller.sendMessage(F.main("Debug", "Bridge Info:"));
caller.sendMessage(_animation.toString());
}
});
}
@EventHandler
public void PlayerOut(final PlayerDeathOutEvent event)
public void prepare(GameStateChangeEvent event)
{
if (_bridgesDown)
return;
Player player = event.GetPlayer();
if (!_usedLife.contains(player.getName()))
if (event.GetState() != GameState.Prepare)
{
_usedLife.add(player.getName());
UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + "."));
event.setCancelled(true);
return;
}
}
Manager.runSyncLater(() -> _animation.onParse(), 10);
}
@EventHandler(priority = EventPriority.MONITOR)
public void GameStateChange(GameStateChangeEvent event)
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
{
WorldWaterDamage = 4;
}
String name = WorldData.MapName;
if (WorldWaterDamage > 0)
{
if (WorldData.MapName.equals("Volcanic Islands"))
if (name.equals("Volcanic Islands"))
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Boiling Hot", 10, 60, 20);
else if (WorldData.MapName.equals("Icelands"))
}
else if (name.equals("Icelands"))
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Freezing Cold", 10, 60, 20);
}
else
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Deadly", 10, 60, 20);
}
}
}
//parse
@Override
public void ParseData()
{
ParseLavaBridge();
ParseWoodBridge();
ParseIceBridge();
ParseLillyPad();
ParseMushrooms();
// Now we need to decide on what bridge animation.
typeLoop : for (BridgeAnimationType type : BridgeAnimationType.values())
{
for (String colours : type.getColoursUsed())
{
if (WorldData.GetDataLocs(colours).isEmpty())
{
continue typeLoop;
}
}
_animation = type.createInstance(this);
break;
}
// If none of the premade ones are usable then we need a custom one!
if (_animation == null)
{
locationLoop : for (String key : WorldData.GetAllCustomLocs().keySet())
{
if (!key.startsWith(CUSTOM_BRIDGE_KEY))
{
continue;
}
String[] split = key.split(" ");
if (split.length < 2)
{
continue;
}
String subKey = split[1];
for (CustomBridgeAnimation animation : _customAnimations)
{
if (animation.getTypeKey().equalsIgnoreCase(subKey))
{
_animation = animation;
break locationLoop;
}
}
}
}
ParseChests();
ParseOre(WorldData.GetCustomLocs("73")); // Red
@ -403,8 +464,6 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
public void ParseOre(ArrayList<Location> teamOre)
{
int coal = (int) ((teamOre.size() / 32d) * _oreDensity);
@ -625,368 +684,45 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
protected void ParseWoodBridge() {
_woodBridge = new ArrayList<Location>();
// Load Wood In
for (Location loc : WorldData.GetDataLocs("BROWN")) {
_woodBridge.add(loc.getBlock().getLocation());
}
for (Location loc : WorldData.GetDataLocs("GRAY")) {
_woodBridge.add(loc.getBlock().getLocation());
_woodBridge.add(loc.getBlock().getRelative(BlockFace.UP)
.getLocation());
}
// Determine Wood Block
_woodBridgeBlocks = new HashMap<Location, Integer>();
for (Location loc : _woodBridge) {
if (_woodBridge.contains(loc.getBlock().getRelative(BlockFace.DOWN)
.getLocation())) {
_woodBridgeBlocks.put(loc, 85);
}
if (_woodBridge.contains(loc.getBlock().getRelative(BlockFace.UP)
.getLocation())) {
_woodBridgeBlocks.put(loc, 17);
}
if (!_woodBridgeBlocks.containsKey(loc)) {
_woodBridgeBlocks.put(loc, 126);
}
}
}
protected void ParseLavaBridge() {
for (Location loc : WorldData.GetDataLocs("RED")) {
_lavaBridge.add(loc.getBlock().getLocation());
}
for (Location loc : WorldData.GetDataLocs("ORANGE")) {
_lavaBridge.add(loc.getBlock().getLocation());
_lavaBridge.add(loc.getBlock().getRelative(BlockFace.UP)
.getLocation());
}
_lavaSource = WorldData.GetDataLocs("BLACK");
}
protected void ParseIceBridge()
{
_iceBridge = WorldData.GetDataLocs("LIGHT_BLUE");
}
protected void ParseMushrooms()
{
for (Location loc : WorldData.GetCustomLocs("21"))
{
_mushroomStem.put(loc, 0L);
loc.getBlock().setType(Material.AIR);
}
for (Location loc : WorldData.GetDataLocs("PURPLE"))
{
_mushroomTop.put(loc, 0L);
}
}
protected void ParseLillyPad()
{
for (Location loc : WorldData.GetDataLocs("LIME"))
{
_lillyPads.put(loc, 0L);
}
}
@EventHandler
public void BridgeBuild(UpdateEvent event)
public void BridgeBuild(UpdateEvent event)
{
if (!IsLive())
if (!IsLive() || !UtilTime.elapsed(GetStateTime(), _bridgeTime))
{
return;
}
if (event.getType() != UpdateType.FASTEST)
return;
if (_animation != null)
{
_animation.onUpdate(event.getType());
}
if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime))
if (event.getType() != UpdateType.FAST)
{
return;
}
if (!_bridgesDown)
{
_bridgesDown = true;
// WorldBorderModule borderModule = getModule(WorldBorderModule.class);
//
// for (Player player : GetPlayers(true))
// {
// borderModule.setSize(player, 10000);
// }
Manager.GetExplosion().SetLiquidDamage(true);
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!");
}
Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!");
UtilTextMiddle.display(C.cRedB + "ALERT", "The BRIDGES ARE SPAWNING!");
_bridgesDown = true;
for (Kit kit : this.GetKits())
{
if (kit instanceof KitDestructor)
for (Kit kit : GetKits())
{
((KitDestructor)kit).SetEnabled(true);
}
}
BuildWood();
BuildLava();
BuildIce();
BuildLillyPad();
buildMushroom();
}
protected void BuildLava()
{
for (int i = 0; i < 3; i++)
if (_lavaBridge != null && _lavaSource != null
&& !_lavaBridge.isEmpty() && !_lavaSource.isEmpty()) {
// Random Block
Location bestLoc = _lavaBridge.get(UtilMath.r(_lavaBridge
.size()));
if (bestLoc.getBlock().getRelative(BlockFace.DOWN)
.isLiquid())
continue;
_lavaBridge.remove(bestLoc);
Location source = _lavaSource.get(UtilMath.r(_lavaSource
.size()));
// Create Part
FallingBlock block = bestLoc.getWorld().spawnFallingBlock(
source, 87, (byte) 0);
BridgePart part = new BridgePart(block, bestLoc, true);
_bridgeParts.add(part);
// Sound
source.getWorld().playSound(source, Sound.EXPLODE,
5f * (float) Math.random(),
0.5f + (float) Math.random());
}
}
protected void BuildLillyPad()
{
for (int i = 0; i < 3; i++)
if (_lillyPads != null && !_lillyPads.isEmpty())
{
// Random Block
Location loc = UtilAlg.Random(_lillyPads.keySet());
if (!UtilTime.elapsed(_lillyPads.get(loc), 8000))
continue;
if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
continue;
_lillyPads.remove(loc);
MapUtil.QuickChangeBlockAt(loc, Material.WATER_LILY);
// Sound
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 111);
}
}
@EventHandler
public void breakLillyPad(BlockBreakEvent event)
{
if (event.getBlock().getType() != Material.WATER_LILY)
return;
_lillyPads.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
}
protected void buildMushroom()
{
if (_mushroomStem != null && !_mushroomStem.isEmpty())
{
for (int i=0 ; i<4 && !_mushroomStem.isEmpty() ; i++)
{
double lowestY = 0;
Location lowestLoc = null;
for (Location loc : _mushroomStem.keySet())
if (kit instanceof KitDestructor)
{
if (!UtilTime.elapsed(_mushroomStem.get(loc), 6000))
continue;
if (lowestLoc == null || loc.getY() < lowestY)
{
lowestY = loc.getY();
lowestLoc = loc;
}
((KitDestructor) kit).SetEnabled(true);
}
if (lowestLoc == null)
continue;
_mushroomStem.remove(lowestLoc);
MapUtil.QuickChangeBlockAt(lowestLoc, 100, (byte)15);
}
}
else
{
_stemsGrown = true;
}
if (_stemsGrown && _mushroomTop != null && !_mushroomTop.isEmpty())
{
int attempts = 0;
int done = 0;
while (done < 6 && attempts < 400)
{
attempts++;
// Random Block
Location loc = UtilAlg.Random(_mushroomTop.keySet());
if (!UtilTime.elapsed(_mushroomTop.get(loc), 6000))
continue;
Block block = loc.getBlock();
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR &&
block.getRelative(BlockFace.NORTH).getType() == Material.AIR &&
block.getRelative(BlockFace.EAST).getType() == Material.AIR &&
block.getRelative(BlockFace.SOUTH).getType() == Material.AIR &&
block.getRelative(BlockFace.WEST).getType() == Material.AIR)
continue;
_mushroomTop.remove(loc);
MapUtil.QuickChangeBlockAt(block.getLocation(), 99, (byte)14);
done++;
}
}
}
@EventHandler
public void breakMushroom(BlockBreakEvent event)
{
if (event.isCancelled())
return;
if (event.getBlock().getTypeId() == 100 &&
WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5)))
{
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
_mushroomStem.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
}
if (event.getBlock().getTypeId() == 99 &&
WorldData.GetDataLocs("PURPLE").contains(event.getBlock().getLocation().add(0.5, 0, 0.5)))
{
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
_mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
}
}
protected void BuildIce()
{
if (_iceBridge == null || _iceBridge.isEmpty() || UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
{
WorldData.World.setStorm(false);
return;
}
WorldData.World.setStorm(true);
int attempts = 0;
int done = 0;
while (done < 5 && attempts < 400)
{
attempts++;
// Random Block
Location loc = _iceBridge.get(UtilMath.r(_iceBridge.size()));
Block block = loc.getBlock().getRelative(BlockFace.DOWN);
if (!block.isLiquid())
continue;
if (block.getRelative(BlockFace.NORTH).isLiquid() &&
block.getRelative(BlockFace.EAST).isLiquid() &&
block.getRelative(BlockFace.SOUTH).isLiquid() &&
block.getRelative(BlockFace.WEST).isLiquid())
continue;
_iceBridge.remove(loc);
if (Math.random() > 0.25)
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.PACKED_ICE);
else
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE);
done++;
}
}
protected void BuildWood()
{
if (_woodBridgeBlocks != null && !_woodBridgeBlocks.isEmpty())
{
ArrayList<Location> toDo = new ArrayList<Location>();
BlockFace[] faces = new BlockFace[] { BlockFace.NORTH,
BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
for (Location loc : _woodBridgeBlocks.keySet())
{
if (_woodBridgeBlocks.get(loc) == 17)
{
int adjacent = 0;
for (BlockFace face : faces)
if (loc.getBlock().getRelative(face).getTypeId() != 0)
adjacent++;
if (adjacent > 0)
toDo.add(loc);
} else if (_woodBridgeBlocks.get(loc) == 85)
{
if (loc.getBlock().getRelative(BlockFace.DOWN).getTypeId() == 0)
continue;
toDo.add(loc);
} else if (_woodBridgeBlocks.get(loc) == 126)
{
int adjacent = 0;
for (BlockFace face : faces)
if (loc.getBlock().getRelative(face).getTypeId() != 0)
adjacent++;
if (adjacent > 0)
toDo.add(loc);
}
}
if (toDo.size() == 0)
return;
for (Location loc : toDo)
{
int id = _woodBridgeBlocks.remove(loc);
Location source = loc.clone().add(0, 30, 0);
// Create Part
FallingBlock block = loc.getWorld().spawnFallingBlock(source,
id, (byte) 0);
block.setVelocity(new Vector(0, -1, 0));
BridgePart part = new BridgePart(block, loc, false);
_bridgeParts.add(part);
}
}
}
@ -1106,7 +842,7 @@ public class Bridge extends TeamGame implements OreObsfucation
while (!UtilBlock.airFoliage(block))
{
block = block.getRelative(BlockFace.UP);
if (block.getY() >= 256)
break;
}
@ -1119,15 +855,15 @@ public class Bridge extends TeamGame implements OreObsfucation
break;
}
block = block.getRelative(BlockFace.UP);
if (block.getTypeId() == 0)
if (block.getType() != Material.SNOW)
{
if (Math.random() > 0.5)
block.setTypeId(39);
else
block.setTypeId(40);
block = block.getRelative(BlockFace.UP);
}
if (Math.random() > 0.5)
block.setTypeId(39);
else
block.setTypeId(40);
}
}
@ -1341,6 +1077,16 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
@EventHandler
public void diamondOreExplode(PerkBomber.BomberExplodeDiamondBlock event)
{
event.setSpawnDrop(false);
event.getBlock().setType(Material.AIR);
Item item = event.getBlock().getWorld().dropItem(event.getBlock().getLocation().add(.5, .5, .5), new ItemStack(Material.DIAMOND));
item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId()));
}
@EventHandler
public void itemPickup(PlayerPickupItemEvent event)
{
@ -1515,7 +1261,7 @@ public class Bridge extends TeamGame implements OreObsfucation
else
{
Scoreboard.write(C.cYellow + C.Bold + "Time Left");
Scoreboard.write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0));
Scoreboard.write(UtilTime.MakeStr(GameTimeout - (System.currentTimeMillis() - GetStateTime()), 0));
}
Scoreboard.draw();
@ -1681,7 +1427,7 @@ public class Bridge extends TeamGame implements OreObsfucation
{
_tournamentKillMessageTimer = System.currentTimeMillis();
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!");
Announce(C.cRed + C.Bold + "ALERT: " + C.Reset + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!");
}
}
@ -1874,23 +1620,34 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
// @EventHandler
// public void liquidBlockDeny(BlockBreakEvent event)
// {
// if (_bridgesDown)
// return;
//
// if (!IsAlive(event.getPlayer()))
// return;
//
// if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || event.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP).isLiquid())
// {
// UtilPlayer.message(event.getPlayer(), F.main("Game",
// "Cannot tunnel under liquids."));
//
// event.setCancelled(true);
// }
// }
@EventHandler(priority=EventPriority.HIGHEST)
public void revivePlayer(CustomDamageEvent event)
{
if (!IsLive() || event.isCancelled() || _bridgesDown || !(event.GetDamageeEntity() instanceof Player))
{
return;
}
Player player = event.GetDamageePlayer();
if (player.getHealth() - event.GetDamage() > 0)
{
return;
}
if (!_usedLife.contains(player.getName()))
{
_usedLife.add(player.getName());
UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + "."));
UtilServer.broadcast(F.main("Game", GetTeam(player).GetColor() + player.getName()) + C.cGray + " fell into the void.");
player.setFallDistance(0);
GetTeam(player).SpawnTeleport(player);
player.setHealth(20);
event.SetCancelled("Early Game Revive");
}
}
@EventHandler
public void vehicleDeny(PlayerInteractEvent event)
@ -1915,16 +1672,6 @@ public class Bridge extends TeamGame implements OreObsfucation
else
return 12;
}
@EventHandler
public void debug(PlayerCommandPreprocessEvent event)
{
if (Manager.GetClients().hasRank(event.getPlayer(), Rank.ADMIN) && event.getMessage().contains("/oretoggle"))
_ore.ToggleVisibility();
if (Manager.GetClients().hasRank(event.getPlayer(), Rank.ADMIN) && event.getMessage().contains("/bridge"))
_bridgeTime = 30000;
}
@EventHandler
public void disableIceForm(BlockFormEvent event)
@ -1940,6 +1687,83 @@ public class Bridge extends TeamGame implements OreObsfucation
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot pickup liquids before the bridges have fallen."));
event.setCancelled(true);
}
@EventHandler
public void disableDoors(CraftItemEvent event)
{
if (_bridgesDown)
{
return;
}
Material type = event.getRecipe().getResult().getType();
if (type == Material.WOOD_DOOR || type == Material.IRON_DOOR)
{
event.setResult(null);
event.setCancelled(true);
}
}
@EventHandler
public void disableDoors(PlayerPickupItemEvent event)
{
if (_bridgesDown)
{
return;
}
Material type = event.getItem().getItemStack().getType();
if (type == Material.WOOD_DOOR || type == Material.IRON_DOOR)
{
event.getItem().remove();
event.setCancelled(true);
}
}
@EventHandler
public void updateBorder(UpdateEvent event)
{
if (!IsLive() || event.getType() != UpdateType.FAST || _bridgesDown)
{
return;
}
for (GameTeam team : GetTeamList())
{
List<Location> border = WorldData.GetCustomLocs("BORDER " + team.getDisplayName());
if (border.size() < 2)
{
continue;
}
Location one = border.get(0);
Location two = border.get(1);
Location average = _averageSpawns.computeIfAbsent(team, k -> UtilAlg.getAverageLocation(team.GetSpawns()));
one.setY(0);
two.setY(256);
for (Player player : team.GetPlayers(true))
{
if (player.getGameMode() != GameMode.SURVIVAL)
{
continue;
}
Location location = player.getLocation();
if (!UtilAlg.inBoundingBox(location, one, two))
{
player.setVelocity(UtilAlg.getTrajectory(location, average).multiply(2).add(new Vector(0, 0.5, 0)));
player.sendMessage(C.cRedB + "STAY ON YOUR ISLAND!");
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.5F);
}
}
}
}
public void setBridgeTime(int time)
{
@ -1961,6 +1785,11 @@ public class Bridge extends TeamGame implements OreObsfucation
return _chestLoot;
}
public HashSet<BridgePart> getBridgeParts()
{
return _bridgeParts;
}
public boolean bridgesDown()
{
return _bridgesDown;

View File

@ -0,0 +1,45 @@
package nautilus.game.arcade.game.games.bridge.animation;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.BridgePart;
import nautilus.game.arcade.world.WorldData;
public abstract class BridgeAnimation
{
public static final int AVERAGE_BRIDGE_BLOCKS = 3000;
protected final Bridge _bridge;
protected final WorldData _worldData;
public BridgeAnimation(Bridge bridge)
{
_bridge = bridge;
_worldData = bridge.WorldData;
}
public abstract void onParse();
public abstract void onUpdate(UpdateType type);
public void registerBridgePart(BridgePart part)
{
_bridge.getBridgeParts().add(part);
}
public boolean isAir(Location location)
{
return isAir(location.getBlock());
}
public boolean isAir(Block block)
{
return block.getType() == Material.AIR;
}
}

View File

@ -0,0 +1,44 @@
package nautilus.game.arcade.game.games.bridge.animation;
import nautilus.game.arcade.game.games.bridge.Bridge;
public enum BridgeAnimationType
{
WOOD(WoodBridgeAnimation.class, "BROWN", "GRAY"),
ICE(IceBridgeAnimation.class, "LIGHT_BLUE"),
LAVA(LavaBridgeAnimation.class, "BLACK", "RED", "ORANGE"),
LILLY(LillyPadBridgeAnimation.class, "LIME"),
MUSHROOM(MushroomBridgeAnimation.class, "PURPLE")
;
private final Class<? extends BridgeAnimation> _clazz;
private final String[] _coloursUsed;
private BridgeAnimationType(Class<? extends BridgeAnimation> clazz, String... coloursUsed)
{
_clazz = clazz;
_coloursUsed = coloursUsed;
}
public BridgeAnimation createInstance(Bridge bridge)
{
try
{
return _clazz.cast(_clazz.getConstructor(Bridge.class).newInstance(bridge));
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
public String[] getColoursUsed()
{
return _coloursUsed;
}
}

View File

@ -0,0 +1,79 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class IceBridgeAnimation extends BridgeAnimation
{
private List<Location> _iceBridge;
public IceBridgeAnimation(Bridge bridge)
{
super(bridge);
_iceBridge = new ArrayList<>(AVERAGE_BRIDGE_BLOCKS);
}
@Override
public void onParse()
{
_iceBridge = _worldData.GetDataLocs("LIGHT_BLUE");
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FASTEST || _iceBridge.isEmpty())
{
return;
}
int attempts = 0;
int done = 0;
while (done < 5 && attempts < 400)
{
attempts++;
// Random Block
Location loc = UtilAlg.Random(_iceBridge);
Block block = loc.getBlock().getRelative(BlockFace.DOWN);
if (!block.isLiquid())
{
continue;
}
if (block.getRelative(BlockFace.NORTH).isLiquid() && block.getRelative(BlockFace.EAST).isLiquid() && block.getRelative(BlockFace.SOUTH).isLiquid() && block.getRelative(BlockFace.WEST).isLiquid())
{
continue;
}
_iceBridge.remove(loc);
if (Math.random() > 0.25)
{
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.PACKED_ICE);
}
else
{
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE);
}
done++;
}
}
}

View File

@ -0,0 +1,84 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.FallingBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.BridgePart;
public class LavaBridgeAnimation extends BridgeAnimation
{
private List<Location> _lavaSource;
private List<Location> _lavaBridge;
public LavaBridgeAnimation(Bridge bridge)
{
super(bridge);
_lavaSource = new ArrayList<>();
_lavaBridge = new ArrayList<>(AVERAGE_BRIDGE_BLOCKS);
}
@Override
public void onParse()
{
for (Location loc : _worldData.GetDataLocs("RED"))
{
_lavaBridge.add(loc.getBlock().getLocation());
}
for (Location loc : _worldData.GetDataLocs("ORANGE"))
{
_lavaBridge.add(loc.getBlock().getLocation());
_lavaBridge.add(loc.getBlock().getRelative(BlockFace.UP).getLocation());
}
_lavaSource = _worldData.GetDataLocs("BLACK");
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FASTEST)
{
return;
}
for (int i = 0; i < 3; i++)
{
if (!_lavaBridge.isEmpty() && !_lavaSource.isEmpty())
{
// Random Block
Location bestLoc = _lavaBridge.get(UtilMath.r(_lavaBridge.size()));
if (bestLoc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
{
continue;
}
_lavaBridge.remove(bestLoc);
Location source = _lavaSource.get(UtilMath.r(_lavaSource.size()));
// Create Part
FallingBlock block = bestLoc.getWorld().spawnFallingBlock(source, Material.NETHERRACK, (byte) 0);
BridgePart part = new BridgePart(block, bestLoc, true);
registerBridgePart(part);
// Sound
source.getWorld().playSound(source, Sound.EXPLODE, 5f * (float) Math.random(), 0.5f + (float) Math.random());
}
}
}
}

View File

@ -0,0 +1,65 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class LillyPadBridgeAnimation extends BridgeAnimation
{
private Map<Location, Long> _lillyPads = new HashMap<>();
public LillyPadBridgeAnimation(Bridge bridge)
{
super(bridge);
}
@Override
public void onParse()
{
for (Location loc : _worldData.GetDataLocs("LIME"))
{
_lillyPads.put(loc, 0L);
}
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FASTEST)
return;
for (int i = 0; i < 3; i++)
{
if (_lillyPads != null && !_lillyPads.isEmpty())
{
// Random Block
Location loc = UtilAlg.Random(_lillyPads.keySet());
if (!UtilTime.elapsed(_lillyPads.get(loc), 8000))
continue;
if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
continue;
_lillyPads.remove(loc);
MapUtil.QuickChangeBlockAt(loc, Material.WATER_LILY);
// Sound
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 111);
}
}
}
}

View File

@ -0,0 +1,107 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class MushroomBridgeAnimation extends BridgeAnimation
{
private Map<Location, Long> _mushroomStem = new HashMap<>();
private Map<Location, Long> _mushroomTop = new HashMap<>();
private boolean _stemsGrown = false;
public MushroomBridgeAnimation(Bridge bridge)
{
super(bridge);
}
@Override
public void onParse()
{
for (Location loc : _worldData.GetCustomLocs("21"))
{
_mushroomStem.put(loc, 0L);
loc.getBlock().setType(Material.AIR);
}
for (Location loc : _worldData.GetDataLocs("PURPLE"))
{
_mushroomTop.put(loc, 0L);
}
}
@Override
public void onUpdate(UpdateType type)
{
if (_mushroomStem != null && !_mushroomStem.isEmpty())
{
for (int i = 0; i < 4 && !_mushroomStem.isEmpty(); i++)
{
double lowestY = 0;
Location lowestLoc = null;
for (Location loc : _mushroomStem.keySet())
{
if (!UtilTime.elapsed(_mushroomStem.get(loc), 6000))
continue;
if (lowestLoc == null || loc.getY() < lowestY)
{
lowestY = loc.getY();
lowestLoc = loc;
}
}
if (lowestLoc == null)
continue;
_mushroomStem.remove(lowestLoc);
MapUtil.QuickChangeBlockAt(lowestLoc, 100, (byte) 15);
}
}
else
{
_stemsGrown = true;
}
if (_stemsGrown && _mushroomTop != null && !_mushroomTop.isEmpty())
{
int attempts = 0;
int done = 0;
while (done < 6 && attempts < 400)
{
attempts++;
// Random Block
Location loc = UtilAlg.Random(_mushroomTop.keySet());
if (!UtilTime.elapsed(_mushroomTop.get(loc), 6000))
continue;
Block block = loc.getBlock();
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR && block.getRelative(BlockFace.NORTH).getType() == Material.AIR && block.getRelative(BlockFace.EAST).getType() == Material.AIR && block.getRelative(BlockFace.SOUTH).getType() == Material.AIR && block.getRelative(BlockFace.WEST).getType() == Material.AIR)
continue;
_mushroomTop.remove(loc);
MapUtil.QuickChangeBlockAt(block.getLocation(), 99, (byte) 14);
done++;
}
}
}
}

View File

@ -0,0 +1,129 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.FallingBlock;
import org.bukkit.util.Vector;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.BridgePart;
public class WoodBridgeAnimation extends BridgeAnimation
{
private static final BlockFace[] FACES = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
private static final int Y_MOD = 30;
private final Map<Location, Material> _woodBridge;
public WoodBridgeAnimation(Bridge bridge)
{
super(bridge);
_woodBridge = new HashMap<>(AVERAGE_BRIDGE_BLOCKS);
}
@Override
public void onParse()
{
onParse(_worldData.GetDataLocs("BROWN"), false);
onParse(_worldData.GetDataLocs("GRAY"), true);
}
public void onParse(List<Location> locations, boolean aboveBelow)
{
for (Location location : locations)
{
if (aboveBelow)
{
_woodBridge.put(location.getBlock().getRelative(BlockFace.UP).getLocation(), Material.FENCE);
_woodBridge.put(location, Material.LOG);
}
else
{
_woodBridge.put(location, Material.WOOD_STEP);
}
}
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FASTEST)
{
return;
}
List<Location> toDo = new ArrayList<>();
for (Location location : _woodBridge.keySet())
{
Material material = _woodBridge.get(location);
if (material == Material.LOG)
{
int adjacent = 0;
for (BlockFace face : FACES)
{
if (!isAir(location.getBlock().getRelative(face)))
{
adjacent++;
}
}
if (adjacent > 0)
{
toDo.add(location);
}
}
else if (material == Material.FENCE)
{
if (!isAir(location.getBlock().getRelative(BlockFace.DOWN)))
{
toDo.add(location);
}
}
else if (material == Material.WOOD_STEP)
{
int adjacent = 0;
for (BlockFace face : FACES)
{
if (!isAir(location.getBlock().getRelative(face)))
{
adjacent++;
}
}
if (adjacent > 0)
{
toDo.add(location);
}
}
}
if (toDo.isEmpty())
{
return;
}
for (Location location : toDo)
{
Material material = _woodBridge.remove(location);
Location source = location.clone().add(0, Y_MOD, 0);
// Create Part
FallingBlock block = location.getWorld().spawnFallingBlock(source, material, (byte) 0);
block.setVelocity(new Vector(0, -1, 0));
BridgePart part = new BridgePart(block, location, false);
registerBridgePart(part);
}
}
}

View File

@ -0,0 +1,251 @@
package nautilus.game.arcade.game.games.bridge.animation.custom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation;
public abstract class CustomBridgeAnimation extends BridgeAnimation
{
private static final String BLOCK_IDS_KEY = "BLOCK_IDS";
private static final String RATE_KEY = "RATE";
private static final String PARTICLE_KEY = "PARTICLE";
private static final String SOUND_KEY = "SOUND";
private static final String REGION_KEY = "BRIDGE";
protected final BlockRestore _restore;
private final String _typeKey;
protected final Map<Location, Double> _bridgeBlocks;
// Configuration
protected List<Integer> _blockIds;
protected int _rate;
protected ParticleType _particle;
// Sound
protected Sound _sound;
protected float _pitch;
protected double _maxDistance;
public CustomBridgeAnimation(Bridge bridge, String typeKey)
{
super(bridge);
_restore = bridge.getArcadeManager().GetBlockRestore();
_typeKey = typeKey;
_bridgeBlocks = new HashMap<>(AVERAGE_BRIDGE_BLOCKS);
// Defaults
// Wood, Logs, Fences
_blockIds = Arrays.asList(5, 17, 85);
_rate = 1;
_particle = ParticleType.BLOCK_DUST;
}
@Override
public void onParse()
{
List<Integer> blockIds = new ArrayList<>();
for (String key : _worldData.GetAllCustomLocs().keySet())
{
String[] split = key.split(" ");
String subKey = split[0];
if (split.length < 2)
{
continue;
}
switch (subKey)
{
case BLOCK_IDS_KEY:
// Set the block ids that the animation will use
for (int i = 1; i < split.length; i++)
{
try
{
blockIds.add(Integer.parseInt(split[i]));
}
catch (NumberFormatException e)
{
continue;
}
}
break;
case RATE_KEY:
// Set the rate at which the animation will run at
try
{
_rate = Integer.parseInt(split[1]);
}
catch (NumberFormatException e)
{
continue;
}
break;
case PARTICLE_KEY:
// Set which type of particle will be displayed when a block
// spawns
try
{
_particle = ParticleType.valueOf(split[1]);
}
catch (IllegalArgumentException e)
{
continue;
}
break;
case SOUND_KEY:
// Set the sound and pitch that will be played when a block
// spawns
if (split.length < 3)
{
continue;
}
try
{
_sound = Sound.valueOf(split[1]);
}
catch (IllegalArgumentException e)
{
continue;
}
try
{
_pitch = Float.parseFloat(split[2]);
}
catch (NumberFormatException e)
{
continue;
}
break;
default:
break;
}
}
// Set configuration values
_blockIds = blockIds;
// Save all blocks in a big map.
for (String key : _worldData.GetAllCustomLocs().keySet())
{
if (!key.startsWith(REGION_KEY))
{
continue;
}
List<Location> locations = _worldData.GetCustomLocs(key);
if (locations.size() < 2)
{
continue;
}
for (Location location : locations)
{
location.getChunk().load();
}
for (Block block : UtilBlock.getInBoundingBox(locations.get(0), locations.get(1)))
{
if (!_blockIds.contains(block.getTypeId()) || _bridgeBlocks.containsKey(block))
{
continue;
}
double dist = UtilMath.offset2d(block.getLocation(), _bridge.GetSpectatorLocation());
if (dist > _maxDistance)
{
_maxDistance = dist;
}
_restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE);
_bridgeBlocks.put(block.getLocation(), dist);
}
}
}
public void onBlockSet(Block block)
{
World world = _worldData.World;
Location location = block.getLocation().add(0.5, 0.5, 0.5);
if (_particle != null)
{
if (_particle == ParticleType.BLOCK_DUST)
{
world.playEffect(location, Effect.STEP_SOUND, block.getType(), block.getData());
}
else
{
UtilParticle.PlayParticleToAll(_particle, block.getLocation(), 0.5F, 0.5F, 0.5F, 0.5F, 5, ViewDist.NORMAL);
}
}
if (_sound != null)
{
world.playSound(location, _sound, 1, _pitch);
}
}
public final String getTypeKey()
{
return _typeKey;
}
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("Type: " + _typeKey).append("\n");
builder.append("Bridge Blocks: " + _bridgeBlocks.size()).append("\n");
builder.append("Block Ids: " + _blockIds).append("\n");
builder.append("Rate: " + _rate).append("\n");
builder.append("Particle: " + (_particle == null ? "Null" : _particle.getFriendlyName())).append("\n");
builder.append("Sound: " + (_sound == null ? "Null" : _sound.toString() + " Pitch: " + _pitch)).append("\n");
builder.append("Max Distance: " + _maxDistance).append("\n");
return builder.toString();
}
}

View File

@ -0,0 +1,58 @@
package nautilus.game.arcade.game.games.bridge.animation.custom;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.block.Block;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class RadiusCustomBridgeAnimation extends CustomBridgeAnimation
{
private double _minDistance;
public RadiusCustomBridgeAnimation(Bridge bridge)
{
super(bridge, "RADIUS");
}
@Override
public void onParse()
{
super.onParse();
_minDistance = _maxDistance;
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.SEC)
{
return;
}
_minDistance -= _rate;
Iterator<Location> iterator = _bridgeBlocks.keySet().iterator();
while (iterator.hasNext())
{
Location location = iterator.next();
double dist = _bridgeBlocks.get(location);
if (dist > _minDistance)
{
Block block = location.getBlock();
_restore.restore(block);
onBlockSet(block);
iterator.remove();
}
}
}
}

View File

@ -0,0 +1,44 @@
package nautilus.game.arcade.game.games.bridge.animation.custom;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.block.Block;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class RandomCustomBridgeAnimation extends CustomBridgeAnimation
{
public RandomCustomBridgeAnimation(Bridge bridge)
{
super(bridge, "RANDOM");
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.TICK)
{
return;
}
Iterator<Location> iterator = _bridgeBlocks.keySet().iterator();
int i = 0;
while (iterator.hasNext() && i < _rate)
{
i++;
Location location = iterator.next();
Block block = location.getBlock();
_restore.restore(block);
onBlockSet(block);
iterator.remove();
}
}
}

View File

@ -21,7 +21,7 @@ public class KitApple extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkApple(10000)
new PerkApple(10000, 250)
};
private static final ItemStack IN_HAND = new ItemStack(Material.APPLE);
@ -36,4 +36,4 @@ public class KitApple extends ProgressingKit
{
}
}
}

View File

@ -22,12 +22,12 @@ public class KitArcher extends ProgressingKit
"Highly trained with a bow, probably an elf or something...",
" ",
"Begin the game with a Bow",
receiveArrowString(1, 20, 3),
receiveArrowString(1, 20, 4),
"Charge Bow to use " + C.cGreen + "Barrage"
};
private static final Perk[] PERKS = {
new PerkFletcher(20, 3, true),
new PerkFletcher(20, 4, true),
new PerkBarrage(5, 250, true, false),
};
@ -53,6 +53,6 @@ public class KitArcher extends ProgressingKit
Bridge bridge = (Bridge) Manager.GetGame();
if(!bridge.hasUsedRevive(player))
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(PLAYER_ITEMS);
}
}

View File

@ -25,7 +25,7 @@ public class KitBerserker extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkLeap("Beserker Leap", 1.2, 1.2, 8000),
new PerkLeap("Beserker Leap", 1.2, 1.2, 10000),
new PerkAxeman(),
};
@ -46,4 +46,4 @@ public class KitBerserker extends ProgressingKit
{
player.getInventory().addItem(PLAYER_ITEMS);
}
}
}

View File

@ -17,12 +17,12 @@ public class KitBomber extends ProgressingKit
private static final String[] DESCRIPTION = {
"Crazy bomb throwing guy.",
" ",
receiveItem("TNT", 1, 30, 2),
receiveItem("TNT", 1, 25, 2),
C.cYellow + "Click" + C.cWhite + " to throw TNT"
};
private static final Perk[] PERKS = {
new PerkBomber(30, 2, -1)
new PerkBomber(25, 2, -1)
};
private static final ItemStack IN_HAND = new ItemStack(Material.TNT);

View File

@ -20,8 +20,8 @@ public class KitBrawler extends ProgressingKit
"Giant and muscular, easily smacks others around.",
" ",
"Begin with an Iron Sword",
"Take " + C.cGreen + "75%" + C.cWhite + " knockback",
"Deal " + C.cGreen + "125%" + C.cWhite + " knockback",
"Take " + C.cGreen + "85%" + C.cWhite + " knockback",
"Deal " + C.cGreen + "115%" + C.cWhite + " knockback",
"Take " + C.cGreen + "-1" + C.cWhite + " damage from all attacks"
};

View File

@ -26,7 +26,7 @@ public class KitDestructor extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkDestructor(40, 2, 400, false)
new PerkDestructor(40, 2, 400, 3, false)
};
private static final Achievement[] ACHIEVEMENTS = {
@ -44,7 +44,7 @@ public class KitDestructor extends ProgressingKit
{
super(manager, "Destructor", "bridgedesctructor", KitAvailability.Achievement, 99999, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
this.setAchievementRequirements(ACHIEVEMENTS);
setAchievementRequirements(ACHIEVEMENTS);
}
@Override

View File

@ -14,7 +14,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
@ -29,7 +28,6 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.AbsorptionFix;
import nautilus.game.arcade.game.games.bridge.Bridge;
import net.md_5.bungee.api.ChatColor;
@ -72,38 +70,8 @@ public class OverpoweredBridge extends Bridge
public void ParseData()
{
_starterChests = new HashMap<>();
ParseLavaBridge();
ParseWoodBridge();
ParseIceBridge();
ParseLillyPad();
ParseMushrooms();
ParseChests();
ParseOre(WorldData.GetCustomLocs("73")); // Red
ParseOre(WorldData.GetCustomLocs("14")); // Yellow
ParseOre(WorldData.GetCustomLocs("129")); // Green
ParseOre(WorldData.GetCustomLocs("56")); // Blue
//Mass Teams
if (!WorldData.GetCustomLocs("152").isEmpty())
ParseOre(WorldData.GetCustomLocs("152"));
if (!WorldData.GetCustomLocs("41").isEmpty())
ParseOre(WorldData.GetCustomLocs("41"));
if (!WorldData.GetCustomLocs("133").isEmpty())
ParseOre(WorldData.GetCustomLocs("133"));
if (!WorldData.GetCustomLocs("57").isEmpty())
ParseOre(WorldData.GetCustomLocs("57"));
if (!WorldData.GetCustomLocs("100").isEmpty())
ParseOre(WorldData.GetCustomLocs("100"));
if (!WorldData.GetCustomLocs("86").isEmpty())
ParseOre(WorldData.GetCustomLocs("86"));
if (!WorldData.GetCustomLocs("103").isEmpty())
ParseOre(WorldData.GetCustomLocs("103"));
if (!WorldData.GetCustomLocs("22").isEmpty())
ParseOre(WorldData.GetCustomLocs("22"));
super.ParseData();
}
@EventHandler

View File

@ -28,7 +28,7 @@ public class KitBrawlAppler extends ProgressingKit
private static final Perk[] PERKS =
{
new PerkApple(3000)
new PerkApple(3000, 0)
};
private static final ItemStack IN_HAND = new ItemStack(Material.APPLE);

View File

@ -106,7 +106,7 @@ public class ChampionsCTF extends CaptureTheFlag
if (GetKit(player) == null)
{
SetKit(player, GetKits()[2], true);
player.closeInventory();
UtilPlayer.closeInventoryIfOpen(player);
}
}

View File

@ -98,7 +98,7 @@ public class ChampionsDominate extends Domination
if (GetKit(player) == null)
{
SetKit(player, GetKits()[2], true);
player.closeInventory();
UtilPlayer.closeInventoryIfOpen(player);
}
}

View File

@ -98,7 +98,7 @@ public class ChampionsTDM extends TeamDeathmatch
if (GetKit(player) == null)
{
SetKit(player, GetKits()[2], true);
player.closeInventory();
UtilPlayer.closeInventoryIfOpen(player);
}
}

View File

@ -196,7 +196,7 @@ public class TeamDeathmatch extends TeamGame
if (GetKit(player) == null)
{
SetKit(player, GetKits()[2], true);
player.closeInventory();
UtilPlayer.closeInventoryIfOpen(player);
}
}

View File

@ -1,8 +1,10 @@
package nautilus.game.arcade.game.games.dragonescape;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@ -200,6 +202,18 @@ public class DragonEscape extends SoloGame
this.WorldWaterDamage = 2;
}
@Override
public List<Player> getWinners()
{
if (GetState().ordinal() >= GameState.End.ordinal())
{
if (_winner == null)
return Collections.emptyList();
return Collections.singletonList(_winner);
}
return null;
}
@EventHandler
public void SpawnDragon(GameStateChangeEvent event)
{

View File

@ -511,7 +511,7 @@ public abstract class SuperSmash extends Game
if (announce)
{
player.closeInventory();
UtilPlayer.closeInventoryIfOpen(player);
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f);
UtilPlayer.message(player, F.main("Kit", "You equipped " + F.elem(kit.GetFormattedName() + " Kit") + "."));
kit.ApplyKit(player);

View File

@ -133,6 +133,7 @@ public class Snake extends SoloGame
this.CreatureAllowOverride = true;
Sheep sheep = player.getWorld().spawn(player.getLocation(), Sheep.class);
UtilEnt.addFlag(sheep, UtilEnt.FLAG_ENTITY_COMPONENT);
this.CreatureAllowOverride = false;
sheep.setColor(DyeColor.getByDyeData((byte) (i % 16)));
@ -447,6 +448,7 @@ public class Snake extends SoloGame
//Spawn
this.CreatureAllowOverride = true;
Sheep tail = loc.getWorld().spawn(loc, Sheep.class);
UtilEnt.addFlag(tail, UtilEnt.FLAG_ENTITY_COMPONENT);
this.CreatureAllowOverride = false;
tail.setRemoveWhenFarAway(false);

View File

@ -289,7 +289,6 @@ public abstract class UHC extends Game
.setGiveCompass(false)
.register(this);
new OreVeinEditorModule().removeNonAirVeins().register(this);
new AntiExpOrbModule().register(this);
new RejoinModule().register(this);
new AbsorptionFix(this);

View File

@ -1,10 +1,7 @@
package nautilus.game.arcade.game.modules;
import com.google.gson.JsonElement;
import mineplex.core.Managers;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.TeamGame;
import org.bukkit.event.Listener;
/**

View File

@ -19,6 +19,7 @@ import mineplex.core.common.util.UtilItem;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.GameTeam;
/**
* This module handles setting armor for team games such as Micro Battles. It allows you to set the player's armor
@ -67,11 +68,15 @@ public class TeamArmorModule extends Module
public void apply(Player player)
{
Color color = getGame().GetTeam(player).GetColorBase();
GameTeam gameTeam = getGame().GetTeam(player);
if (gameTeam == null)
return;
Color color = gameTeam.GetColorBase();
if (_giveTeamArmor)
{
String itemName = getGame().GetTeam(player).GetColor() + C.Bold + "Team Armor";
String itemName = gameTeam.GetColor() + C.Bold + "Team Armor";
_armorNames.add(itemName);
player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(color).setTitle(itemName).setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(color).setTitle(itemName).setUnbreakable(true).build());
@ -81,7 +86,7 @@ public class TeamArmorModule extends Module
if (_giveHotbarItem && getGame().InProgress())
{
String teamName = getGame().GetTeam(player).GetFormattedName();
String teamName = gameTeam.GetFormattedName();
_hotbarNames.add(teamName);
player.getInventory().setItem(8, new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(color).setTitle(teamName).setUnbreakable(true).build());
}

View File

@ -0,0 +1,116 @@
package nautilus.game.arcade.game.modules;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.Pair;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction;
import net.minecraft.server.v1_8_R3.WorldBorder;
public class WorldBorderModule extends Module implements IPacketHandler
{
private PacketHandler _packetHandler;
private Map<UUID, Double> _sizeToSet;
private Map<UUID, Pair<Double, Double>> _centerToSet;
@Override
protected void setup()
{
_packetHandler = getGame().getArcadeManager().getPacketHandler();
_sizeToSet = new HashMap<>();
_centerToSet = new HashMap<>();
}
@EventHandler(priority = EventPriority.LOWEST)
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
_packetHandler.addPacketHandler(this, PacketPlayOutWorldBorder.class);
}
@Override
public void handle(PacketInfo packetInfo)
{
UUID player = packetInfo.getPlayer().getUniqueId();
PacketPlayOutWorldBorder packet = (PacketPlayOutWorldBorder) packetInfo.getPacket();
try
{
Field actionField = packet.getClass().getDeclaredField("a");
actionField.setAccessible(true);
EnumWorldBorderAction action = (EnumWorldBorderAction) actionField.get(packet);
if (action == EnumWorldBorderAction.SET_SIZE)
{
Field sizeField = packet.getClass().getDeclaredField("e");
sizeField.setAccessible(true);
double newSize = _sizeToSet.get(player);
sizeField.set(packet, newSize);
}
else if (action == EnumWorldBorderAction.SET_CENTER)
{
Field xField = packet.getClass().getDeclaredField("c");
Field zField = packet.getClass().getDeclaredField("d");
xField.setAccessible(true);
zField.setAccessible(true);
Pair<Double, Double> pair = _centerToSet.get(player);
xField.set(packet, pair.getLeft());
zField.set(packet, pair.getRight());
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void cleanup()
{
_packetHandler.removePacketHandler(this);
}
public void setSize(Player player, double size)
{
_sizeToSet.put(player.getUniqueId(), size);
sendPacket(player, EnumWorldBorderAction.SET_SIZE);
}
public void setCenter(Player player, Location location)
{
_centerToSet.put(player.getUniqueId(), Pair.create(location.getX(), location.getZ()));
sendPacket(player, EnumWorldBorderAction.SET_CENTER);
}
private void sendPacket(Player player, EnumWorldBorderAction action)
{
WorldBorder border = ((CraftWorld) player.getWorld()).getHandle().getWorldBorder();
UtilPlayer.sendPacket(player, new PacketPlayOutWorldBorder(border, action));
}
}

View File

@ -18,6 +18,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.scheduler.BukkitRunnable;
@ -30,6 +31,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.donation.Donor;
import mineplex.core.menu.Menu;
import mineplex.core.progression.ProgressiveKit;
@ -53,6 +55,8 @@ import net.minecraft.server.v1_8_R3.World;
public abstract class ProgressingKit extends Kit implements ProgressiveKit
{
public static final String COOLDOWN = "Cooldown";
private static final FireworkEffect EFFECT = FireworkEffect.builder()
.withColor(Color.AQUA)
.with(Type.BALL)
@ -261,7 +265,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
Player bukkitPlayer = Bukkit.getPlayer(player);
bukkitPlayer.sendMessage(F.main("Kit", "Set " + C.cYellowB + getDisplayName() + C.cGray + " as your default kit."));
bukkitPlayer.closeInventory();
UtilPlayer.closeInventoryIfOpen(bukkitPlayer);
//Undefault any kits and update the DB
for (Kit kit : Manager.GetGame().GetKits())
{
@ -420,6 +424,11 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
return "Receive " + C.cGreen + amount + C.cWhite + " " + item + " every " + C.cGreen + time + C.cWhite + " second" + (time == 1 ? "" : "s") +
(max > 0 ? ". Max " + C.cGreen + max : "");
}
public static String receiveItem(String item, int amount)
{
return "Receive " + (amount == 1 ? (UtilText.startsWithVowel(item) ? "an" :" a") : C.cGreen + amount) + " " + item;
}
public static String click(boolean left, String comp)
{

View File

@ -21,14 +21,19 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Iterator;
public class PerkApple extends Perk implements IThrown
{
private long _spawnDelay;
public PerkApple(long delay)
private long _throwDelay;
public PerkApple(long delay, long throwDelay)
{
super("Apple Thrower", new String[]
{
@ -37,6 +42,7 @@ public class PerkApple extends Perk implements IThrown
});
_spawnDelay = delay;
_throwDelay = throwDelay;
}
@EventHandler
@ -80,6 +86,11 @@ public class PerkApple extends Perk implements IThrown
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, getMessage(player) + " Throw", _throwDelay, false, false))
{
return;
}
event.setCancelled(true);
@ -132,6 +143,23 @@ public class PerkApple extends Perk implements IThrown
}
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
if (!hasPerk(event.getEntity()))
{
return;
}
for (ItemStack itemStack : event.getDrops())
{
if (itemStack.getType() == Material.APPLE)
{
itemStack.setAmount((int) Math.ceil((double) itemStack.getAmount() / 2D));
}
}
}
private Material getMaterial(Player player)
{
if (Manager.getCosmeticManager().getGadgetManager().isKitModifierActive(KitModifier.Bridges_Apple_Potato, player))

View File

@ -39,18 +39,30 @@ public class PerkBomber extends Perk
}
private final Block _block;
private boolean _spawnDrop;
public BomberExplodeDiamondBlock(Player who, Block block)
{
super(who);
_block = block;
_spawnDrop = true;
}
public Block getBlock()
{
return _block;
}
public void setSpawnDrop(boolean b)
{
_spawnDrop = b;
}
public boolean shouldSpawnDrop()
{
return _spawnDrop;
}
}
private static final String THROWING_TNT_DISPLAY_NAME = F.item("Throwing TNT");
@ -265,8 +277,13 @@ public class PerkBomber extends Perk
if (block.getType() == Material.DIAMOND_ORE)
{
Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block));
block.breakNaturally();
BomberExplodeDiamondBlock explodeEvent = new BomberExplodeDiamondBlock(player, block);
UtilServer.CallEvent(explodeEvent);
if (explodeEvent.shouldSpawnDrop())
{
block.breakNaturally();
}
it.remove();
}
}

View File

@ -32,6 +32,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
@ -49,10 +50,12 @@ public class PerkDestructor extends Perk
private long _fallTime;
private double _damage;
private HashSet<String> _preparing = new HashSet<String>();
private HashMap<Block, Long> _blocks = new HashMap<Block, Long>();
public PerkDestructor(int spawnRate, int max, long fallTime, boolean enabled)
public PerkDestructor(int spawnRate, int max, long fallTime, double damage, boolean enabled)
{
super("Seismic Charge", new String[]
{
@ -64,7 +67,8 @@ public class PerkDestructor extends Perk
_spawnRate = spawnRate;
_max = max;
_fallTime = fallTime;
_damage = damage;
_enabled = enabled;
}
@ -203,7 +207,17 @@ public class PerkDestructor extends Perk
if (!proj.hasMetadata("Destructor"))
return;
for (Player hit : UtilPlayer.getNearby(proj.getLocation(), 3))
{
if (player.equals(hit))
{
continue;
}
Manager.GetDamage().NewDamageEvent(hit, player, proj, EntityDamageEvent.DamageCause.CUSTOM, _damage, true, true, true, proj.getName(), GetName());
}
for (Block block : UtilBlock.getInRadius(proj.getLocation(), 4).keySet())
{
if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.getType() == Material.BARRIER || block.isLiquid())
@ -226,49 +240,6 @@ public class PerkDestructor extends Perk
proj.getWorld().playSound(proj.getLocation(), Sound.EXPLODE, 1f, 0.5f);
proj.getWorld().playSound(proj.getLocation(), Sound.FIREWORK_TWINKLE, 2f, 0.5f);
}
// @EventHandler
// public void collide(PlayerTeleportEvent event)
// {
// if (Manager.GetGame() == null || !Manager.GetGame().IsLive())
// return;
//
// if (event.getCause() != TeleportCause.ENDER_PEARL)
// return;
//
// if (!Manager.IsAlive(event.getPlayer()))
// return;
//
// if (!Kit.HasKit(event.getPlayer()))
// return;
//
//
//
// for (Block block : UtilBlock.getInRadius(event.getTo(), 4).keySet())
// {
// if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.isLiquid())
// continue;
//
// //Event
// PerkDestructorBlockEvent blockEvent = new PerkDestructorBlockEvent(event.getPlayer(), block);
// UtilServer.getServer().getPluginManager().callEvent(blockEvent);
//
// if (!blockEvent.isCancelled())
// {
// _blocks.put(block, System.currentTimeMillis());
//
// block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
// }
// }
//
// UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.getTo(), 0f, 0f, 0f, 0f, 1,
// ViewDist.MAX, UtilServer.getPlayers());
//
// event.getTo().getWorld().playSound(event.getTo(), Sound.EXPLODE, 1f, 0.5f);
// event.getTo().getWorld().playSound(event.getTo(), Sound.FIREWORK_TWINKLE, 2f, 0.5f);
//
// event.setCancelled(true);
// }
@SuppressWarnings("deprecation")
@EventHandler
@ -294,7 +265,9 @@ public class PerkDestructor extends Perk
if (lowest != null)
{
if (lowest.getType() != Material.AIR && UtilBlock.airFoliage(lowest.getRelative(BlockFace.DOWN)))
Block down = lowest.getRelative(BlockFace.DOWN);
if (lowest.getType() != Material.AIR && (UtilBlock.airFoliage(down) || down.isLiquid()))
{
lowest.getWorld().playEffect(lowest.getLocation(), Effect.STEP_SOUND, lowest.getType());

View File

@ -13,6 +13,7 @@ import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
@ -22,12 +23,15 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilVariant;
@ -39,6 +43,8 @@ import nautilus.game.arcade.kit.Perk;
public class PerkHorsePet extends Perk
{
private static final ItemStack SADDLE_ITEM = new ItemBuilder(Material.SADDLE).setTitle(C.cGreenB + "Saddle").build();
private HashMap<Player, Horse> _horseMap = new HashMap<Player, Horse>();
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
@ -98,7 +104,7 @@ public class PerkHorsePet extends Perk
horse.setOwner(player);
horse.setMaxDomestication(1);
horse.setJumpStrength(1);
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horse.getInventory().setSaddle(SADDLE_ITEM);
horse.setMaxHealth(40);
horse.setHealth(40);
@ -299,6 +305,22 @@ public class PerkHorsePet extends Perk
}
}
@EventHandler
public void onClick(InventoryClickEvent event)
{
Horse horse = _horseMap.get(event.getWhoClicked());
if (horse != null)
{
if (event.getInventory().equals(horse.getInventory()))
{
if (UtilInv.shouldCancelEvent(event, item -> UtilItem.isSimilar(item, SADDLE_ITEM, UtilItem.ItemAttribute.NAME)))
{
event.setCancelled(true);
}
}
}
}
private KitModifier getHorseType(Player player)
{
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();

View File

@ -14,7 +14,7 @@ public class PerkMammoth extends Perk
{
super("Mammoth", new String[]
{
C.cGray + "Take 75% knockback and deal 125% knockback",
C.cGray + "Take 85% knockback and deal 115% knockback",
});
}
@ -30,7 +30,7 @@ public class PerkMammoth extends Perk
if (!Kit.HasKit(damager))
return;
event.AddKnockback(GetName(), 1.25d);
event.AddKnockback(GetName(), 1.15d);
}
@EventHandler(priority = EventPriority.HIGH)
@ -45,6 +45,6 @@ public class PerkMammoth extends Perk
if (!Kit.HasKit(damagee))
return;
event.AddKnockback(GetName(), 0.75d);
event.AddKnockback(GetName(), 0.85d);
}
}

View File

@ -12,6 +12,7 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -247,6 +248,18 @@ public class GameHostManager implements Listener
}
}
@EventHandler
public void onClick(InventoryClickEvent event)
{
if (_shop.isPlayerInShop(event.getWhoClicked()))
{
if (event.getClickedInventory().getType() == InventoryType.PLAYER)
{
event.setCancelled(true);
}
}
}
@EventHandler
public void adminJoin(PlayerJoinEvent event)
{

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.managers;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -132,6 +133,9 @@ public class GameSpectatorManager implements Listener, IPacketHandler
}
}
if (UtilEnt.hasFlag(event.getRightClicked(), UtilEnt.FLAG_ENTITY_COMPONENT))
return;
if (!_manager.GetGame().IsAlive(player))
{
event.setCancelled(true);

View File

@ -109,7 +109,7 @@ public class GameChatManager implements Listener
else
rankStr = C.cDGreen + C.Bold + "MPS Co-Host " + C.Reset;
}
else
else if (rank != Rank.ALL)
{
rankStr = rank.getTag(true, true) + " " + C.Reset;
}

View File

@ -1,17 +1,16 @@
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class DeathBomberStatTracker extends StatTracker<Game>
{
@ -52,6 +51,11 @@ public class DeathBomberStatTracker extends StatTracker<Game>
if(killer.equals(killed))
return;
if (killer.getItemInHand().getType() != Material.TNT)
{
return;
}
if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT"))
{
Integer count = _killCount.get(killer.getUniqueId());

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.stats;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -40,6 +41,11 @@ public class FoodForTheMassesStatTracker extends StatTracker<Game>
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null)
return;
if (killer.getItemInHand().getType() != Material.APPLE)
{
return;
}
if (event.GetLog().GetKiller().GetReason() != null && event.GetLog().GetKiller().GetReason().contains("Apple Thrower"))
{