Compare commits

..

No commits in common. "master" and "v2.4.3.4" have entirely different histories.

8 changed files with 26 additions and 46 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId> <groupId>cn.lunadeer</groupId>
<artifactId>LiteWorldEdit</artifactId> <artifactId>LiteWorldEdit</artifactId>
<version>2.5.0.1</version> <version>2.4.3.4</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>LiteWorldEdit</name> <name>LiteWorldEdit</name>

View File

@ -5,7 +5,6 @@ import cn.lunadeer.liteworldedit.JobGenerator.Empty;
import cn.lunadeer.liteworldedit.JobGenerator.Fill; import cn.lunadeer.liteworldedit.JobGenerator.Fill;
import cn.lunadeer.liteworldedit.JobGenerator.OverLay; import cn.lunadeer.liteworldedit.JobGenerator.OverLay;
import cn.lunadeer.liteworldedit.Jobs.Job; import cn.lunadeer.liteworldedit.Jobs.Job;
import cn.lunadeer.liteworldedit.Managers.ConfigManager;
import cn.lunadeer.liteworldedit.Managers.Point; import cn.lunadeer.liteworldedit.Managers.Point;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -103,11 +102,11 @@ public class Commands implements TabExecutor {
if (!player.isOp()) { if (!player.isOp()) {
Notification.error(player, "你没有权限。"); Notification.error(player, "你没有权限。");
} else { } else {
LiteWorldEdit.config.reload(); LiteWorldEdit.instance.reloadConfig();
Notification.info(player, "已重载配置文件。"); Notification.info(player, "已重载配置文件。");
} }
} else { } else {
LiteWorldEdit.config.reload(); LiteWorldEdit.instance.reloadConfig();
LoggerX.info("已重载配置文件。"); LoggerX.info("已重载配置文件。");
} }
} }

View File

