mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Merge pull request #16 from IronApollo/master
Changes to completely separate SyncTabCompleteListener from Paper
This commit is contained in:
commit
94d5028c12
@ -53,6 +53,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -68,6 +69,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
|
|
||||||
private final Field nbtListTagListField;
|
private final Field nbtListTagListField;
|
||||||
private final Method nbtCreateTagMethod;
|
private final Method nbtCreateTagMethod;
|
||||||
|
private Method chunkSetTypeMethod;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// A simple test
|
// A simple test
|
||||||
@ -86,6 +88,13 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
// The method to create an NBTBase tag given its type ID
|
// The method to create an NBTBase tag given its type ID
|
||||||
nbtCreateTagMethod = NBTBase.class.getDeclaredMethod("createTag", byte.class);
|
nbtCreateTagMethod = NBTBase.class.getDeclaredMethod("createTag", byte.class);
|
||||||
nbtCreateTagMethod.setAccessible(true);
|
nbtCreateTagMethod.setAccessible(true);
|
||||||
|
|
||||||
|
// 1.13.2 Adaptation to find the a/setType method
|
||||||
|
try {
|
||||||
|
chunkSetTypeMethod = Chunk.class.getMethod("setType", BlockPosition.class, IBlockData.class, boolean.class);
|
||||||
|
}catch(NoSuchMethodException e) {
|
||||||
|
chunkSetTypeMethod = Chunk.class.getMethod("a", BlockPosition.class, IBlockData.class, boolean.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] idbToStateOrdinal;
|
private int[] idbToStateOrdinal;
|
||||||
@ -276,7 +285,12 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
|||||||
sections[y4] = section = new ChunkSection(y4 << 4, nmsWorld.worldProvider.g());
|
sections[y4] = section = new ChunkSection(y4 << 4, nmsWorld.worldProvider.g());
|
||||||
}
|
}
|
||||||
if (existing.e() != blockData.e() || existing.getMaterial().f() != blockData.getMaterial().f()) {
|
if (existing.e() != blockData.e() || existing.getMaterial().f() != blockData.getMaterial().f()) {
|
||||||
nmsChunk.a(pos = new BlockPosition(x, y, z), blockData, false);
|
try {
|
||||||
|
chunkSetTypeMethod.invoke(nmsChunk, pos = new BlockPosition(x, y, z), blockData, false);
|
||||||
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
|
logger.warning("Error when setting block!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
section.setType(x & 15, y & 15, z & 15, blockData);
|
section.setType(x & 15, y & 15, z & 15, blockData);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.boydti.fawe.bukkit.listener;
|
package com.boydti.fawe.bukkit.listener;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.server.TabCompleteEvent;
|
import org.bukkit.event.server.TabCompleteEvent;
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ public class SyncTabCompleteListener extends ATabCompleteListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTabComplete(TabCompleteEvent event) {
|
public void onTabComplete(TabCompleteEvent event) {
|
||||||
if (event.isCommand()) {
|
if (event.getSender() instanceof ConsoleCommandSender || event.getBuffer().startsWith("/")) {
|
||||||
List<String> result = this.onTab(event.getBuffer(), event.getSender());
|
List<String> result = this.onTab(event.getBuffer(), event.getSender());
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
event.setCompletions(result);
|
event.setCompletions(result);
|
||||||
|
Loading…
Reference in New Issue
Block a user