Add 1.12 Support
Dieser Commit ist enthalten in:
Ursprung
7a89347248
Commit
faf31bc883
@ -20,7 +20,12 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import net.minecraft.server.v1_12_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_12_R1.PacketPlayOutOpenSignEditor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
class RegionListener_12 {
|
class RegionListener_12 {
|
||||||
private RegionListener_12(){}
|
private RegionListener_12(){}
|
||||||
@ -33,4 +38,9 @@ class RegionListener_12 {
|
|||||||
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
||||||
.getCommandManager().getDispatcher().get(command) != null;
|
.getCommandManager().getDispatcher().get(command) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void openSignEditor(Player player, Location location) {
|
||||||
|
PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,5 +50,12 @@
|
|||||||
<artifactId>BauSystem_API</artifactId>
|
<artifactId>BauSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>4.5.0</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${main.basedir}/lib/ProtocolLib.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -19,7 +19,17 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
class RegionListener_15 {
|
class RegionListener_15 {
|
||||||
private RegionListener_15(){}
|
private RegionListener_15(){}
|
||||||
@ -31,4 +41,14 @@ class RegionListener_15 {
|
|||||||
command = command.toLowerCase();
|
command = command.toLowerCase();
|
||||||
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
|
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void openSignEditor(Player player, Location location) {
|
||||||
|
PacketContainer signOpen = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
|
||||||
|
signOpen.getBlockPositionModifier().write(0, new BlockPosition(location.toVector()));
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, signOpen);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,5 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${main.basedir}/lib/WorldEdit-1.15.jar</systemPath>
|
<systemPath>${main.basedir}/lib/WorldEdit-1.15.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<version>4.5.0</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${main.basedir}/lib/ProtocolLib.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -28,12 +28,10 @@ import com.comphenix.protocol.wrappers.BlockPosition;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.VersionedCallable;
|
import de.steamwar.core.VersionedRunnable;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutOpenSignEditor;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -47,10 +45,6 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class RegionListener implements Listener {
|
public class RegionListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
@ -132,20 +126,14 @@ public class RegionListener implements Listener {
|
|||||||
}
|
}
|
||||||
sign.update();
|
sign.update();
|
||||||
|
|
||||||
PacketContainer signOpen = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
|
VersionedRunnable.call(new VersionedRunnable(() -> RegionListener_12.openSignEditor(player, event.getClickedBlock().getLocation()), 12),
|
||||||
signOpen.getBlockPositionModifier().write(0, new BlockPosition(event.getClickedBlock().getLocation().toVector()));
|
new VersionedRunnable(() -> RegionListener_15.openSignEditor(player, event.getClickedBlock().getLocation()), 15));
|
||||||
try {
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, signOpen);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getPlugin(), PacketType.Play.Client.UPDATE_SIGN) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getPlugin(), PacketType.Play.Client.UPDATE_SIGN) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
if(!event.getPlayer().equals(player))
|
if(!event.getPlayer().equals(player))
|
||||||
return;
|
return;
|
||||||
event.setCancelled(true);
|
|
||||||
Bukkit.getScheduler().runTask(BauSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTask(BauSystem.getPlugin(), () -> {
|
||||||
PacketContainer packetContainer = event.getPacket();
|
PacketContainer packetContainer = event.getPacket();
|
||||||
BlockPosition position = packetContainer.getBlockPositionModifier().read(0);
|
BlockPosition position = packetContainer.getBlockPositionModifier().read(0);
|
||||||
@ -156,7 +144,6 @@ public class RegionListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Sign sign = ((Sign) signLoc.getState());
|
Sign sign = ((Sign) signLoc.getState());
|
||||||
sign.setEditable(true);
|
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', lines[i]));
|
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', lines[i]));
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren