Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Initial update to api-8
Dieser Commit ist enthalten in:
Ursprung
755a69e912
Commit
2a1e82ac6d
@ -21,7 +21,7 @@ checkerQual = "3.18.0"
|
||||
paper = "1.16.5-R0.1-SNAPSHOT"
|
||||
legacyBukkit = "1.8.8-R0.1-SNAPSHOT"
|
||||
bungee = "1.17-R0.1-SNAPSHOT"
|
||||
sponge = "5.0.0"
|
||||
sponge = "8.0.0-SNAPSHOT"
|
||||
legacySponge = "4.0.0"
|
||||
velocity = "3.0.0-SNAPSHOT"
|
||||
|
||||
|
@ -37,31 +37,32 @@ import com.viaversion.viaversion.sponge.platform.SpongeViaLoader;
|
||||
import com.viaversion.viaversion.sponge.util.LoggerWrapper;
|
||||
import com.viaversion.viaversion.util.ChatColorUtil;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import com.viaversion.viaversion.util.VersionInfo;
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.Platform;
|
||||
import org.spongepowered.api.config.DefaultConfig;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
||||
import org.spongepowered.api.event.lifecycle.StoppingEngineEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.scheduler.Task;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
import org.spongepowered.plugin.PluginContainer;
|
||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
import org.spongepowered.plugin.metadata.PluginMetadata;
|
||||
import org.spongepowered.plugin.metadata.model.PluginContributor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Plugin(id = "viaversion",
|
||||
name = "ViaVersion",
|
||||
version = VersionInfo.VERSION,
|
||||
authors = {"_MylesC", "creeper123123321", "Gerrygames", "kennytv", "Matsv"},
|
||||
description = "Allow newer Minecraft versions to connect to an older server version."
|
||||
)
|
||||
@Plugin("viaversion")
|
||||
public class SpongePlugin implements ViaPlatform<Player> {
|
||||
@Inject
|
||||
private Game game;
|
||||
@ -79,7 +80,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
@Listener
|
||||
public void onGameStart(GameInitializationEvent event) {
|
||||
// Setup Logger
|
||||
logger = new LoggerWrapper(container.getLogger());
|
||||
logger = new LoggerWrapper(container.logger());
|
||||
// Setup Plugin
|
||||
conf = new SpongeViaConfig(container, spongeConfig.getParentFile());
|
||||
SpongeCommandHandler commandHandler = new SpongeCommandHandler();
|
||||
@ -97,7 +98,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
|
||||
@Listener
|
||||
public void onServerStart(GameAboutToStartServerEvent event) {
|
||||
if (game.getPluginManager().getPlugin("viabackwards").isPresent()) {
|
||||
if (game.pluginManager().plugin("viabackwards").isPresent()) {
|
||||
MappingDataLoader.enableMappingsCache();
|
||||
}
|
||||
|
||||
@ -107,23 +108,30 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onServerStop(GameStoppingServerEvent event) {
|
||||
public void onServerStop(StoppingEngineEvent<?> event) {
|
||||
((ViaManagerImpl) Via.getManager()).destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return game.getPlatform().getImplementation().getName();
|
||||
return game.platform().container(Platform.Component.IMPLEMENTATION).metadata().name().orElse("unknown");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformVersion() {
|
||||
return game.getPlatform().getImplementation().getVersion().orElse("Unknown Version");
|
||||
return readVersion(game.platform().container(Platform.Component.IMPLEMENTATION).metadata().version());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginVersion() {
|
||||
return container.getVersion().orElse("Unknown Version");
|
||||
return readVersion(container.metadata().version());
|
||||
}
|
||||
|
||||
private static String readVersion(ArtifactVersion version) {
|
||||
String qualifier = version.getQualifier();
|
||||
qualifier = (qualifier == null || qualifier.isEmpty()) ? "" : "-" + qualifier;
|
||||
|
||||
return version.getMajorVersion() + "." + version.getMinorVersion() + "." + version.getIncrementalVersion() + qualifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -167,9 +175,9 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
|
||||
@Override
|
||||
public ViaCommandSender[] getOnlinePlayers() {
|
||||
ViaCommandSender[] array = new ViaCommandSender[game.getServer().getOnlinePlayers().size()];
|
||||
ViaCommandSender[] array = new ViaCommandSender[game.server().onlinePlayers().size()];
|
||||
int i = 0;
|
||||
for (Player player : game.getServer().getOnlinePlayers()) {
|
||||
for (Player player : game.server().onlinePlayers()) {
|
||||
array[i++] = new SpongeCommandSender(player);
|
||||
}
|
||||
return array;
|
||||
@ -178,12 +186,12 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
@Override
|
||||
public void sendMessage(UUID uuid, String message) {
|
||||
String serialized = SpongePlugin.COMPONENT_SERIALIZER.serialize(SpongePlugin.COMPONENT_SERIALIZER.deserialize(message));
|
||||
game.getServer().getPlayer(uuid).ifPresent(player -> player.sendMessage(TextSerializers.JSON.deserialize(serialized))); // Hacky way to fix links
|
||||
game.server().player(uuid).ifPresent(player -> player.sendMessage(TextSerializers.JSON.deserialize(serialized))); // Hacky way to fix links
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kickPlayer(UUID uuid, String message) {
|
||||
return game.getServer().getPlayer(uuid).map(player -> {
|
||||
return game.server().player(uuid).map(player -> {
|
||||
player.kick(TextSerializers.formattingCode(ChatColorUtil.COLOR_CHAR).deserialize(message));
|
||||
return true;
|
||||
}).orElse(false);
|
||||
@ -214,13 +222,14 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
JsonObject platformSpecific = new JsonObject();
|
||||
|
||||
List<PluginInfo> plugins = new ArrayList<>();
|
||||
for (PluginContainer p : game.getPluginManager().getPlugins()) {
|
||||
for (PluginContainer p : game.pluginManager().plugins()) {
|
||||
PluginMetadata meta = p.metadata();
|
||||
plugins.add(new PluginInfo(
|
||||
true,
|
||||
p.getName(),
|
||||
p.getVersion().orElse("Unknown Version"),
|
||||
p.getInstance().isPresent() ? p.getInstance().get().getClass().getCanonicalName() : "Unknown",
|
||||
p.getAuthors()
|
||||
meta.name().orElse("Unknown"),
|
||||
readVersion(meta.version()),
|
||||
p.instance() != null ? p.instance().getClass().getCanonicalName() : "Unknown",
|
||||
meta.contributors().stream().map(PluginContributor::name).collect(Collectors.toList())
|
||||
));
|
||||
}
|
||||
platformSpecific.add("plugins", GsonUtil.getGson().toJsonTree(plugins));
|
||||
@ -247,4 +256,9 @@ public class SpongePlugin implements ViaPlatform<Player> {
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public PluginContainer getPluginContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,53 +18,55 @@
|
||||
package com.viaversion.viaversion.sponge.commands;
|
||||
|
||||
import com.viaversion.viaversion.commands.ViaCommandHandler;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.api.command.CommandCallable;
|
||||
import org.spongepowered.api.command.CommandException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.api.command.Command;
|
||||
import org.spongepowered.api.command.CommandCompletion;
|
||||
import org.spongepowered.api.command.CommandResult;
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.world.Location;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.command.CommandCause;
|
||||
import org.spongepowered.api.command.parameter.ArgumentReader;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SpongeCommandHandler extends ViaCommandHandler implements CommandCallable {
|
||||
public class SpongeCommandHandler extends ViaCommandHandler implements Command.Raw {
|
||||
|
||||
@Override
|
||||
public CommandResult process(CommandSource source, String arguments) throws CommandException {
|
||||
String[] args = arguments.length() > 0 ? arguments.split(" ") : new String[0];
|
||||
onCommand(new SpongeCommandSender(source), args);
|
||||
public CommandResult process(CommandCause cause, ArgumentReader.Mutable arguments) {
|
||||
String[] args = arguments.input().length() > 0 ? arguments.input().split(" ") : new String[0];
|
||||
onCommand(new SpongeCommandSender(cause), args);
|
||||
return CommandResult.success();
|
||||
}
|
||||
|
||||
public List<String> getSuggestions(CommandSource commandSource, String s, @Nullable Location<World> location) throws CommandException {
|
||||
return getSuggestions(commandSource, s);
|
||||
}
|
||||
|
||||
public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException {
|
||||
String[] args = arguments.split(" ", -1); // ViaCommandHandler handles empty String in array. -1: do not discard empty strings
|
||||
return onTabComplete(new SpongeCommandSender(source), args);
|
||||
@Override
|
||||
public List<CommandCompletion> complete(CommandCause cause, ArgumentReader.Mutable arguments) {
|
||||
String[] args = arguments.input().split(" ", -1); // ViaCommandHandler handles empty String in array. -1: do not discard empty strings
|
||||
return onTabComplete(new SpongeCommandSender(cause), args).stream().map(CommandCompletion::of).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testPermission(CommandSource source) {
|
||||
return source.hasPermission("viaversion.admin");
|
||||
public boolean canExecute(CommandCause cause) {
|
||||
return cause.hasPermission("viaversion.admin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Text> getShortDescription(CommandSource source) {
|
||||
return Optional.of(Text.of("Shows ViaVersion Version and more."));
|
||||
public Optional<Component> shortDescription(CommandCause cause) {
|
||||
return Optional.of(Component.text("Shows ViaVersion Version and more."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Text> getHelp(CommandSource source) {
|
||||
public Optional<Component> extendedDescription(CommandCause cause) {
|
||||
return shortDescription(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Component> help(@NotNull CommandCause cause) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getUsage(CommandSource source) {
|
||||
return Text.of("Usage /viaversion");
|
||||
public Component usage(CommandCause cause) {
|
||||
return Component.text("Usage /viaversion");
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,15 @@ package com.viaversion.viaversion.sponge.commands;
|
||||
|
||||
import com.viaversion.viaversion.SpongePlugin;
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
import org.spongepowered.api.command.CommandCause;
|
||||
import org.spongepowered.api.util.Identifiable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeCommandSender implements ViaCommandSender {
|
||||
private final CommandSource source;
|
||||
private final CommandCause source;
|
||||
|
||||
public SpongeCommandSender(CommandSource source) {
|
||||
public SpongeCommandSender(CommandCause source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ public class SpongeCommandSender implements ViaCommandSender {
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (source instanceof Identifiable) {
|
||||
return ((Identifiable) source).getUniqueId();
|
||||
return ((Identifiable) source).uniqueId();
|
||||
} else {
|
||||
return UUID.fromString(getName());
|
||||
}
|
||||
@ -55,6 +54,6 @@ public class SpongeCommandSender implements ViaCommandSender {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return source.getName();
|
||||
return source.friendlyIdentifier().orElse(source.identifier());
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,13 @@ package com.viaversion.viaversion.sponge.listeners;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.update.UpdateUtil;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
||||
import org.spongepowered.api.event.network.ServerSideConnectionEvent;
|
||||
|
||||
public class UpdateListener {
|
||||
@Listener
|
||||
public void onJoin(ClientConnectionEvent.Join join) {
|
||||
if (join.getTargetEntity().hasPermission("viaversion.update")
|
||||
&& Via.getConfig().isCheckForUpdates()) {
|
||||
UpdateUtil.sendUpdateMessage(join.getTargetEntity().getUniqueId());
|
||||
public void onJoin(ServerSideConnectionEvent.Join join) {
|
||||
if (join.player().hasPermission("viaversion.update") && Via.getConfig().isCheckForUpdates()) {
|
||||
UpdateUtil.sendUpdateMessage(join.player().uniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ViaSpongeListener extends ViaListener {
|
||||
public void register() {
|
||||
if (isRegistered()) return;
|
||||
|
||||
Sponge.getEventManager().registerListeners(plugin, this);
|
||||
Sponge.eventManager().registerListeners(plugin.getPluginContainer(), this);
|
||||
setRegistered(true);
|
||||
}
|
||||
|
||||
@ -61,8 +61,4 @@ public class ViaSpongeListener extends ViaListener {
|
||||
Via.getPlatform().getLogger().severe("Could not get the entity id, please report this on our Github");
|
||||
return -1;
|
||||
}
|
||||
|
||||
public SpongePlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
|
@ -18,16 +18,19 @@
|
||||
package com.viaversion.viaversion.sponge.listeners.protocol1_9to1_8;
|
||||
|
||||
import com.viaversion.viaversion.SpongePlugin;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
||||
import com.viaversion.viaversion.sponge.listeners.ViaSpongeListener;
|
||||
import org.spongepowered.api.block.transaction.BlockTransaction;
|
||||
import org.spongepowered.api.block.transaction.Operations;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.block.ChangeBlockEvent;
|
||||
import org.spongepowered.api.event.filter.cause.Root;
|
||||
import org.spongepowered.api.world.Location;
|
||||
import org.spongepowered.api.world.server.ServerLocation;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BlockListener extends ViaSpongeListener {
|
||||
|
||||
@ -36,11 +39,17 @@ public class BlockListener extends ViaSpongeListener {
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void placeBlock(ChangeBlockEvent.Place e, @Root Player player) {
|
||||
if (isOnPipe(player.getUniqueId())) {
|
||||
Location loc = e.getTransactions().get(0).getFinal().getLocation().get();
|
||||
EntityTracker1_9 tracker = getUserConnection(player.getUniqueId()).getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addBlockInteraction(new Position(loc.getBlockX(), (short) loc.getBlockY(), loc.getBlockZ()));
|
||||
public void placeBlock(ChangeBlockEvent.All e, @Root Player player) {
|
||||
BlockTransaction transaction = e.transactions().get(0);
|
||||
if (transaction.operation().equals(Operations.PLACE.get())) {
|
||||
if (isOnPipe(player.uniqueId())) {
|
||||
Optional<ServerLocation> optional = transaction.finalReplacement().location();
|
||||
if (optional.isPresent()) {
|
||||
ServerLocation loc = optional.get();
|
||||
EntityTracker1_9 tracker = getUserConnection(player.uniqueId()).getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addBlockInteraction(new Position(loc.blockX(), loc.blockY(), loc.blockZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.sponge.listeners.ViaSpongeListener;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.Order;
|
||||
@ -39,17 +40,17 @@ public class DeathListener extends ViaSpongeListener {
|
||||
|
||||
@Listener(order = Order.LAST)
|
||||
public void onDeath(DestructEntityEvent.Death e) {
|
||||
if (!(e.getTargetEntity() instanceof Player))
|
||||
if (!(e.entity() instanceof Player))
|
||||
return;
|
||||
|
||||
Player p = (Player) e.getTargetEntity();
|
||||
if (isOnPipe(p.getUniqueId()) && Via.getConfig().isShowNewDeathMessages() && checkGamerule(p.getWorld())) {
|
||||
sendPacket(p, e.getMessage().toPlain());
|
||||
Player p = (Player) e.entity();
|
||||
if (isOnPipe(p.uniqueId()) && Via.getConfig().isShowNewDeathMessages() && checkGamerule(p.getWorld())) {
|
||||
sendPacket(p, PlainTextComponentSerializer.plainText().serialize(e.message()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkGamerule(World w) {
|
||||
Optional<String> gamerule = w.getGameRule("showDeathMessages");
|
||||
Optional<String> gamerule = w.gameRule("showDeathMessages");
|
||||
|
||||
if (gamerule.isPresent()) {
|
||||
try {
|
||||
|
@ -58,9 +58,9 @@ public class HandItemCache implements Runnable {
|
||||
public void run() {
|
||||
List<UUID> players = new ArrayList<>(handCache.keySet());
|
||||
|
||||
for (Player p : Sponge.getServer().getOnlinePlayers()) {
|
||||
handCache.put(p.getUniqueId(), convert(grabber.getItem(p)));
|
||||
players.remove(p.getUniqueId());
|
||||
for (Player p : Sponge.server().onlinePlayers()) {
|
||||
handCache.put(p.uniqueId(), convert(grabber.getItem(p)));
|
||||
players.remove(p.uniqueId());
|
||||
}
|
||||
// Remove offline players
|
||||
for (UUID uuid : players) {
|
||||
@ -105,7 +105,7 @@ public class HandItemCache implements Runnable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new DataItem(id, (byte) itemInHand.getQuantity(), (short) damage, null);
|
||||
return new DataItem(id, (byte) itemInHand.quantity(), (short) damage, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,15 +29,15 @@ import org.spongepowered.api.data.type.HandTypes;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.action.InteractEvent;
|
||||
import org.spongepowered.api.event.cause.entity.MovementTypes;
|
||||
import org.spongepowered.api.event.entity.MoveEntityEvent;
|
||||
import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent;
|
||||
import org.spongepowered.api.event.entity.living.player.RespawnPlayerEvent;
|
||||
import org.spongepowered.api.event.filter.cause.Root;
|
||||
import org.spongepowered.api.event.item.inventory.ClickInventoryEvent;
|
||||
import org.spongepowered.api.event.network.ClientConnectionEvent;
|
||||
import org.spongepowered.api.event.item.inventory.container.ClickContainerEvent;
|
||||
import org.spongepowered.api.event.network.ServerSideConnectionEvent;
|
||||
import org.spongepowered.api.item.inventory.ItemStack;
|
||||
import org.spongepowered.api.item.inventory.transaction.SlotTransaction;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Sponge5ArmorListener extends ViaSpongeListener {
|
||||
@ -50,14 +50,14 @@ public class Sponge5ArmorListener extends ViaSpongeListener {
|
||||
//
|
||||
public void sendArmorUpdate(Player player) {
|
||||
// Ensure that the player is on our pipe
|
||||
if (!isOnPipe(player.getUniqueId())) return;
|
||||
if (!isOnPipe(player.uniqueId())) return;
|
||||
|
||||
|
||||
int armor = 0;
|
||||
armor += calculate(player.getHelmet());
|
||||
armor += calculate(player.getChestplate());
|
||||
armor += calculate(player.getLeggings());
|
||||
armor += calculate(player.getBoots());
|
||||
armor += calculate(player.head());
|
||||
armor += calculate(player.chest());
|
||||
armor += calculate(player.legs());
|
||||
armor += calculate(player.feet());
|
||||
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.ENTITY_PROPERTIES, null, getUserConnection(player.getUniqueId()));
|
||||
try {
|
||||
@ -76,18 +76,19 @@ public class Sponge5ArmorListener extends ViaSpongeListener {
|
||||
}
|
||||
}
|
||||
|
||||
private int calculate(Optional<ItemStack> itemStack) {
|
||||
if (itemStack.isPresent())
|
||||
return ArmorType.findByType(itemStack.get().getItem().getType().getId()).getArmorPoints();
|
||||
|
||||
private int calculate(ItemStack itemStack) {
|
||||
if (itemStack != null) {
|
||||
// todo
|
||||
return ArmorType.findByType(itemStack.type()).getArmorPoints();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onInventoryClick(ClickInventoryEvent e, @Root Player player) {
|
||||
for (SlotTransaction transaction : e.getTransactions()) {
|
||||
if (ArmorType.isArmor(transaction.getFinal().getType().getId()) ||
|
||||
ArmorType.isArmor(e.getCursorTransaction().getFinal().getType().getId())) {
|
||||
public void onContainerClick(ClickContainerEvent e, @Root Player player) {
|
||||
for (SlotTransaction transaction : e.transactions()) {
|
||||
if (ArmorType.isArmor(transaction.finalReplacement().type()) ||
|
||||
ArmorType.isArmor(e.cursorTransaction().finalReplacement().type())) {
|
||||
sendDelayedArmorUpdate(player);
|
||||
break;
|
||||
}
|
||||
@ -96,32 +97,34 @@ public class Sponge5ArmorListener extends ViaSpongeListener {
|
||||
|
||||
@Listener
|
||||
public void onInteract(InteractEvent event, @Root Player player) {
|
||||
if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
|
||||
if (ArmorType.isArmor(player.getItemInHand(HandTypes.MAIN_HAND).get().getItem().getId()))
|
||||
if (player.itemInHand(HandTypes.MAIN_HAND) != null) {
|
||||
if (ArmorType.isArmor(player.itemInHand(HandTypes.MAIN_HAND).type()))
|
||||
sendDelayedArmorUpdate(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onJoin(ClientConnectionEvent.Join e) {
|
||||
sendArmorUpdate(e.getTargetEntity());
|
||||
public void onJoin(ServerSideConnectionEvent.Join e) {
|
||||
sendArmorUpdate(e.player());
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onRespawn(RespawnPlayerEvent e) {
|
||||
sendDelayedArmorUpdate(e.getTargetEntity());
|
||||
sendDelayedArmorUpdate(e.entity());
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onWorldChange(MoveEntityEvent.Teleport e) {
|
||||
if (!(e.getTargetEntity() instanceof Player)) return;
|
||||
if (!e.getFromTransform().getExtent().getUniqueId().equals(e.getToTransform().getExtent().getUniqueId())) {
|
||||
sendArmorUpdate((Player) e.getTargetEntity());
|
||||
public void onWorldChange(MoveEntityEvent e) {
|
||||
if (!(e.entity() instanceof Player)) return;
|
||||
if (!e.cause().contains(MovementTypes.ENTITY_TELEPORT)) return; //todo: probably doesn't work
|
||||
|
||||
if (!e.originalDestinationPosition().getExtent().getUniqueId().equals(e.destinationPosition().getExtent().getUniqueId())) {
|
||||
sendArmorUpdate((Player) e.entity());
|
||||
}
|
||||
}
|
||||
|
||||
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.uniqueId())) return; // Don't start a task if the player is not on the pipe
|
||||
Via.getPlatform().runSync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -25,6 +25,6 @@ import org.spongepowered.api.item.inventory.ItemStack;
|
||||
public class Sponge5ItemGrabber implements ItemGrabber {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
return player.getItemInHand(HandTypes.MAIN_HAND).orElse(null);
|
||||
return player.itemInHand(HandTypes.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ public class SpongeViaAPI extends ViaAPIBase<Player> {
|
||||
|
||||
@Override
|
||||
public int getPlayerVersion(Player player) {
|
||||
return getPlayerVersion(player.getUniqueId());
|
||||
return getPlayerVersion(player.uniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawPacket(Player player, ByteBuf packet) throws IllegalArgumentException {
|
||||
sendRawPacket(player.getUniqueId(), packet);
|
||||
sendRawPacket(player.uniqueId(), packet);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.sponge.platform;
|
||||
|
||||
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
||||
import org.spongepowered.api.asset.Asset;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.plugin.PluginContainer;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
@ -46,7 +46,7 @@ public class SpongeViaConfig extends AbstractViaConfig {
|
||||
if (!config.isPresent()) {
|
||||
throw new IllegalArgumentException("Default config is missing from jar");
|
||||
}
|
||||
return config.get().getUrl();
|
||||
return config.get().url();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,7 +33,7 @@ public class SpongeViaInjector extends LegacyViaInjector {
|
||||
|
||||
@Override
|
||||
public int getServerProtocolVersion() throws ReflectiveOperationException {
|
||||
MinecraftVersion version = Sponge.getPlatform().getMinecraftVersion();
|
||||
MinecraftVersion version = Sponge.platform().minecraftVersion();
|
||||
return (int) version.getClass().getDeclaredMethod("getProtocol").invoke(version);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class SpongeViaInjector extends LegacyViaInjector {
|
||||
Class<?> serverClazz = Class.forName("net.minecraft.server.MinecraftServer");
|
||||
for (Method method : serverClazz.getDeclaredMethods()) {
|
||||
if (method.getReturnType().getSimpleName().equals("NetworkSystem") && method.getParameterTypes().length == 0) {
|
||||
Object connection = method.invoke(Sponge.getServer());
|
||||
Object connection = method.invoke(Sponge.server());
|
||||
if (connection != null) {
|
||||
return connection;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.sponge.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.logging.Level;
|
||||
|
48
sponge/src/main/resources/META-INF/sponge_plugins.json
Normale Datei
48
sponge/src/main/resources/META-INF/sponge_plugins.json
Normale Datei
@ -0,0 +1,48 @@
|
||||
{
|
||||
"loader": {
|
||||
"name": "java_plain",
|
||||
"version": "1.0"
|
||||
},
|
||||
"license": "GNU GPLv3",
|
||||
"plugins": [
|
||||
{
|
||||
"id": "viaversion",
|
||||
"name": "ViaVersion",
|
||||
"version": "${version}",
|
||||
"description": "${description}",
|
||||
"entrypoint": "com.viaversion.viaversion.SpongePlugin",
|
||||
"branding": {
|
||||
"logo": "assets/viaversion/textures/logo.png",
|
||||
"icon": "assets/viaversion/textures/logo.png"
|
||||
},
|
||||
"links": {
|
||||
"homepage": "https://www.spigotmc.org/resources/viaversion.19254/",
|
||||
"source": "https://github.com/ViaVersion/ViaVersion",
|
||||
"issues": "https://github.com/ViaVersion/ViaVersion"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "_MylesC"
|
||||
},
|
||||
{
|
||||
"name": "creeper123123321"
|
||||
},
|
||||
{
|
||||
"name": "Gerrygames"
|
||||
},
|
||||
{
|
||||
"name": "kennytv"
|
||||
},
|
||||
{
|
||||
"name": "Matsv"
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{
|
||||
"id": "spongeapi",
|
||||
"version": "8.0.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren