Search in sources :

Example 1 with NMSAssistant

use of preponderous.ponder.minecraft.bukkit.nms.NMSAssistant in project Storage by VoChiDanh.

the class Files method colorize.

// Colorizes messages with preset colorcodes (&) and if using 1.16+, applies hex values via "&#hexvalue"
public static String colorize(String input) {
    input = ChatColor.translateAlternateColorCodes('&', input);
    NMSAssistant nms = new NMSAssistant();
    if (nms.isVersionGreaterThan(15)) {
        input = translateHexColorCodes("\\&#", "", input);
    }
    return input;
}
Also used : NMSAssistant(preponderous.ponder.minecraft.bukkit.nms.NMSAssistant)

Example 2 with NMSAssistant

use of preponderous.ponder.minecraft.bukkit.nms.NMSAssistant in project bCore by D-x-Z.

the class Data method convert.

// Colorizes messages with preset colorcodes (&) and if using 1.16+, applies hex values via "&#hexvalue"
public static String convert(String input) {
    input = ChatColor.translateAlternateColorCodes('&', input);
    NMSAssistant nms = new NMSAssistant();
    if (nms.isVersionGreaterThan(15)) {
        input = translateHexColorCodes("\\&#", "", input);
    }
    return input;
}
Also used : NMSAssistant(preponderous.ponder.minecraft.bukkit.nms.NMSAssistant)

Example 3 with NMSAssistant

use of preponderous.ponder.minecraft.bukkit.nms.NMSAssistant in project bCore by D-x-Z.

the class bCore method performNMSChecks.

private void performNMSChecks() {
    final NMSAssistant nmsAssistant = new NMSAssistant();
    if (nmsAssistant.isVersionGreaterThan(7)) {
        getLogger().log(Level.INFO, "Loading data matching server version " + nmsAssistant.getNMSVersion().toString());
    } else {
        getLogger().warning("The server version is not suitable to load the plugin");
        getLogger().warning("Support version 1.8.x - 1.18.x");
        Bukkit.getServer().getPluginManager().disablePlugin(this);
    }
}
Also used : NMSAssistant(preponderous.ponder.minecraft.bukkit.nms.NMSAssistant)

Example 4 with NMSAssistant

use of preponderous.ponder.minecraft.bukkit.nms.NMSAssistant in project Storage by D-x-Z.

the class Files method colorize.

// Colorizes messages with preset colorcodes (&) and if using 1.16+, applies hex values via "&#hexvalue"
public static String colorize(String input) {
    input = ChatColor.translateAlternateColorCodes('&', input);
    NMSAssistant nms = new NMSAssistant();
    if (nms.isVersionGreaterThan(15)) {
        input = translateHexColorCodes("\\&#", "", input);
    }
    return input;
}
Also used : NMSAssistant(preponderous.ponder.minecraft.bukkit.nms.NMSAssistant)

Example 5 with NMSAssistant

use of preponderous.ponder.minecraft.bukkit.nms.NMSAssistant in project Storage by D-x-Z.

the class BlockBreak method onBreaking.

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBreaking(@NotNull BlockBreakEvent e) {
    Player p = e.getPlayer();
    String blocks = e.getBlock().getType().toString();
    String items = null;
    NMSAssistant nms = new NMSAssistant();
    LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(p);
    Location loc = new Location(p.getWorld(), e.getBlock().getLocation().getBlockX(), e.getBlock().getLocation().getBlockY(), e.getBlock().getLocation().getBlockZ());
    RegionContainer container = WorldGuardPlugin.inst().getRegionContainer();
    RegionQuery query = container.createQuery();
    if (!query.testState(loc, localPlayer, DefaultFlag.BLOCK_BREAK) && !p.hasPermission("Storage.admin")) {
        e.setCancelled(true);
        return;
    }
    e.getBlock().getDrops().clear();
    if (nms.isVersion(12)) {
        e.setDropItems(false);
    }
    List<String> w = getconfigfile().getStringList("Blacklist-World");
    if (!w.contains(p.getWorld().getName())) {
        if (autoPick(p)) {
            for (String getBlockType : Objects.requireNonNull(getconfigfile().getConfigurationSection("Blocks.")).getKeys(false)) {
                if (blocks.equalsIgnoreCase(getBlockType)) {
                    items = getconfigfile().getString("Blocks." + blocks + ".Name");
                    break;
                }
            }
            if (items == null) {
                return;
            }
            if (getMaxStorage(p, blocks) == 0) {
                setMaxStorage(p, blocks, getconfigfile().getInt("Default_Max_Storage"));
            }
            if (p.getItemInHand() != null && p.getItemInHand().getItemMeta().hasEnchant(Enchantment.LOOT_BONUS_BLOCKS)) {
                if (getRandomInt(getconfigfile().getInt("Fortune.Chance.System.Min"), getconfigfile().getInt("Fortune.Chance.System.Max")) <= (p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) * getconfigfile().getInt("Fortune.Chance.Player"))) {
                    int fortune = getRandomInt(getconfigfile().getInt("Fortune.Drop.Min"), getconfigfile().getInt("Fortune.Drop.Max"));
                    addStorage(p, blocks, 1 + fortune);
                } else {
                    addStorage(p, blocks, 1);
                }
            } else {
                addStorage(p, blocks, 1);
            }
        }
    }
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) Player(org.bukkit.entity.Player) RegionContainer(com.sk89q.worldguard.bukkit.RegionContainer) LocalPlayer(com.sk89q.worldguard.LocalPlayer) RegionQuery(com.sk89q.worldguard.bukkit.RegionQuery) NMSAssistant(preponderous.ponder.minecraft.bukkit.nms.NMSAssistant) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

NMSAssistant (preponderous.ponder.minecraft.bukkit.nms.NMSAssistant)5 LocalPlayer (com.sk89q.worldguard.LocalPlayer)1 RegionContainer (com.sk89q.worldguard.bukkit.RegionContainer)1 RegionQuery (com.sk89q.worldguard.bukkit.RegionQuery)1 Location (org.bukkit.Location)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1