From 703919bf4a9f7e9d7e955c1f1d3dc57511a2c6c4 Mon Sep 17 00:00:00 2001 From: Alastair Date: Thu, 31 Mar 2016 22:34:12 +0100 Subject: [PATCH] fixed imports for bungee packet listener and also looking at horse fix --- Resources/plugin.yml | 2 +- .../advancedportals/AdvancedPortalsPlugin.java | 8 ++++++-- .../destinations/Destination.java | 16 +++++++++++++++- .../listeners/BungeeListener.java | 4 ++-- .../advancedportals/listeners/Listeners.java | 9 +++++---- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Resources/plugin.yml b/Resources/plugin.yml index d773feb9..713fcb1f 100644 --- a/Resources/plugin.yml +++ b/Resources/plugin.yml @@ -1,6 +1,6 @@ main: com.sekwah.advancedportals.AdvancedPortalsPlugin name: AdvancedPortals -version: 0.0.16 +version: 0.0.17 author: sekwah41 description: An advanced portals plugin for bukkit. commands: diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java index 717fdfe5..072bfe88 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java @@ -7,10 +7,14 @@ import com.sekwah.advancedportals.effects.WarpEffects; import com.sekwah.advancedportals.listeners.*; import com.sekwah.advancedportals.metrics.Metrics; import com.sekwah.advancedportals.portals.Portal; +import org.bukkit.Chunk; +import org.bukkit.entity.Entity; import org.bukkit.plugin.java.JavaPlugin; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; public class AdvancedPortalsPlugin extends JavaPlugin { @@ -31,8 +35,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin { // Failed to submit the stats :-( } - this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!"); - String packageName = getServer().getClass().getPackage().getName(); String[] packageSplit = packageName.split("\\."); String version = packageSplit[packageSplit.length - 1]; @@ -104,6 +106,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin { this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this)); + this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!"); + } diff --git a/src/com/sekwah/advancedportals/destinations/Destination.java b/src/com/sekwah/advancedportals/destinations/Destination.java index 01b03180..0aec1a72 100644 --- a/src/com/sekwah/advancedportals/destinations/Destination.java +++ b/src/com/sekwah/advancedportals/destinations/Destination.java @@ -10,6 +10,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.inventory.InventoryView; +import org.bukkit.metadata.FixedMetadataValue; import java.util.Collections; import java.util.LinkedList; @@ -21,12 +23,21 @@ public class Destination { private static AdvancedPortalsPlugin plugin; + private static boolean TeleportRiding = false; + public Destination(AdvancedPortalsPlugin plugin) { Destination.plugin = plugin; + + ConfigAccessor config = new ConfigAccessor(plugin, "config.yml"); + TeleportRiding = config.getConfig().getBoolean("WarpRiddenEntity"); } // TODO add permissions for destinations. + // TODO try keeping the chunks loaded and add different delays to events to make + // the horse teleport when you have more time.(its an annoying bug caused by changed) + // in mc + public static void create(Location location, String name) { ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml"); @@ -112,11 +123,14 @@ public class Destination { Chunk c = loc.getChunk(); Entity riding = player.getVehicle(); if (!c.isLoaded()) c.load(); - if (player.getVehicle() != null) { + + if (player.getVehicle() != null && TeleportRiding) { + riding.eject(); riding.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN); player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN); riding.setPassenger(player); + } else { player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN); } diff --git a/src/com/sekwah/advancedportals/listeners/BungeeListener.java b/src/com/sekwah/advancedportals/listeners/BungeeListener.java index 60d0690c..2e88c370 100644 --- a/src/com/sekwah/advancedportals/listeners/BungeeListener.java +++ b/src/com/sekwah/advancedportals/listeners/BungeeListener.java @@ -1,8 +1,8 @@ package com.sekwah.advancedportals.listeners; +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; import com.sekwah.advancedportals.AdvancedPortalsPlugin; -import net.minecraft.util.com.google.common.io.ByteArrayDataInput; -import net.minecraft.util.com.google.common.io.ByteStreams; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; diff --git a/src/com/sekwah/advancedportals/listeners/Listeners.java b/src/com/sekwah/advancedportals/listeners/Listeners.java index 24cb61a6..bd7912bc 100644 --- a/src/com/sekwah/advancedportals/listeners/Listeners.java +++ b/src/com/sekwah/advancedportals/listeners/Listeners.java @@ -7,11 +7,9 @@ import com.sekwah.advancedportals.events.WarpEvent; import com.sekwah.advancedportals.portals.AdvancedPortal; import com.sekwah.advancedportals.portals.Portal; import com.sun.org.apache.regexp.internal.RE; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.*; import org.bukkit.block.Block; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -23,8 +21,11 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.metadata.FixedMetadataValue; +import java.util.HashMap; + public class Listeners implements Listener { // The needed config values will be stored so they are easier to access later