3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-28 04:20:08 +01:00

Handle plr teleporting when carrying armor stand

Dieser Commit ist enthalten in:
Steven 2015-08-03 19:27:03 +08:00
Ursprung 576d07e1ea
Commit a38b9a85ec
6 geänderte Dateien mit 30 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -28,6 +28,7 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.metadata.FixedMetadataValue;
@ -187,11 +188,31 @@ public class MainListener implements Listener {
Utils.actionBarMsg(p, Config.asDropped);
return;
}
as.teleport(Utils.getLocationFacingPlayer(p));
as.teleport(Utils.getLocationFacing(event.getTo()));
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
}
}
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
final Player p = event.getPlayer();
if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) {
final ArmorStand as = plugin.carryingArmorStand.get(p.getUniqueId());
if (as == null || as.isDead()) {
plugin.carryingArmorStand.remove(p.getUniqueId());
Utils.actionBarMsg(p, Config.asDropped);
return;
}
new BukkitRunnable() {
@Override
public void run() {
as.teleport(Utils.getLocationFacing(p.getLocation()));
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
}
}.runTaskLater(plugin, 1L);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
final Player p = event.getEntity();
@ -282,7 +303,7 @@ public class MainListener implements Listener {
p.sendMessage(ChatColor.RED + Config.generalNoPerm);
return;
}
Location l = Utils.getLocationFacingPlayer(p);
Location l = Utils.getLocationFacing(p.getLocation());
plugin.pickUpArmorStand(spawnArmorStand(l), p, true);
Utils.actionBarMsg(p, ChatColor.GREEN + Config.carrying);
p.updateInventory();

Datei anzeigen

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.api.PlotAPI;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.Permissions;
@SuppressWarnings("deprecation")
class PlotSquaredHook {

Datei anzeigen

@ -54,12 +54,12 @@ class Utils {
return false;
}
static Location getLocationFacingPlayer(Player p) {
Vector v = p.getLocation().getDirection();
static Location getLocationFacing(Location l) {
Vector v = l.getDirection();
v.setY(0);
v.multiply(3);
Location l = p.getLocation().add(v);
l.setYaw(p.getLocation().getYaw() + 180);
l.add(v);
l.setYaw(l.getYaw() + 180);
int n;
boolean ok = false;
for (n = 0; n < 5; n++) {

Datei anzeigen

@ -4,7 +4,7 @@
#
# Main Config
#
# File generated by: v2.03
# File generated by: v2.04
# (If this is not the version you are running, consider deleting this
# config to allow it to be re-created. There may be new config options)
#

Datei anzeigen

@ -4,7 +4,7 @@
#
# Language Config
#
# File generated by: v2.03
# File generated by: v2.04
# (If this is not the version you are running, consider deleting this
# config to allow it to be re-created. There may be new config options)
#

Datei anzeigen

@ -1,6 +1,6 @@
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
name: ArmorStandTools
version: 2.03
version: 2.04
author: St3venAU
description: Armor stand manipulation tools
softdepend: [WorldGuard, PlotSquared]