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;
|
2019-01-09 07:13:44 +00:00
|
|
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
2014-06-28 02:55:38 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Platform;
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
2014-06-28 02:55:38 +00:00
|
|
|
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) {
|
2019-01-09 07:13:44 +00:00
|
|
|
World world = (World) clicked.getExtent();
|
2019-03-31 16:09:20 +00:00
|
|
|
BlockVector3 blockPoint = clicked.toBlockPoint();
|
2018-12-23 16:19:33 +00:00
|
|
|
final BlockType blockType = world.getBlock(blockPoint).getBlockType();
|
|
|
|
if (blockType == BlockTypes.BEDROCK
|
|
|
|
&& !player.canDestroyBedrock()) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2018-10-21 02:50:35 +00:00
|
|
|
try (EditSession editSession = session.createEditSession(player)) {
|
2018-12-23 16:19:33 +00:00
|
|
|
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
|
|
|
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
|
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
|
|
|
}
|