Помогите Перенастройка плагина с PEX на LP

Статус
Закрыто для дальнейших ответов.

EnderDRagon25

Новичок
Баллы
6
Недавно откопал хороший плагин PlugDrop (*********/threads/misc-plug_drop-v0-5-povyshennyj-opyt-i-drop-vipam-1-2-5-1-4-7.20483/). Но появилась проблема с правами. На моём сервере стоит плагин LuckPerms, а PlugDrop поддерживает только PermissionsBukkit и PermissionsEX, соответственно эти плагины видят его права. LuckPerms прав не видит. Внутри плагина так же прописаны только те 2 плагина. Отсюда вытекает вопрос - как перенастроить плагин, чтобы права можно было настраивать с помощью LuckPerms? Пробовал связывать с Vault, не помогло.
P. s. В ссылке блокируется сайт bukkit, вводить надо вручную, файл прикрепляю на всякий случай.
 

Вложения

Ну даешь, использовать плагины 1.2.5-1.4.7 версии. Скорее всего, тебе придется вообще большинство вещей там переписывать, так как, даже поменяв права, все равно работать не будет.
 
А в чем суть плагина, просто код ушасен и не понятно что делает это сложение байтов.
Код:
package ru.WS.DROP.II;

import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.event.entity.EntityDeathEvent;
import org.*********ventory.ItemStack;
import org.bukkit.event.EventPriority;
import org.bukkit.event.EventHandler;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginManager;
import java.util.logging.Logger;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public class RUN extends JavaPlugin implements Listener {
    public boolean usePEX;
    public boolean usePB;
    public static Logger log;
    public List<Material> list;
    public boolean onMobs;
    public boolean onBlocks;

    @Override
    public void onEnable() {
        if (!this.LoadConfig()) {
            this.setEnabled(false);
            return;
        }
        RUN.log.info("Starting WS Plag Drop II ...");
        PluginManager pm = this.getServer().getPluginManager();
        pm.registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        RUN.log.info("Disabling WS Plag Drop II ...");
    }

    private boolean LoadConfig() {
        this.saveDefaultConfig();
        FileConfiguration conf = this.getConfig();
        List<String> mat = (List<String>) conf.getStringList("Material-Not-Drop-Blocks");
        this.onMobs = conf.getBoolean("enabled_drop_mobs", true);
        this.onBlocks = conf.getBoolean("enabled_drop_blocks", true);
        this.list = new ArrayList<Material>();
        for (String s : mat) {
            this.list.add(Material.matchMaterial(s));
        }
        return conf.getBoolean("enabled", true);
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void StopDiamondBlockBreak(BlockBreakEvent e) {
        if (!this.onBlocks) {
            return;
        }
        if (e.isCancelled()) {
            return;
        }
        if (e.getPlayer().getGameMode() == GameMode.CREATIVE) {
            return;
        }
        Material mat = e.getBlock().getType();
        for (int i = 0; i < this.list.size(); ++i) {
            if (mat == this.list.get(i)) {
                return;
            }
        }
        ItemStack[] stack = e.getBlock().getDrops().toArray(new ItemStack[] {});
        if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.20X")) {
            this.dropBlock(stack, 20.0, e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.15X")) {
            this.dropBlock(stack, 15.0, e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.10X")) {
            this.dropBlock(stack, 10.0, e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.5X")) {
            this.dropBlock(stack, 5.0, e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.4X")) {
            this.dropBlock(stack, 4.0, e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.3X")) {
            this.dropBlock(stack, 3.0, e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.2X")) {
            this.dropBlock(stack, 2.0, e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.1.5X")) {
            this.dropBlock(stack, 1.5, e);
        }
        if (e.getPlayer().hasPermission("PlugDrop.Effect.BLOCK.I")) {
            e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.ENDER_SIGNAL, 10);
        }
    }

    public void dropBlock(ItemStack[] stacks, double d, BlockBreakEvent event) {
        if (!this.onBlocks) {
            return;
        }
        for (ItemStack stack : stacks) {
            int l5 = (int) (stack.getAmount() * d);
            int l6 = l5 / 64;
            stack.setAmount(64);
            for (int l7 = 0; l7 < l6; ++l7) {
                event.getBlock().getWorld().dropItem(event.getBlock().getLocation(), stack);
            }
            stack.setAmount(l5 % 64);
            event.getBlock().getWorld().dropItem(event.getBlock().getLocation(), stack);
            stack.setType(Material.AIR);
        }
    }

    @EventHandler
    public void onEntityDeath(EntityDeathEvent event) {
        if (!this.onMobs) {
            return;
        }
        Player player = event.getEntity().getKiller();
        if (player == null) {
            return;
        }
        LivingEntity entity = event.getEntity();
        if (entity.hasPermission("PlugDrop.EXP.20X")) {
            event.setDroppedExp(event.getDroppedExp() * 20);
        } else if (entity.hasPermission("PlugDrop.EXP.15X")) {
            event.setDroppedExp(event.getDroppedExp() * 15);
        } else if (entity.hasPermission("PlugDrop.EXP.10X")) {
            event.setDroppedExp(event.getDroppedExp() * 10);
        } else if (entity.hasPermission("PlugDrop.EXP.5X")) {
            event.setDroppedExp(event.getDroppedExp() * 5);
        } else if (entity.hasPermission("PlugDrop.EXP.4X")) {
            event.setDroppedExp(event.getDroppedExp() * 4);
        } else if (entity.hasPermission("PlugDrop.EXP.3X")) {
            event.setDroppedExp(event.getDroppedExp() * 3);
        } else if (entity.hasPermission("PlugDrop.EXP.2X")) {
            event.setDroppedExp(event.getDroppedExp() * 2);
        } else if (entity.hasPermission("PlugDrop.EXP.1.5X")) {
            event.setDroppedExp((int) (event.getDroppedExp() * 1.5));
        }
        ItemStack[] stack = event.getDrops().toArray(new ItemStack[] {});
        if (entity instanceof Player) {
            if (entity.hasPermission("PlugDrop.DROP.PLAYER")) {
                if (entity.hasPermission("PlugDrop.DROP.20X")) {
                    this.dropEntity(stack, 20.0, event.getEntity());
                } else if (entity.hasPermission("PlugDrop.DROP.15X")) {
                    this.dropEntity(stack, 15.0, event.getEntity());
                } else if (entity.hasPermission("PlugDrop.DROP.10X")) {
                    this.dropEntity(stack, 10.0, event.getEntity());
                } else if (entity.hasPermission("PlugDrop.DROP.5X")) {
                    this.dropEntity(stack, 5.0, event.getEntity());
                } else if (entity.hasPermission("PlugDrop.DROP.4X")) {
                    this.dropEntity(stack, 4.0, event.getEntity());
                } else if (entity.hasPermission("PlugDrop.DROP.3X")) {
                    this.dropEntity(stack, 3.0, event.getEntity());
                } else if (entity.hasPermission("PlugDrop.DROP.2X")) {
                    this.dropEntity(stack, 2.0, event.getEntity());
                } else if (entity.hasPermission("PlugDrop.DROP.1.5X")) {
                    this.dropEntity(stack, 1.5, event.getEntity());
                }
            }
        } else if (entity.hasPermission("PlugDrop.DROP.20X")) {
            this.dropEntity(stack, 20.0, event.getEntity());
        } else if (entity.hasPermission("PlugDrop.DROP.15X")) {
            this.dropEntity(stack, 15.0, event.getEntity());
        } else if (entity.hasPermission("PlugDrop.DROP.10X")) {
            this.dropEntity(stack, 10.0, event.getEntity());
        } else if (entity.hasPermission("PlugDrop.DROP.5X")) {
            this.dropEntity(stack, 5.0, event.getEntity());
        } else if (entity.hasPermission("PlugDrop.DROP.4X")) {
            this.dropEntity(stack, 4.0, event.getEntity());
        } else if (entity.hasPermission("PlugDrop.DROP.3X")) {
            this.dropEntity(stack, 3.0, event.getEntity());
        } else if (entity.hasPermission("PlugDrop.DROP.2X")) {
            this.dropEntity(stack, 2.0, event.getEntity());
        } else if (entity.hasPermission("PlugDrop.DROP.1.5X")) {
            this.dropEntity(stack, 1.5, event.getEntity());
        }
        if (entity.hasPermission("PlugDrop.Effect.I")) {
            event.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 10, 10));
        }
    }

    public void dropEntity(ItemStack[] stacks, double d, LivingEntity entity) {
        for (ItemStack stack : stacks) {
            int l5 = (int) (stack.getAmount() * d);
            int l6 = l5 / 64;
            stack.setAmount(64);
            for (int l7 = 0; l7 < l6; ++l7) {
                entity.getWorld().dropItem(entity.getLocation(), stack);
            }
            stack.setAmount(l5 % 64);
        }
    }

    static {
        log = Logger.getLogger("Minecrat");
    }
}
 
Последнее редактирование:
final FileOutputStream fos = new FileOutputStream(fileConf2); byte[] buff = new byte[65536]; int n; while ((n = resourceAsStream.read(buff)) > 0) { fos.write(buff, 0, n); fos.flush(); } fos.close(); buff = null;
Вроде как-то связано с созданием конфига, но не понятно, почему не использовали обычный saveDefaultConfig(). Я бы такому коду не доверял
 
А в чем суть плагина, просто код ушасен и не понятно что делает это сложение байтов.
Код:
package ru.WS.DROP.II;

import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.*********ventory.ItemStack;
import org.bukkit.event.EventPriority;
import org.bukkit.event.EventHandler;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.configuration.file.FileConfiguration;
import java.io.InputStream;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.FileOutputStream;
import java.io.File;
import org.bukkit.plugin.PluginManager;
import java.util.logging.Logger;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public class RUN extends JavaPlugin implements Listener {
    public boolean usePEX;
    public boolean usePB;
    public static final Logger log;
    public List<Material> list;
    public boolean onMobs;
    public boolean onBlocks;

    public void onEnable() {
        if (!this.LoadConfig()) {
            this.setEnabled(false);
            return;
        }
        RUN.log.info("Starting WS Plag Drop II ...");
        final PluginManager pm = this.getServer().getPluginManager();
        pm.registerEvents(this, this);
    }

    public void onLoad() {
    }

    public void onDisable() {
        RUN.log.info("Disabling WS Plag Drop II ...");
    }

    private boolean LoadConfig() {
        this.saveDefaultConfig();
        final FileConfiguration conf = this.getConfig();
        final List<String> l = (List<String>) conf.getStringList("Material-Not-Drop-Blocks");
        this.onMobs = conf.getBoolean("enabled_drop_mobs", true);
        this.onBlocks = conf.getBoolean("enabled_drop_blocks", true);
        this.list = new ArrayList<Material>();
        Short[] ll = new Short[l.size()];
        ll = l.toArray(ll);
        for (String s : l) {
            this.list.add(Material.matchMaterial(s));
        }
        return conf.getBoolean("enabled", true);
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void StopDiamondBlockBreak(final BlockBreakEvent e) {
        if (!this.onBlocks) {
            return;
        }
        if (e.isCancelled()) {
            return;
        }
        if (e.getPlayer().getGameMode() == GameMode.CREATIVE) {
            return;
        }
        final @NotNull Material lll = e.getBlock().getType();
        for (int i = 0; i < this.list.size(); ++i) {
            if (lll == this.list.get(i)) {
                return;
            }
        }

        final ItemStack[] l2 = e.getBlock().getDrops().toArray(new ItemStack[] {});
        if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.20X")) {
            this.dropBlock(l2, 20.0, (BlockEvent) e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.15X")) {
            this.dropBlock(l2, 15.0, (BlockEvent) e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.10X")) {
            this.dropBlock(l2, 10.0, (BlockEvent) e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.5X")) {
            this.dropBlock(l2, 5.0, (BlockEvent) e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.4X")) {
            this.dropBlock(l2, 4.0, (BlockEvent) e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.3X")) {
            this.dropBlock(l2, 3.0, (BlockEvent) e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.2X")) {
            this.dropBlock(l2, 2.0, (BlockEvent) e);
        } else if (e.getPlayer().hasPermission("PlugDrop.DROP.BLOCK.1.5X")) {
            this.dropBlock(l2, 1.5, (BlockEvent) e);
        }
        if (e.getPlayer().hasPermission("PlugDrop.Effect.BLOCK.I")) {
            e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.ENDER_SIGNAL, 10);
        }
    }

    public void dropBlock(final ItemStack[] a1, final double a2, final BlockEvent a3) {
        if (!this.onBlocks) {
            return;
        }
        for (final ItemStack l3 : a1) {
            final int l5 = (int) (l3.getAmount() * a2);
            final int l6 = l5 / 64;
            l3.setAmount(64);
            for (int l7 = 0; l7 < l6; ++l7) {
                a3.getBlock().getWorld().dropItem(a3.getBlock().getLocation(), l3);
            }
            l3.setAmount(l5 % 64);
            a3.getBlock().getWorld().dropItem(a3.getBlock().getLocation(), l3);
            l3.setType(Material.AIR);
        }
    }

    @EventHandler
    public void onEntityDeath(final EntityDeathEvent a1) {
        if (a1 == null || !(a1.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) || !this.onMobs) {
            return;
        }
        final Player l2 = a1.getEntity().getKiller();
        if (l2 == null) {
            return;
        }
        final LivingEntity l3 = a1.getEntity();
        if (l3.hasPermission("PlugDrop.EXP.20X")) {
            a1.setDroppedExp(a1.getDroppedExp() * 20);
        } else if (l3.hasPermission("PlugDrop.EXP.15X")) {
            a1.setDroppedExp(a1.getDroppedExp() * 15);
        } else if (l3.hasPermission("PlugDrop.EXP.10X")) {
            a1.setDroppedExp(a1.getDroppedExp() * 10);
        } else if (l3.hasPermission("PlugDrop.EXP.5X")) {
            a1.setDroppedExp(a1.getDroppedExp() * 5);
        } else if (l3.hasPermission("PlugDrop.EXP.4X")) {
            a1.setDroppedExp(a1.getDroppedExp() * 4);
        } else if (l3.hasPermission("PlugDrop.EXP.3X")) {
            a1.setDroppedExp(a1.getDroppedExp() * 3);
        } else if (l3.hasPermission("PlugDrop.EXP.2X")) {
            a1.setDroppedExp(a1.getDroppedExp() * 2);
        } else if (l3.hasPermission("PlugDrop.EXP.1.5X")) {
            a1.setDroppedExp((int) (a1.getDroppedExp() * 1.5));
        }
        final Object[] l4 = a1.getDrops().toArray();
        if (l3 instanceof Player) {
            if (l3.hasPermission("PlugDrop.DROP.PLAYER")) {
                if (l2.hasPermission("PlugDrop.DROP.20X")) {
                    this.dropEntity(l4, 20.0, a1.getEntity());
                } else if (l2.hasPermission("PlugDrop.DROP.15X")) {
                    this.dropEntity(l4, 15.0, a1.getEntity());
                } else if (l2.hasPermission("PlugDrop.DROP.10X")) {
                    this.dropEntity(l4, 10.0, a1.getEntity());
                } else if (l2.hasPermission("PlugDrop.DROP.5X")) {
                    this.dropEntity(l4, 5.0, a1.getEntity());
                } else if (l2.hasPermission("PlugDrop.DROP.4X")) {
                    this.dropEntity(l4, 4.0, a1.getEntity());
                } else if (l2.hasPermission("PlugDrop.DROP.3X")) {
                    this.dropEntity(l4, 3.0, a1.getEntity());
                } else if (l2.hasPermission("PlugDrop.DROP.2X")) {
                    this.dropEntity(l4, 2.0, a1.getEntity());
                } else if (l2.hasPermission("PlugDrop.DROP.1.5X")) {
                    this.dropEntity(l4, 1.5, a1.getEntity());
                }
            }
        } else if (l2.hasPermission("PlugDrop.DROP.20X")) {
            this.dropEntity(l4, 20.0, a1.getEntity());
        } else if (l2.hasPermission("PlugDrop.DROP.15X")) {
            this.dropEntity(l4, 15.0, a1.getEntity());
        } else if (l2.hasPermission("PlugDrop.DROP.10X")) {
            this.dropEntity(l4, 10.0, a1.getEntity());
        } else if (l2.hasPermission("PlugDrop.DROP.5X")) {
            this.dropEntity(l4, 5.0, a1.getEntity());
        } else if (l2.hasPermission("PlugDrop.DROP.4X")) {
            this.dropEntity(l4, 4.0, a1.getEntity());
        } else if (l2.hasPermission("PlugDrop.DROP.3X")) {
            this.dropEntity(l4, 3.0, a1.getEntity());
        } else if (l2.hasPermission("PlugDrop.DROP.2X")) {
            this.dropEntity(l4, 2.0, a1.getEntity());
        } else if (l2.hasPermission("PlugDrop.DROP.1.5X")) {
            this.dropEntity(l4, 1.5, a1.getEntity());
        }
        if (l2.hasPermission("PlugDrop.Effect.I")) {
            a1.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 10, 10));
        }
    }

    public void dropEntity(final Object[] a1, final double a2, final LivingEntity a3) {
        for (final Object l3 : a1) {
            final ItemStack l4 = (ItemStack) l3;
            final int l5 = (int) (l4.getAmount() * a2);
            final int l6 = l5 / 64;
            l4.setAmount(64);
            for (int l7 = 0; l7 < l6; ++l7) {
                a3.getWorld().dropItem(a3.getLocation(), l4);
            }
            l4.setAmount(l5 % 64);
        }
    }

    static {
        log = Logger.getLogger("Minecrat");
    }
}
код после декомпиля видимо
 
Всё правильно выше пишут - плагин очень старый. Даже если оживишь права - скорее всего, не будет работать что-то ещё.

Наверняка есть аналоги с подобным функционалом, поищи.

Либо можешь найти программиста, который за небольшую сумму переведёт плагин на новую версию и добавит поддержку LP. Но смысла особо нет
 
player.hasPermission = универсал. И плагин не просто стар, он успел умереть 80 раз :D 2к12 год.
Не везде достаточно hasPermission, даже не везде достаточно Vault.
Например, список всех игроков в группе просто так не получить без реализации под каждый конкретный плагин прав.

Ну а плагин дохлый, это правда
 
Статус
Закрыто для дальнейших ответов.
Назад
Верх