This commit is contained in:
parent
b976339687
commit
fd13d20676
@ -168,9 +168,6 @@ ForceLoadChunks:
|
||||
# 附魔瓶经验值倍率
|
||||
ExpBottleRatio: 1.0
|
||||
|
||||
# 战利品倍率 (当大于1时会自动阻止怪物拾东西避免刷物品)
|
||||
LootTableRatio: 1
|
||||
|
||||
# 强加载区块列表
|
||||
ForceLoadChunks:
|
||||
# - world:0:0
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>EssentialsD</artifactId>
|
||||
<version>1.15.12</version>
|
||||
<version>1.17.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EssentialsD</name>
|
||||
|
@ -2,25 +2,22 @@ package cn.lunadeer.essentialsd;
|
||||
|
||||
import cn.lunadeer.essentialsd.utils.XLogger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Sign;
|
||||
import org.bukkit.block.data.type.Stairs;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ChairEvent implements Listener {
|
||||
|
||||
|
@ -5,7 +5,6 @@ import cn.lunadeer.essentialsd.recipes.*;
|
||||
import cn.lunadeer.essentialsd.utils.ConfigManager;
|
||||
import cn.lunadeer.essentialsd.utils.Scheduler;
|
||||
import cn.lunadeer.essentialsd.utils.XLogger;
|
||||
import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -39,6 +38,7 @@ public final class EssentialsD extends JavaPlugin {
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("storm")).setExecutor(new Storm());
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("enderchest")).setExecutor(new EnderChest());
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("tpa")).setExecutor(new Teleport());
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("inspect")).setExecutor(new Inspect());
|
||||
|
||||
this.getServer().addRecipe(InvisibleItemFrame.getRecipe());
|
||||
this.getServer().addRecipe(InvisibleGlowItemFrame.getRecipe());
|
||||
|
@ -5,7 +5,6 @@ import cn.lunadeer.essentialsd.recipes.Crowbar;
|
||||
import cn.lunadeer.essentialsd.recipes.InvisibleGlowItemFrame;
|
||||
import cn.lunadeer.essentialsd.recipes.InvisibleItemFrame;
|
||||
import cn.lunadeer.essentialsd.utils.Notification;
|
||||
import cn.lunadeer.essentialsd.utils.XLogger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
@ -16,22 +15,18 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.ExpBottleEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.world.LootGenerateEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Events implements Listener {
|
||||
@ -197,33 +192,4 @@ public class Events implements Listener {
|
||||
}
|
||||
event.setExperience((int) (exp * EssentialsD.config.getExpBottleRatio()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void lootTableRation(EntityDeathEvent event) {
|
||||
XLogger.debug("LootGenerateEvent");
|
||||
Integer ratio = EssentialsD.config.getLootTableRatio();
|
||||
if (ratio < 0) {
|
||||
return;
|
||||
}
|
||||
XLogger.debug("ratio: " + ratio);
|
||||
List<ItemStack> loots = event.getDrops();
|
||||
for (ItemStack loot : loots) {
|
||||
XLogger.debug("LootGenerateEvent: " + loot.getType().name());
|
||||
loot.setAmount(loot.getAmount() * ratio);
|
||||
XLogger.debug("LootGenerateEvent: " + loot.getAmount());
|
||||
}
|
||||
event.setDroppedExp(event.getDroppedExp() * ratio);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // prevent mob pick up item for duplication
|
||||
public void mobPickUpItem(EntityPickupItemEvent event) {
|
||||
if (!(event.getEntity() instanceof Mob)) {
|
||||
return;
|
||||
}
|
||||
Integer ratio = EssentialsD.config.getLootTableRatio();
|
||||
if (ratio > 1) {
|
||||
XLogger.debug("prevent mobPickUpItem");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
src/main/java/cn/lunadeer/essentialsd/commands/Inspect.java
Normal file
50
src/main/java/cn/lunadeer/essentialsd/commands/Inspect.java
Normal file
@ -0,0 +1,50 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.utils.Notification;
|
||||
import cn.lunadeer.essentialsd.utils.XLogger;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static cn.lunadeer.essentialsd.commands.Apis.opCommandGetPlayer;
|
||||
|
||||
public class Inspect implements CommandExecutor {
|
||||
/**
|
||||
* Executes the given command, returning its success.
|
||||
* <br>
|
||||
* If false is returned, then the "usage" plugin.yml entry for this command
|
||||
* (if defined) will be sent to the player.
|
||||
*
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return true if a valid command, otherwise false
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
Notification.error(sender, "只有玩家才能使用这个命令");
|
||||
return false;
|
||||
}
|
||||
Player op = (Player) sender;
|
||||
if (!op.isOp()) {
|
||||
XLogger.warn("玩家 " + op.getName() + " 试图使用检查命令");
|
||||
Notification.error(op, "你没有权限使用这个命令");
|
||||
return false;
|
||||
}
|
||||
EssentialsD.scheduler.global.run(EssentialsD.instance, (instance) -> {
|
||||
Player target = opCommandGetPlayer(sender, args);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
Inventory inv = target.getInventory();
|
||||
op.openInventory(inv);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ConfigManager {
|
||||
public ConfigManager(EssentialsD plugin) {
|
||||
@ -28,7 +27,6 @@ public class ConfigManager {
|
||||
_tp_delay = _file.getInt("Teleport.Delay", 0);
|
||||
_tp_cool_down = _file.getInt("Teleport.CoolDown", 0);
|
||||
_tp_expire = _file.getInt("Teleport.Expire", 30);
|
||||
_loot_table_ratio = _file.getInt("LootTableRatio", 1);
|
||||
_chair_enable = _file.getBoolean("Chair.Enable", true);
|
||||
_chair_max_width = _file.getInt("Chair.MaxWidth", 4);
|
||||
_chair_sign_check = _file.getBoolean("Chair.SignCheck", false);
|
||||
@ -81,9 +79,6 @@ public class ConfigManager {
|
||||
return _tp_expire;
|
||||
}
|
||||
|
||||
public Integer getLootTableRatio() {
|
||||
return _loot_table_ratio;
|
||||
}
|
||||
|
||||
public Boolean getChairEnable() {
|
||||
return _chair_enable;
|
||||
@ -150,7 +145,6 @@ public class ConfigManager {
|
||||
private Integer _tp_expire;
|
||||
private Integer _tp_delay;
|
||||
private Integer _tp_cool_down;
|
||||
private Integer _loot_table_ratio;
|
||||
private Boolean _chair_enable;
|
||||
private Integer _chair_max_width;
|
||||
private Boolean _chair_sign_check;
|
||||
|
@ -1,9 +1,6 @@
|
||||
# 附魔瓶经验值倍率
|
||||
ExpBottleRatio: 1.0
|
||||
|
||||
# 战利品倍率 (当大于1时会自动阻止怪物拾东西避免刷物品)
|
||||
LootTableRatio: 1
|
||||
|
||||
# 强加载区块列表
|
||||
ForceLoadChunks:
|
||||
# - world:0:0
|
||||
|
@ -55,3 +55,6 @@ commands:
|
||||
tpa:
|
||||
description: 发起传送请求
|
||||
usage: /tpa <player>
|
||||
inspect:
|
||||
description: 检查玩家背包
|
||||
usage: /inspect <player>
|
Loading…
Reference in New Issue
Block a user