3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00

Implement World Change

Dieser Commit ist enthalten in:
Myles 2016-09-27 17:38:56 +01:00
Ursprung 396998c7fc
Commit d5108061c1
3 geänderte Dateien mit 11 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ package us.myles.ViaVersion.sponge.listeners.protocol1_9to1_8;
import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.action.InteractEvent; import org.spongepowered.api.event.action.InteractEvent;
import org.spongepowered.api.event.entity.DisplaceEntityEvent;
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent; import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent;
import org.spongepowered.api.event.filter.cause.Root; import org.spongepowered.api.event.filter.cause.Root;
import org.spongepowered.api.event.item.inventory.ClickInventoryEvent; import org.spongepowered.api.event.item.inventory.ClickInventoryEvent;
@ -34,8 +35,6 @@ public class ArmorListener extends ViaSpongeListener {
int armor = 0; int armor = 0;
// TODO is there a method like getArmorContents?
armor += calculate(player.getHelmet()); armor += calculate(player.getHelmet());
armor += calculate(player.getChestplate()); armor += calculate(player.getChestplate());
armor += calculate(player.getLeggings()); armor += calculate(player.getLeggings());
@ -91,17 +90,17 @@ public class ArmorListener extends ViaSpongeListener {
@Listener @Listener
public void onRespawn(RespawnPlayerEvent e) { public void onRespawn(RespawnPlayerEvent e) {
if (!isOnPipe(e.getTargetEntity().getUniqueId())) return;
sendDelayedArmorUpdate(e.getTargetEntity()); sendDelayedArmorUpdate(e.getTargetEntity());
} }
// TODO find world change event @Listener
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onWorldChange(DisplaceEntityEvent.Teleport e) {
// public void onWorldChange(PlayerChangedWorldEvent e) { if (!(e.getTargetEntity() instanceof Player)) return;
// sendArmorUpdate(e.getPlayer()); if (!e.getFromTransform().getExtent().getUniqueId().equals(e.getToTransform().getExtent().getUniqueId())) {
// } sendArmorUpdate((Player) e.getTargetEntity());
// }
}
public void sendDelayedArmorUpdate(final Player player) { public void sendDelayedArmorUpdate(final Player player) {
if (!isOnPipe(player.getUniqueId())) return; // Don't start a task if the player is not on the pipe if (!isOnPipe(player.getUniqueId())) return; // Don't start a task if the player is not on the pipe
Via.getPlatform().runSync(new Runnable() { Via.getPlatform().runSync(new Runnable() {

Datei anzeigen

@ -17,7 +17,7 @@ public class BlockListener extends ViaSpongeListener {
super(plugin, Protocol1_9TO1_8.class); super(plugin, Protocol1_9TO1_8.class);
} }
@Listener // TODO is there better way to do this? @Listener
public void placeBlock(ChangeBlockEvent.Place e, @Root Player player) { public void placeBlock(ChangeBlockEvent.Place e, @Root Player player) {
if (isOnPipe(player.getUniqueId())) { if (isOnPipe(player.getUniqueId())) {
Location loc = e.getTransactions().get(0).getFinal().getLocation().get(); Location loc = e.getTransactions().get(0).getFinal().getLocation().get();

Datei anzeigen

@ -30,7 +30,7 @@ import java.io.DataOutputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Optional; import java.util.Optional;
// TODO Change to bytebuf to not use reflection bullshit? // TODO Change to bytebuf to not use reflection bullsh*t
public class CommandBlockListener extends ViaSpongeListener { public class CommandBlockListener extends ViaSpongeListener {
public CommandBlockListener(SpongePlugin plugin) { public CommandBlockListener(SpongePlugin plugin) {
super(plugin, Protocol1_9TO1_8.class); super(plugin, Protocol1_9TO1_8.class);