use of com.bergerkiller.bukkit.common.map.MapPlayerInput in project BKCommonLib by bergerhealer.
the class CommonMapController method onPacketReceive.
@Override
public void onPacketReceive(PacketReceiveEvent event) {
// Handle input coming from the player for the map
if (event.getType() == PacketType.IN_STEER_VEHICLE) {
Player p = event.getPlayer();
MapPlayerInput input = playerInputs.get(p);
if (input != null) {
CommonPacket packet = event.getPacket();
int dx = (int) -Math.signum(packet.read(PacketType.IN_STEER_VEHICLE.sideways));
int dy = (int) -Math.signum(packet.read(PacketType.IN_STEER_VEHICLE.forwards));
int dz = 0;
if (packet.read(PacketType.IN_STEER_VEHICLE.unmount)) {
dz -= 1;
}
if (packet.read(PacketType.IN_STEER_VEHICLE.jump)) {
dz += 1;
}
// Receive input. If it will be handled, it will cancel further handling of this packet
event.setCancelled(input.receiveInput(dx, dy, dz));
}
}
}
use of com.bergerkiller.bukkit.common.map.MapPlayerInput in project BKCommonLib by bergerhealer.
the class CommonMapController method getPlayerInput.
/**
* Gets the Player Input controller for a certain player
*
* @param player
* @return player input
*/
public MapPlayerInput getPlayerInput(Player player) {
MapPlayerInput input = playerInputs.get(player);
if (input == null) {
input = new MapPlayerInput(player);
playerInputs.put(player, input);
}
return input;
}
Aggregations