2014-04-03 02:08:50 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
2014-04-03 02:08:50 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
|
|
* for more details.
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-04-03 02:08:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.command.tool;
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.EditSession;
|
|
|
|
import com.sk89q.worldedit.LocalConfiguration;
|
|
|
|
import com.sk89q.worldedit.LocalSession;
|
|
|
|
import com.sk89q.worldedit.entity.Player;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Platform;
|
|
|
|
import com.sk89q.worldedit.world.World;
|
2018-07-30 13:26:06 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockType;
|
|
|
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A super pickaxe mode that removes one block.
|
|
|
|
*/
|
|
|
|
public class SinglePickaxe implements BlockTool {
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
@Override
|
|
|
|
public boolean canUse(Actor player) {
|
2014-04-03 02:08:50 +00:00
|
|
|
return player.hasPermission("worldedit.superpickaxe");
|
|
|
|
}
|
|
|
|
|
2014-06-28 02:55:38 +00:00
|
|
|
@Override
|
|
|
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
2014-06-29 22:36:41 +00:00
|
|
|
World world = (World) clicked.getExtent();
|
2018-08-12 14:03:07 +00:00
|
|
|
final BlockType blockType = world.getLazyBlock(clicked.toVector()).getBlockType();
|
|
|
|
if (blockType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) {
|
2014-04-03 02:08:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-23 07:33:00 +00:00
|
|
|
EditSession editSession = session.createEditSession(player);
|
|
|
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2014-04-23 07:33:00 +00:00
|
|
|
try {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) {
|
|
|
|
// TODO FIXME play effect
|
|
|
|
// world.playEffect(clicked.toVector(), 2001, blockType);
|
|
|
|
}
|
2014-04-23 07:33:00 +00:00
|
|
|
} finally {
|
|
|
|
editSession.flushQueue();
|
2018-08-12 14:03:07 +00:00
|
|
|
session.remember(editSession);
|
2014-04-23 07:33:00 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-12 16:36:39 +00:00
|
|
|
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|