mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Further modernise and remove legacy item classes
This commit is contained in:
@ -26,11 +26,13 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.ItemID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.blocks.type.ItemType;
|
||||
import com.sk89q.worldedit.blocks.type.ItemTypes;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
@ -81,12 +83,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
@Override
|
||||
public boolean isHoldingPickAxe() {
|
||||
int item = getItemInHand();
|
||||
return item == ItemID.IRON_PICK
|
||||
|| item == ItemID.WOOD_PICKAXE
|
||||
|| item == ItemID.STONE_PICKAXE
|
||||
|| item == ItemID.DIAMOND_PICKAXE
|
||||
|| item == ItemID.GOLD_PICKAXE;
|
||||
ItemType item = getItemInHand(HandSide.MAIN_HAND).getType();
|
||||
return item == ItemTypes.IRON_PICKAXE
|
||||
|| item == ItemTypes.WOODEN_PICKAXE
|
||||
|| item == ItemTypes.STONE_PICKAXE
|
||||
|| item == ItemTypes.DIAMOND_PICKAXE
|
||||
|| item == ItemTypes.GOLDEN_PICKAXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -362,12 +364,12 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlockInHand() throws WorldEditException {
|
||||
final int typeId = getItemInHand();
|
||||
if (!getWorld().isValidBlockType(typeId)) {
|
||||
throw new NotABlockException(typeId);
|
||||
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
|
||||
final ItemType typeId = getItemInHand(handSide).getType();
|
||||
if (!getWorld().isValidBlockType(typeId.getLegacyId())) {
|
||||
throw new NotABlockException(typeId.getId());
|
||||
}
|
||||
return new BaseBlock(typeId);
|
||||
return new BaseBlock(typeId.getLegacyId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,6 +41,7 @@ import com.sk89q.worldedit.event.platform.PlayerInputEvent;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.internal.ServerInterfaceAdapter;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -318,7 +319,7 @@ public class PlatformManager {
|
||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||
|
||||
if (event.getType() == Interaction.HIT) {
|
||||
if (player.getItemInHand() == getConfiguration().wandItem) {
|
||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
|
||||
if (!session.isToolControlEnabled()) {
|
||||
return;
|
||||
}
|
||||
@ -345,8 +346,8 @@ public class PlatformManager {
|
||||
}
|
||||
}
|
||||
|
||||
Tool tool = session.getTool(player.getItemInHand());
|
||||
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
if (tool instanceof DoubleActionBlockTool) {
|
||||
if (tool.canUse(player)) {
|
||||
((DoubleActionBlockTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||
event.setCancelled(true);
|
||||
@ -354,7 +355,7 @@ public class PlatformManager {
|
||||
}
|
||||
|
||||
} else if (event.getType() == Interaction.OPEN) {
|
||||
if (player.getItemInHand() == getConfiguration().wandItem) {
|
||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
|
||||
if (!session.isToolControlEnabled()) {
|
||||
return;
|
||||
}
|
||||
@ -372,8 +373,8 @@ public class PlatformManager {
|
||||
return;
|
||||
}
|
||||
|
||||
Tool tool = session.getTool(player.getItemInHand());
|
||||
if (tool != null && tool instanceof BlockTool) {
|
||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
if (tool instanceof BlockTool) {
|
||||
if (tool.canUse(player)) {
|
||||
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
|
||||
event.setCancelled(true);
|
||||
@ -391,7 +392,7 @@ public class PlatformManager {
|
||||
|
||||
switch (event.getInputType()) {
|
||||
case PRIMARY: {
|
||||
if (player.getItemInHand() == getConfiguration().navigationWand) {
|
||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
|
||||
if (getConfiguration().navigationWandMaxDistance <= 0) {
|
||||
return;
|
||||
}
|
||||
@ -413,7 +414,7 @@ public class PlatformManager {
|
||||
|
||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||
|
||||
Tool tool = session.getTool(player.getItemInHand());
|
||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
if (tool instanceof DoubleActionTraceTool) {
|
||||
if (tool.canUse(player)) {
|
||||
((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
||||
@ -426,7 +427,7 @@ public class PlatformManager {
|
||||
}
|
||||
|
||||
case SECONDARY: {
|
||||
if (player.getItemInHand() == getConfiguration().navigationWand) {
|
||||
if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
|
||||
if (getConfiguration().navigationWandMaxDistance <= 0) {
|
||||
return;
|
||||
}
|
||||
@ -445,8 +446,8 @@ public class PlatformManager {
|
||||
|
||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||
|
||||
Tool tool = session.getTool(player.getItemInHand());
|
||||
if (tool != null && tool instanceof TraceTool) {
|
||||
Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
if (tool instanceof TraceTool) {
|
||||
if (tool.canUse(player)) {
|
||||
((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
|
||||
event.setCancelled(true);
|
||||
|
@ -20,11 +20,13 @@
|
||||
package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
@ -58,8 +60,8 @@ class PlayerProxy extends AbstractPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
return basePlayer.getItemInHand();
|
||||
public BaseItemStack getItemInHand(HandSide handSide) {
|
||||
return basePlayer.getItemInHand(handSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user