geforkt von Mirrors/FastAsyncWorldEdit
Use ItemInteract for item right clicks in Sponge.
They don't fire for InteractBlock. # Conflicts: # worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java
Dieser Commit ist enthalten in:
Ursprung
351fd6771a
Commit
8022d8e911
@ -51,6 +51,7 @@ import org.spongepowered.api.event.game.state.GamePostInitializationEvent;
|
|||||||
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
||||||
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
|
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
|
||||||
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
||||||
|
import org.spongepowered.api.event.item.inventory.InteractItemEvent;
|
||||||
import org.spongepowered.api.item.ItemType;
|
import org.spongepowered.api.item.ItemType;
|
||||||
import org.spongepowered.api.item.inventory.ItemStack;
|
import org.spongepowered.api.item.inventory.ItemStack;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
@ -204,6 +205,22 @@ public class SpongeWorldEdit {
|
|||||||
return this.spongeAdapter;
|
return this.spongeAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onPlayerItemInteract(InteractItemEvent event, @Root Player spongePlayer) {
|
||||||
|
if (platform == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!platform.isHookingEvents()) return; // We have to be told to catch these events
|
||||||
|
|
||||||
|
WorldEdit we = WorldEdit.getInstance();
|
||||||
|
|
||||||
|
SpongePlayer player = wrapPlayer(spongePlayer);
|
||||||
|
if (we.handleRightClick(player)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onPlayerInteract(InteractBlockEvent event, @Root Player spongePlayer) {
|
public void onPlayerInteract(InteractBlockEvent event, @Root Player spongePlayer) {
|
||||||
if (platform == null) {
|
if (platform == null) {
|
||||||
@ -244,26 +261,20 @@ public class SpongeWorldEdit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event instanceof InteractBlockEvent.Secondary) {
|
} else if (event instanceof InteractBlockEvent.Secondary) {
|
||||||
if (interactedType != BlockTypes.AIR) {
|
if (!optLoc.isPresent()) {
|
||||||
if (!optLoc.isPresent()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Location<World> loc = optLoc.get();
|
Location<World> loc = optLoc.get();
|
||||||
com.sk89q.worldedit.util.Location pos = new com.sk89q.worldedit.util.Location(
|
com.sk89q.worldedit.util.Location pos = new com.sk89q.worldedit.util.Location(
|
||||||
world, loc.getX(), loc.getY(), loc.getZ());
|
world, loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
|
||||||
if (we.handleBlockRightClick(player, pos)) {
|
if (we.handleBlockRightClick(player, pos)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (we.handleRightClick(player)) {
|
if (we.handleRightClick(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (we.handleRightClick(player)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren