13
0
Dieser Commit ist enthalten in:
Lixfel 2021-10-04 18:35:49 +02:00
Ursprung f59a0fda8d
Commit 8ad29453e0
5 geänderte Dateien mit 26 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -8,5 +8,5 @@ PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf
PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7PortalName§8] §8- §7Fügt ein Portal hinzu
PORTAL_COMMAND_REMOVE_HELP = §8/§7portal §eremove §8[§7PortalName§8] §8- §7Entfernt ein Portal
PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos2§8(§7{2}§8)
PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos2§8(§7{3}§8)
PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection

Datei anzeigen

@ -44,7 +44,7 @@ public class PortalCommand extends SWCommand {
if (noPermissions(player)) return;
LobbySystem.getMessage().sendPrefixless("COMMAND_HELP_HEAD", player, "portal list");
Portal.getPortals().forEach(portal -> {
LobbySystem.getMessage().sendPrefixless("PORTAL_COMMAND_LIST_SHORT_INFO", player, portal.type().name(), portal.getId(), portal.getPos1().toVector().toString(), portal.getPos1().toVector().toString());
LobbySystem.getMessage().sendPrefixless("PORTAL_COMMAND_LIST_SHORT_INFO", player, portal.type().name(), portal.getId(), portal.getPos1().toVector().toString(), portal.getPos2().toVector().toString());
});
}

Datei anzeigen

@ -47,6 +47,13 @@ public class Hologram implements ConfigurationSerializable {
}
throw new SecurityException("Could not find Serializer for " + type.getName());
}
private static Object getDataWatcherObject(int index, int fieldIndex) {
try {
return dataWatcherObjectConstructor.invoke(index, dataWatcherRegistry.getFields()[fieldIndex].get(null));
} catch (IllegalAccessException e) {
throw new SecurityException("Could not get field", e);
}
}
private static final Class<?> spawnLivingPacket = Reflection.getClass("{nms}.PacketPlayOutSpawnEntityLiving");
private static final Reflection.ConstructorInvoker spawnLivingPacketConstructor = Reflection.getConstructor(spawnLivingPacket);
@ -64,11 +71,11 @@ public class Hologram implements ConfigurationSerializable {
private static final Class<?> item = Reflection.getClass("{nms}.DataWatcher$Item");
private static final Reflection.ConstructorInvoker itemConstructor = Reflection.getConstructor(item, dataWatcherObject, Object.class);
private static final Object invisibleWatcher = getDataWatcherObject(0, Byte.class);
private static final Object nameWatcher = getDataWatcherObject(2, String.class);
private static final Object nameWatcher = getDataWatcherObject(2, 5);
private static final Object nameVisibleWatcher = getDataWatcherObject(3, Boolean.class);
private static final Object silentWatcher = getDataWatcherObject(4, Boolean.class);
private static final Object noGravityWatcher = getDataWatcherObject(5, Boolean.class);
private static final Object sizeWatcher = getDataWatcherObject(14, Byte.class);
private static final Class<?> chatComponentText = Reflection.getClass("{nms}.ChatComponentText");
private static final Reflection.ConstructorInvoker chatComponentTextConstructor = Reflection.getConstructor(chatComponentText, String.class);
private static final Class<?> destroyPacket = Reflection.getClass("{nms}.PacketPlayOutEntityDestroy");
private static final Reflection.ConstructorInvoker destoryPacketConstructor = Reflection.getConstructor(destroyPacket);
@ -127,10 +134,8 @@ public class Hologram implements ConfigurationSerializable {
metadataEntity.set(packet, entityId);
List<Object> watchers = new ArrayList<>();
watchers.add(itemConstructor.invoke(invisibleWatcher, (byte) 0x20));
watchers.add(itemConstructor.invoke(nameWatcher, text));
watchers.add(itemConstructor.invoke(nameWatcher, Optional.of(chatComponentTextConstructor.invoke(text))));
watchers.add(itemConstructor.invoke(nameVisibleWatcher, true));
watchers.add(itemConstructor.invoke(silentWatcher, true));
watchers.add(itemConstructor.invoke(noGravityWatcher, true));
watchers.add(itemConstructor.invoke(sizeWatcher, (byte) 0x10));
metadataMetadata.set(packet, watchers);
Protocol.getTinyProtocol().sendPacket(player, packet);

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.lobby.portal;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.listener.Portals;
import org.bukkit.Location;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Player;
@ -92,11 +93,9 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
private void init() {
portals.put(id, this);
Vector diff = pos2.subtract(pos1).toVector();
diff.divide(new Vector(Math.abs(diff.getBlockX()), Math.abs(diff.getBlockY()), Math.abs(diff.getBlockZ())));
for(int x = pos1.getBlockX(); x <= pos2.getBlockX(); x += diff.getBlockX()) {
for(int y = pos1.getBlockY(); y <= pos2.getBlockY(); y += diff.getBlockY()) {
for(int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z += diff.getBlockZ()) {
for(int x = pos1.getBlockX(); x <= pos2.getBlockX(); x++) {
for(int y = pos1.getBlockY(); y <= pos2.getBlockY(); y++) {
for(int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
posMap.put(new Vector(x, y, z), this);
}
}
@ -106,6 +105,7 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
@Override
public void handle(Player player, Location from) {
handler.handle(player, from);
Portals.getStack(player).push(this);
}
@Override
@ -152,4 +152,9 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
PortalHandler getHandler() {
return handler;
}
@Override
public String toString() {
return getId() + " " + type().name();
}
}

Datei anzeigen

@ -50,13 +50,14 @@ public class TeleportPortal implements PortalHandler {
private void init() {
portals.stream().filter(p -> p.target.equals(portal.getId())).forEach(sources::add);
portals.stream().filter(p -> p.portal.getId().equals(target)).forEach(p -> p.sources.add(this));
portals.add(this);
}
@Override
public void handle(Player player, Location loc) {
Deque<Portal> stack = Portals.getStack(player);
if(!stack.isEmpty() && sources.contains(stack.peek())) {
if(!stack.isEmpty() && sources.contains(stack.peek().getHandler())) {
teleport(player, loc, stack.pop());
} else {
teleport(player, loc, Portal.getPortal(target));
@ -64,6 +65,7 @@ public class TeleportPortal implements PortalHandler {
}
protected void teleport(Player player, Location from, Portal target) {
player.sendMessage("teleport " + portal.getId() + " -> " + target.getId());
Vector vector = from.toVector();
double yaw = from.getYaw();