Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Changed arm swing event to use arm swing; now compass right click toggles the compass mode between /jumpto and /thru.
Dieser Commit ist enthalten in:
Ursprung
c49631de1e
Commit
fdb7c31aae
@ -32,6 +32,11 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class LocalSession {
|
public class LocalSession {
|
||||||
|
public enum CompassMode {
|
||||||
|
JUMPTO,
|
||||||
|
THRU
|
||||||
|
}
|
||||||
|
|
||||||
public static final int MAX_HISTORY_SIZE = 15;
|
public static final int MAX_HISTORY_SIZE = 15;
|
||||||
|
|
||||||
private boolean placeAtPos1 = false;
|
private boolean placeAtPos1 = false;
|
||||||
@ -49,6 +54,7 @@ public class LocalSession {
|
|||||||
private boolean useInventory;
|
private boolean useInventory;
|
||||||
private Snapshot snapshot;
|
private Snapshot snapshot;
|
||||||
private String lastScript;
|
private String lastScript;
|
||||||
|
private CompassMode compassMode = CompassMode.JUMPTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear history.
|
* Clear history.
|
||||||
@ -427,4 +433,18 @@ public class LocalSession {
|
|||||||
public void setLastScript(String lastScript) {
|
public void setLastScript(String lastScript) {
|
||||||
this.lastScript = lastScript;
|
this.lastScript = lastScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the compassMode
|
||||||
|
*/
|
||||||
|
public CompassMode getCompassMode() {
|
||||||
|
return compassMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param compassMode the compassMode to set
|
||||||
|
*/
|
||||||
|
public void setCompassMode(CompassMode compassMode) {
|
||||||
|
this.compassMode = compassMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import java.util.logging.Logger;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
|
import com.sk89q.worldedit.LocalSession.CompassMode;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.bags.BlockBag;
|
||||||
import com.sk89q.worldedit.blocks.*;
|
import com.sk89q.worldedit.blocks.*;
|
||||||
import com.sk89q.worldedit.data.*;
|
import com.sk89q.worldedit.data.*;
|
||||||
@ -1952,14 +1953,55 @@ public class WorldEditController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (player.getItemInHand() == config.navigationWand
|
} else if (player.getItemInHand() == config.navigationWand
|
||||||
&& config.navigationWandMaxDistance > 0
|
&& config.navigationWandMaxDistance > 0) {
|
||||||
&& player.hasPermission("jumpto")) {
|
CompassMode mode = session.getCompassMode();
|
||||||
|
|
||||||
|
if (player.hasPermission("jumpto") && mode == CompassMode.JUMPTO) {
|
||||||
WorldVector pos = player.getSolidBlockTrace(config.navigationWandMaxDistance);
|
WorldVector pos = player.getSolidBlockTrace(config.navigationWandMaxDistance);
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
player.findFreePosition(pos);
|
player.findFreePosition(pos);
|
||||||
} else {
|
} else {
|
||||||
player.printError("No block in sight (or too far)!");
|
player.printError("No block in sight (or too far)!");
|
||||||
}
|
}
|
||||||
|
} else if (mode == CompassMode.THRU) { // Permission is implied
|
||||||
|
if (!player.passThroughForwardWall(40)) {
|
||||||
|
player.printError("Nothing to pass through!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on right click (not on a block).
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean handleRightClick(LocalPlayer player) {
|
||||||
|
LocalSession session = getSession(player);
|
||||||
|
|
||||||
|
if (player.getItemInHand() == config.navigationWand) {
|
||||||
|
CompassMode mode = session.getCompassMode();
|
||||||
|
|
||||||
|
if (mode == CompassMode.JUMPTO) {
|
||||||
|
if (player.hasPermission("thru")) {
|
||||||
|
session.setCompassMode(CompassMode.THRU);
|
||||||
|
player.print("Switched to /thru mode.");
|
||||||
|
} else {
|
||||||
|
player.printError("You don't have permission for /thru.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (player.hasPermission("jumpto")) {
|
||||||
|
session.setCompassMode(CompassMode.JUMPTO);
|
||||||
|
player.print("Switched to /jumpto mode.");
|
||||||
|
} else {
|
||||||
|
player.printError("You don't have permission for /jumpto.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
|
import org.bukkit.event.player.PlayerAnimationType;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
import org.bukkit.event.player.PlayerItemEvent;
|
import org.bukkit.event.player.PlayerItemEvent;
|
||||||
@ -34,6 +36,17 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
*/
|
*/
|
||||||
private WorldEditPlugin plugin;
|
private WorldEditPlugin plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player plays an animation, such as an arm swing
|
||||||
|
*
|
||||||
|
* @param event Relevant event details
|
||||||
|
*/
|
||||||
|
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||||
|
if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) {
|
||||||
|
plugin.controller.handleArmSwing(wrapPlayer(event.getPlayer()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object;
|
* Construct the object;
|
||||||
*
|
*
|
||||||
@ -71,7 +84,7 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
* @param event Relevant event details
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onPlayerItem(PlayerItemEvent event) {
|
public void onPlayerItem(PlayerItemEvent event) {
|
||||||
if (plugin.controller.handleArmSwing(wrapPlayer(event.getPlayer()))) {
|
if (plugin.controller.handleRightClick(wrapPlayer(event.getPlayer()))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT,
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT,
|
||||||
playerListener, Priority.Normal, this);
|
playerListener, Priority.Normal, this);
|
||||||
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_ANIMATION,
|
||||||
|
playerListener, Priority.Normal, this);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_ITEM,
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_ITEM,
|
||||||
playerListener, Priority.Normal, this);
|
playerListener, Priority.Normal, this);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND,
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND,
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren