Rebase with upstream

This commit is contained in:
verinia 2019-05-28 22:15:17 -08:00
commit 101b8314c9
2889 changed files with 481914 additions and 0 deletions

View file

@ -0,0 +1,99 @@
package plugin.activity.pestcontrol;
import org.crandor.game.interaction.Option;
import org.crandor.game.node.Node;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.zone.MapZone;
import org.crandor.game.world.map.zone.ZoneBorders;
import org.crandor.game.world.map.zone.ZoneRestriction;
/**
* The pest control lander zone handler.
* @author Emperor
*/
public final class PCLanderZone extends MapZone {
/**
* The activities.
*/
private PestControlActivityPlugin[] activities;
/**
* Constructs a new {@code PCLanderZone} {@code Object}.
* @param activities The activities.
*/
public PCLanderZone(PestControlActivityPlugin[] activities) {
super("pest control lander", true, ZoneRestriction.RANDOM_EVENTS, ZoneRestriction.FIRES, ZoneRestriction.FOLLOWERS, ZoneRestriction.CANNON);
this.activities = activities;
}
@Override
public boolean interact(Entity e, Node target, Option option) {
if (target instanceof GameObject) {
GameObject o = (GameObject) target;
switch (o.getId()) {
case 14314: // Novice exit ladder
if (activities[0].getWaitingPlayers().contains(e)) {
activities[0].getWaitingPlayers().remove(e);
e.getProperties().setTeleportLocation(activities[0].getLeaveLocation());
}
return true;
case 25629: // Intermediate exit ladder
if (activities[1].getWaitingPlayers().contains(e)) {
activities[1].getWaitingPlayers().remove(e);
e.getProperties().setTeleportLocation(activities[1].getLeaveLocation());
}
return true;
case 25630: // Veteran exit ladder
if (activities[2].getWaitingPlayers().contains(e)) {
activities[2].getWaitingPlayers().remove(e);
e.getProperties().setTeleportLocation(activities[2].getLeaveLocation());
}
return true;
}
}
return false;
}
@Override
public boolean teleport(Entity e, int type, Node node) {
if (e instanceof Player && type != -1) {
for (PestControlActivityPlugin a : activities) {
if (a.getWaitingPlayers().contains(e)) {
((Player) e).getPacketDispatch().sendMessage("The knights don't appreciate you teleporting off their craft!");
return false;
}
}
}
return super.teleport(e, type, node);
}
@Override
public boolean leave(Entity e, boolean logout) {
if (e instanceof Player) {
Player p = (Player) e;
if (p.getInterfaceManager().getComponent(407) != null) {
p.getInterfaceManager().closeOverlay();
}
for (PestControlActivityPlugin a : activities) {
if (a.getWaitingPlayers().remove(e)) {
if (logout) {
e.getProperties().setTeleportLocation(a.getLeaveLocation());
}
break;
}
}
}
return super.leave(e, logout);
}
@Override
public void configure() {
register(new ZoneBorders(2659, 2637, 2664, 2664));
register(new ZoneBorders(2637, 2641, 2642, 2648));
register(new ZoneBorders(2631, 2648, 2636, 2655));
}
}