@ -1,7 +1,10 @@
package cn.lunadeer.liteworldedit.Jobs; package cn.lunadeer.liteworldedit.Jobs;
import cn.lunadeer.liteworldedit.LoggerX; import cn.lunadeer.liteworldedit.LoggerX;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
@ -51,9 +54,7 @@ public class Absorb extends Job {
raw_block.setType(Material.SPONGE); raw_block.setType(Material.SPONGE);
raw_block.setType(Material.AIR); raw_block.setType(Material.AIR);
// 损坏镐 // 损坏镐
if (!_creator.isOp() && _creator.getGameMode() != GameMode.CREATIVE) {
useNetherPickaxe(pickaxe); useNetherPickaxe(pickaxe);
}
return JobErrCode.OK; return JobErrCode.OK;
} else { } else {
return JobErrCode.NO_PERMISSION; return JobErrCode.NO_PERMISSION;

View File

@ -91,12 +91,10 @@ public class Job {
} }
// 如果耐久小于10提示玩家 // 如果耐久小于10提示玩家
pickaxe_damage = (Damageable) pickaxe_meta; pickaxe_damage = (Damageable) pickaxe_meta;
if (!pickaxe_meta.isUnbreakable()) {
if (pickaxe_damage.getDamage() >= 2031 - 10) { if (pickaxe_damage.getDamage() >= 2031 - 10) {
LoggerX.debug(index + " 下界合金镐耐久太低!"); LoggerX.debug(index + " 下界合金镐耐久太低!");
continue; continue;
} }
}
pickaxe = p; pickaxe = p;
break; break;
} }
@ -106,13 +104,9 @@ public class Job {
public static ItemStack useNetherPickaxe(ItemStack pickaxe) { public static ItemStack useNetherPickaxe(ItemStack pickaxe) {
int durability = pickaxe.getEnchantmentLevel(Enchantment.DURABILITY); int durability = pickaxe.getEnchantmentLevel(Enchantment.DURABILITY);
double random = Math.random(); double random = Math.random();
Damageable pickaxe_damage = (Damageable) pickaxe.getItemMeta();
if (pickaxe_damage.isUnbreakable()) {
// 无限耐久则不损坏
return pickaxe;
}
if (random < 1.0 / (durability + 1)) { if (random < 1.0 / (durability + 1)) {
// 扣除耐久 // 扣除耐久
Damageable pickaxe_damage = (Damageable) pickaxe.getItemMeta();
pickaxe_damage.setDamage(pickaxe_damage.getDamage() + 1); pickaxe_damage.setDamage(pickaxe_damage.getDamage() + 1);
pickaxe.setItemMeta(pickaxe_damage); pickaxe.setItemMeta(pickaxe_damage);
} }

View File

@ -1,7 +1,10 @@
package cn.lunadeer.liteworldedit.Jobs; package cn.lunadeer.liteworldedit.Jobs;
import cn.lunadeer.liteworldedit.LoggerX; import cn.lunadeer.liteworldedit.LoggerX;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.ShulkerBox; import org.bukkit.block.ShulkerBox;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -72,9 +75,7 @@ public class Place extends Job {
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
raw_block.setType(_block); raw_block.setType(_block);
if (!_creator.isOp() && _creator.getGameMode() != GameMode.CREATIVE) {
stack.setAmount(stack.getAmount() - 1); stack.setAmount(stack.getAmount() - 1);
}
return JobErrCode.OK; return JobErrCode.OK;
} else { } else {
return JobErrCode.NO_PERMISSION; return JobErrCode.NO_PERMISSION;

View File

@ -2,13 +2,15 @@ package cn.lunadeer.liteworldedit.Jobs;
import cn.lunadeer.liteworldedit.LiteWorldEdit; import cn.lunadeer.liteworldedit.LiteWorldEdit;
import cn.lunadeer.liteworldedit.LoggerX; import cn.lunadeer.liteworldedit.LoggerX;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
public class Remove extends Job { public class Remove extends Job {
@ -35,7 +37,7 @@ public class Remove extends Job {
} }
// 获取玩家背包中的下届合金镐 // 获取玩家背包中的下届合金镐
HashMap<Integer, ?> pickaxes = getNetherPickaxes(_creator); HashMap<Integer, ?> pickaxes = getNetherPickaxes(_creator);
if (pickaxes.isEmpty()) { if (pickaxes.size() == 0) {
return JobErrCode.NO_PICKAXE; return JobErrCode.NO_PICKAXE;
} }
ItemStack pickaxe = getUsableNetherPickaxe(pickaxes, _creator); ItemStack pickaxe = getUsableNetherPickaxe(pickaxes, _creator);
@ -46,17 +48,12 @@ public class Remove extends Job {
BlockBreakEvent event = new BlockBreakEvent(raw_block, _creator); BlockBreakEvent event = new BlockBreakEvent(raw_block, _creator);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
Collection<ItemStack> drops = raw_block.getDrops(pickaxe, _creator);
raw_block.setType(Material.AIR); raw_block.setType(Material.AIR);
if (LiteWorldEdit.instance.getConfigMgr().isDropItems()) { if (LiteWorldEdit.instance.getConfigMgr().isDropItems()) {
for (ItemStack drop : drops) { raw_block.getWorld().dropItemNaturally(raw_block.getLocation(), new ItemStack(raw_block.getType()));
raw_block.getWorld().dropItemNaturally(raw_block.getLocation(), drop);
}
} }
// 损坏镐 // 损坏镐
if (!_creator.isOp() && _creator.getGameMode() != GameMode.CREATIVE) {
useNetherPickaxe(pickaxe); useNetherPickaxe(pickaxe);
}
return JobErrCode.OK; return JobErrCode.OK;
} else { } else {
return JobErrCode.NO_PERMISSION; return JobErrCode.NO_PERMISSION;

View File

@ -2,11 +2,6 @@ package cn.lunadeer.liteworldedit;
import cn.lunadeer.liteworldedit.Jobs.Job; import cn.lunadeer.liteworldedit.Jobs.Job;
import cn.lunadeer.liteworldedit.Jobs.JobErrCode; import cn.lunadeer.liteworldedit.Jobs.JobErrCode;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Task implements Runnable { public class Task implements Runnable {
@ -45,8 +40,7 @@ public class Task implements Runnable {
} }
Player player = job.get_creator(); Player player = job.get_creator();
if (re.canContinue()) { if (re.canContinue()) {
TextComponent warn = Component.text("警告:" + re.getMessage(), Style.style(TextColor.color(TextColor.color(255, 185, 69)), TextDecoration.BOLD)); Notification.titleWarn(player, "警告", re.getMessage());
player.sendActionBar(warn);
job = this.xPlayer.popJob(); job = this.xPlayer.popJob();
if (job == null) { if (job == null) {
return; return;

View File

@ -12,10 +12,4 @@ commands:
LiteWorldEdit: LiteWorldEdit:
description: 简易创世神命令 description: 简易创世神命令
usage: /lwe <cmd> usage: /lwe <cmd>
aliases: [ lwe ] aliases: [lwe]
permission: lwe.command
permission-message: 你没有权限使用这个命令。
permissions:
lwe.command:
description: 是否允许使用 LiteWorldEdit
default: true