#help-development

1 messages ¡ Page 2015 of 1

sterile token
#

I looks retarded

#

😕

ivory sleet
#

well okay let me ask you, what are you going to do with the data?

sterile token
#

And when plugin enable load each class object data, with each mongo object data

ivory sleet
#

oh okay

sterile token
#

Understand?

ivory sleet
#

so you have a data model in code which you want to represent the data from mongo?

#

I mean that makes things easier

sterile token
#

Yeah

young knoll
#

Mongo let’s you just directly serialize and deserialize POJOs

sterile token
#

Hmn?

#

Please dont confuse more me

#

Im already really confuse

#

Conclure this my class object

ivory sleet
#

serialize:
Taking your "class object data", transforming it into json

deserialize:
taking the json, transforming it into "class object data"

crimson terrace
#

How would one have language options for their plugin? would an enum be the proper way of doing it with the selection for languages being in the config?

ivory sleet
#

ResourceBundles is probably the best way

waxen plinth
#

lomb🤢k

crimson terrace
#

I'll look into it

sterile token
ivory sleet
#

no to Shreb

sterile token
#

Oh

#

What abotu me? :D

ivory sleet
#

whats node?

sterile token
#

Node is another object class

quaint mantle
tardy delta
#

exposing a list grr

ivory sleet
#

wat

sterile token
# ivory sleet whats node?

Im saivng to mongo:

List<Rank> ranks = new ArrayList<>();

void save() {
  this.ranks.foreach(rank -> Mongo#update("ranks", new Document().append("name", rank.getName()).append("nodes", rank.getNodes())));
}
#

But i dont know how read each object from mongo

ivory sleet
#

may I ask what library you use

sterile token
ivory sleet
#

alright

sterile token
#

So what i can do?

#

Im too much confused

#

I dont wanna skidd from a plugin the mongo part

#

I will prob search on github mongo examples

ivory sleet
#

well

#

in principle MongoDatabase::getCollection

sterile token
ivory sleet
#

then just ::find (which gives you a cursor)

sterile token
#

I jsut send in that way to short the code

#

I already done, i just dont know how to loop through each document object

#

MongoDatabase#getCollection("ranks")#find();

#

And there i mstuck

ivory sleet
#

okay so I looked it up, havent done mongo in some time

sterile token
#

Allright no problem

ivory sleet
#

but supposedly you should iterate over find

sterile token
#

Hmn

ivory sleet
#

so like

vale ember
#

is 1.18.2 the same 1_18_R1 nms or not?

kindred valley
#

hey

#
public class HealMe implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        Player p = (Player)commandSender;
        if(p.getHealth() <= 0.5F) {
            if(command.getName().equalsIgnoreCase("healme")){
                Bukkit.dispatchCommand(p, "givemoney hastane 2000");
                Location hastane = new Location(p.getWorld(), 192, 4, 799);
                p.teleport(hastane);
                p.setHealth(20F);
                p.setWalkSpeed(0.2F);
                p.sendTitle("Iyilestin", "Durumun Iyi");
            }
        }
        return true;
    }
}```
kindred valley
#

i can control the situation player does not have money

ivory sleet
#
try (MongoCursor<Document> cursor = find(new Document()).iterator()) {
  while (cursor.hasNext()) {
    Document document = cursor.next();
  }
}
```@sterile token
#

maybe

kindred valley
#

how can i

#

im using The New Economy

hybrid spoke
#

by using the api of the economy plugin

sonic phoenix
#

Hello, i'm trying to disable craft with custom items but it doesn't work, can someone explain me why ?

@EventHandler
public void craftItem(CraftItemEvent event) {
    System.out.println("Testing craft item event");
    CraftingInventory inv = event.getInventory();
    for(ItemStack stack : inv.getStorageContents()) {
        System.out.println(stack.getItemMeta().getDisplayName());
        if(CustomPaper.contains(stack)) {
            event.setCancelled(true);
        }
    }
}```
chrome beacon
#

Does it print

sonic phoenix
#

nope

#

And CustomPaper is the list who contain the items

chrome beacon
#

Did you register the listener

sonic phoenix
#

Yup

#

just here

#
getServer().getPluginManager().registerEvents(new CraftSecure(), this);```
quaint mantle
#

How would I make a falling chest spawn randomly in the sky near me

zenith spire
#

Is it possible to make any Item edible? In my case diamonds

molten hearth
#

wait, by on the server, do you mean on every server where the message is being received or just on the bungee server

sterile token
molten hearth
#

alright ty

sterile token
#

So if you wanna receive messages on Lobby at least one player should be online

jovial sparrow
#

I am making a plugin that applies potion effects to players who are wearing armor, is it more efficient (server resources efficient, not time efficient) to check the armor of every player on the server every X amount of time or to use Listeners on all relevant events and check if the player has equipped the armor?

tardy delta
#

listeners

sterile token
#

For checking player related things use listeners

#

Because they will be called once the player do something

#

And no everytime

devout canyon
#

how do I prevent ClassNotFoundException from happening between maven modules when dependencies look correct and I have the shade plugin included?

gusty gorge
#

Can I set custom colors as a bossbar color (such as gold) in the createBossBar method, if so how?

chrome beacon
sterile token
devout canyon
#

I think I'm just confused on how shade works, I'll look into that more

sterile token
#

Why doesnt work lmao

devout canyon
#

I have 4 poms, idk if I can fit them in one

#

?paste

undone axleBOT
jovial sparrow
# sterile token And no everytime

In this case, I would have to put listeners on InventoryClickEvent, PlayerInteractEvent, and DispenserArmorEvent wouldn't this result in me running code more often than just running a check on all players every 5-15 seconds?

devout canyon
#

I was looking up how to do versioned plugins and many people suggested to follow the example of AnvilGUI, and it has worked up until actually running the server in which case the exception happens

tardy delta
#

how would i call a method that removes an user after some time?

#

scheduleUserRemoval?

sterile token
#

He?

devout canyon
grim ice
#

btw

#

how to make an api of a plugin

zenith spire
#

Is it possible to make any Item consumable? In my case diamonds

crimson terrace
#

you just have to check the PlayerInteractEvent for the item, in your case a diamond, then upon right click or whatever you reduce the amount in the ItemStack by one.

tardy delta
#

after some time?

devout canyon
#

I don't think you can detect a player holding down a mouse button sadly

crimson terrace
#

np

crimson terrace
# zenith spire Thanks helps me a lot

you can enhance this by only making special diamonds consumable or things like that by checking the PDC for a special key or something you set at another time.

chrome beacon
#

?pdc

kindred valley
#
public BigDecimal getHoldings(String identifier, String world) {
    return TNE.manager().getAccount(IDFinder.getID(identifier)).getHoldings(WorldFinder.getWorldName(world, WorldVariant.BALANCE));
  }``` i dont know how to really use this
sacred mountain
#

hey im having trouble preserving comments in my file, how do i keep them when i set values

#

it keeps the first comment but not the rest

tardy flame
#

This looks cringe

#
        lore.forEach(s -> {
            var ref = new Object() {
                String toAdd = s;
            };
            String[] strings = s.split(" ");
            Arrays.stream(strings).forEach(s1 -> {
                if (s1.startsWith("%") && s1.endsWith("%")) {
                    s1 = s1.replace("%", "");
                    int number = Integer.parseInt(s1.replaceAll("[A-z]", ""));
                    Pet pet = pets.get(number - 1);
                    switch (s1.substring(1)) {
                        case "_player_name" -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_name%", OpUtils.getNameFromUUID(pet.getOwnerUUID()));
                        case "_player_object" -> {
                            switch (leaderboard.getType()) {
                                case TOP_LEVEL -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_object%", String.valueOf(pet.getLevel()));
                                case TOP_PRESTIGE -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_object%", new PrestigeManager().getFilledPrestige(pet.getPrestige()));
                                case TOP_EXPERIENCE -> ref.toAdd = ref.toAdd.replace("%" + number + "_player_object%", String.valueOf(pet.getPetExperience()));
                                default -> throw new IllegalStateException("Unexpected value: " + leaderboard.getType());
                            }
                        }
                        default -> throw new IllegalStateException("Unexpected value: " + s1);
                    }
                }
            });
            list.add(FormatUtils.formatMessage(ref.toAdd));
        });
#

Any way to clear it up?

sacred mountain
young knoll
#

Ah

kindred valley
#

what the fuck is bigdecimal

young knoll
#

Spigot doesn’t support comments on 1.8

tardy flame
young knoll
#

What

tardy flame
#

comments are based on spigot?

young knoll
#

What

zenith spire
#

I'm trying to increase a players potioneffect but it stops when i run this line:
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 999999, player.getPotionEffect(PotionEffectType.REGENERATION).getAmplifier() + 1));
Am i doing something wrong?

sterile token
sacred mountain
#

usage?

young knoll
#

That looks to only be for copying the file out of the jar

#

Which should preserve comments anyway

sacred mountain
zenith spire
# sacred mountain usage?

I use it in PlayerInteractEvent. broadcastmessage before this line works the one after it doesn't get excecuted

young knoll
#

You’ll have to search for a third party library

chrome beacon
young knoll
#

Spigot 1.8 did not preserve comments in yaml

#

Except for the header

sacred mountain
#

thats fine but

#

my other files do

#

preserve

grim ice
sacred mountain
#

using my merger

tardy flame
#

i probably could just do a final temp s

#

which could look better-

grim ice
#

okay i guess start by removing obfuscation

#

ur variable names suck

tardy flame
#

i know

#

at least here

#

:boohoo:

simple anvil
#

what is the best event to use to get the item in the main hand?

crimson terrace
#

anything that involves a player

tardy flame
#
        lore.forEach(lambdaString -> {
            final String[] finalString = new String[1];
            String[] strings = lambdaString.split(" ");
            Arrays.stream(strings).forEach(eachString -> {
                if (!eachString.startsWith("%") && !eachString.endsWith("%")) {
                    return;
                }
                String replaced = eachString.replace("%", "");
                int number = Integer.parseInt(eachString.replaceAll("[A-z]", "")) - 1;
                Pet pet = pets.get(number);

                switch (replaced.substring(2)) {
                    case "player_name" -> finalString[0] = finalString[0].replace("%" + number + "_player_name%", OpUtils.getNameFromUUID(pet.getOwnerUUID()));
                    case "player_object" -> {
                        switch (leaderboard.getType()) {
                            case TOP_LEVEL -> finalString[0] = getObject(finalString[0], number, String.valueOf(pet.getLevel()));
                            case TOP_PRESTIGE -> finalString[0] = getObject(finalString[0], number, new PrestigeManager().getFilledPrestige(pet.getPrestige()));
                            case TOP_EXPERIENCE -> finalString[0] = getObject(finalString[0], number, String.valueOf(pet.getPetExperience()));
                            default -> throw new IllegalStateException("Unexpected value: " + leaderboard.getType());
                        }
                    }
                    default -> throw new IllegalStateException("Unexpected value: " + replaced);
                }

            });
            list.add(FormatUtils.formatMessage(finalString[0]));
        });

@grim ice better?

simple anvil
#

AllOfThemEvent?

crimson terrace
#

basically

tardy flame
simple anvil
#

ok thanks

crimson terrace
#

you can always get a players equipment, which includes the main hand item

grim ice
#

ye

zenith spire
#

How can i check if a player has an effect? My current try was (player.getPotionEffect(PotionEffectType.REGENERATION) != null)

sterile token
#

Anyone have connected to Mongo atlas cloud, throw the mongo-driver-java because its telling me that the host is invalid

ebon stratus
#

hi, i tried using the mojang mappings and my server keeps telling me java.lang.ClassNotFoundException for every import, any fix?

young knoll
#

hasEffect iirc

#

Did you remap

simple anvil
young knoll
#

Check the 1.17/1.18 release posts for details

tardy flame
sterile token
simple anvil
#
public void CompassClick(PlayerInteractEvent e){
        Player p = e.getPlayer();
        if (p.getInventory().getItemInMainHand().getType().equals(Material.COMPASS)){
            p.sendMessage("hi");
        }
    }
#

its not saying hi

crimson terrace
ebon stratus
midnight shore
#

How can I crewte a custom event? That can be listened and cancelled

vocal cloud
#

By googling and selecting the first thing that shows up

sterile token
#

Oh nice

#

I hate atlas cloud

vocal cloud
sterile token
#

Its giving the ip address of the database, but them its saying its not valid

#

Its so amazing

#

hahaha

wet breach
young knoll
# ebon stratus ?

I told you to check the 1.18 release post for info on how to remap

kindred valley
#

how to access uuid.toString

quaint mantle
#

How would I make player data, which has economy in it ands saves?

#

I dont wanna use fault or anything to do that, cant find any tutorials on how to do it

midnight shore
quaint mantle
#

Without vault or any of that]

midnight shore
sterile token
young knoll
#

First comment

quaint mantle
#

Just a value that players have

#

To view money

gusty gorge
quaint mantle
gusty gorge
#

Or a hash map

vocal cloud
#

Use a database. YanSigh

sterile token
quaint mantle
sterile token
#

And if dont use database is shity, because you cannot use it in cross server

gusty gorge
vocal cloud
wet breach
# midnight shore Ty
GitHub

Bukkit Plugin for in-game player tutorials. Contribute to frostalf/ServerTutorial development by creating an account on GitHub.

GitHub

Bukkit Plugin for in-game player tutorials. Contribute to frostalf/ServerTutorial development by creating an account on GitHub.

quaint mantle
#

Oh

sterile token
#

Frost do you have experience with mongo driver?

wet breach
#

First link is the custom event, the second one is how to use it

#

its not all that difficult 🙂

sterile token
#

😡

midnight shore
zenith spire
wet breach
sterile token
gusty gorge
#

Can some1 tell me why the progress of the bossbar stays empty while setting it with setProgress(intWithMax100 / 100)

sterile token
crimson terrace
sterile token
#

So either im dumb or host is dumb

wet breach
#

also quite possible you need to specify the port too

sterile token
#

mongodb://<username>:<password>@mongodb.aa6vu.mongodb.net:27017/database/?retryWrites=true&w=majority

worldly quest
#

is there any way with prepareitemcraftevent to chjeck if event.getrecipe is a vanilla recipe

sterile token
#

Im really annoyyed

sterile token
#

Find the event and read the methods it has. And you will find what you want

worldly quest
#

theres nothing to compare it to a vanilla recipe on the docs

young knoll
#

Cast the recipe to keyed and get the key

#

The key will be “minecraft:xyz” for vanilla stuff

worldly quest
#

that helps tysm

sterile token
#

Idk that domain is what its giving me the atlas cloud

simple anvil
#
public void CompassClick(PlayerInteractEvent e){
        Player p = e.getPlayer();
        if (p.getItemInUse().equals(Material.COMPASS)){
            p.sendMessage("hi");
        }
    }

ava.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.equals(Object)" because the return value of "org.bukkit.entity.Player.getItemInUse()" is null

young knoll
#

I mean

#

It tells you

wet breach
simple anvil
#

yea but im holding a compass

young knoll
#

getItemInUse is for bows and stuff

#

Use event.getItem

sterile token
#

That its what attlas say me

wet breach
sterile token
#

What i can do?

wet breach
#

setup your own mongodb?

maiden briar
#

Guys I am stuck: I want to create an algorythm pushing forward a string value in a stringlist
marge: a, list: [test1, test2, test3] should become list: [atest, 1tes, t2te, st3]

sterile token
wet breach
#

then contact them and tell them

#

I can't do anything about a provider's service if they are down

sterile token
#

I will contact them

#

Thanks

fluid nacelle
#

Could I get your opinions?

I'm enabling players to set traps where if players walk over these traps, they are stuck in place for 5 seconds (I'll just set their walk speed to 0 for 5 seconds). To detect when these traps are used, I'm thinking of having it set a pressure plate server-side, then send packets to players to make it look like there's nothing there and listen for RedstoneBlockEvent or whatever you call it and make sure the source is a pressure plate then make sure the location matches and if so, find the nearest player (nearbyEntities of 1 or 2 radius?) or the other two alternatives are to make a runnable that runs every 0.5 seconds or so that listens for all trap locations for entities within the radius of 1 or 2 (whatever triggers it), or using PlayerMoveEvent

Which do you think would be most efficient out of those 3 methods?

simple anvil
#
 Player p = e.getPlayer();
        if (e.getItem().getType().equals(Material.COMPASS)){
            p.sendMessage("Hi");
        }else if(e.getItem() == null){
            return;
        }

still getting the error when not item in hand

grim ice
#

ibruh

sterile token
fluid nacelle
#

If e.getItem() is null then using getType() on it will give you a NPE

grim ice
#

ur doing that check before the second one

wet breach
grim ice
#

lmao

wet breach
#

you should check for null first

#

not last

grim ice
#

java doesnt read line 2 before line 1 lol

fluid nacelle
#

Or just
if(e.getItem() != null && e.getItem().getType().equals(Material.COMPASS()){} xD

simple anvil
#

just testing u

wet breach
#

you could just skip that and go based on location

fluid nacelle
hybrid spoke
#

you wont need that pressure plate if nobody is supposed to see it

wet breach
#

you can activate redstone without the pressure plate

hybrid spoke
#

he means he wanna use the event when someone steps on the plate

#

not to activate something

wet breach
#

setting the power on the block should do the same

grim ice
#

imagine stepping on people plates

#

rude

wet breach
#

but, I mean you could remove all that if its location based anyways

#

once the location matches where a trap is recorded to be, then do something

#

don't need the redstone even to do that

#

also don't need fake items

#

so doing all those things just adds unnecessary steps and complexity

#

if you want them to hear a sound, you can send a sound to the client to play based on the location as well

fluid nacelle
#

Let's say there's 50+ players online and there's 5 traps set somewhere in some game where the game has 16 or so people and the traps only apply to 9 of them as a scenario, I could use a runnable and check for nearby entities for those traps that meet the criteria, or I could use a player move listener that checks if they're in the same world then compares location distance as well as checking the criteria to make sure it applies to them, alternatively there's the redstone event I mentioned.

wet breach
#

if the traps are in a specific world, then make a list of the players that could only be possible

hybrid spoke
#

to get back to the topic: i would probably go location based with a timer. PlayerMoveEvent is too frequently called for just location-checking/player and spamming the players with packets seems exaggerated and redundant

wet breach
#

then in the move listener, if they are not those players in that world ignore them anyways

#

you don't need the redstone event for this, playermoveevent is sufficient

devout canyon
#

I got shade mostly working, and the log says that's including the other jars into the shaded jar, but when I open the jar file it only has the resource folder and pom 😐

fluid nacelle
wet breach
fluid nacelle
lost matrix
#

I would opt for how regions are grouped in worldguard.
Create chunk buckets and BoundingBoxes. Then the PlayerMoveEvent will have only a tiny overhead even with a ton of players online.

lean gull
#

hi am back, does anyone have a good tutorial on multiple config files? preferably ones that explains the code and what each line does

wet breach
hybrid spoke
fluid nacelle
young knoll
#

No one said you had to

lost matrix
#

So basically like this but instead of having an IntSet you have a List<BoundingBox>
So you only check the chunk the player is currently in. Then its still O(n) for all boxes mapped to this chunk but
extremely fast on the global scale

wet breach
# hybrid spoke in this case there is a better option which should be preferred. why would you s...

because checking numbers isn't inefficient if you setup the checks right. First check is if the player is valid, not hard to setup the list of players valid for a given world, second you just check if the player that moved, is in the same location as a trap. Not hard to setup a map where the key is the location. How many times it runs isn't going to make a difference until it actually does something.

lost matrix
#

And if you want to really squeeze out every last bit of performance you wouldnt use the PlayerMoveEvent but
use an evenly distributed runnable where every player gets checked every 20 ticks. So not all players at once
but each individual player has a delta of 20 ticks between each check

#

So instead of 100 players every 20 ticks you check 5 player every tick

wet breach
grim ice
wet breach
#

Either way, you don't need to get super complex with this. Keeping it simple is the better way to go lol. 7smile7's way isn't super complex even for the distributed runnable

lost matrix
#

Yeah probably overkill. The method mentioned above had < 0.1% tick time on the PlayerMoveEvent with 70 concurrent players online and several hundred boxes on a world.

fluid nacelle
#

If there's multiple games running at once, it's not just a single world lol, anyway I'm just going to check every 0.5 seconds or so, maybe more/less frequently pending testing as well as once a trap is activated, check if any remain and if not, stop checking, continues when at least 1 other trap is placed down

hybrid spoke
#

petition for smile to make a performance resource

#

if there isnt already one

grim ice
#

like how to optimize?

#

if so he did

wet breach
#

there is many ways to optimize stuff

hybrid spoke
#

there is always a way to optimize stuff

grim ice
#

maybe thats what u mean

wet breach
#

however, most of the time you don't need the extreme optimizations unless you hit that point that is all you have left to do to improve performance on your server

#

that is, most people don't have large enough servers to warrant such extremes

grim ice
#

i always do the maximum i can do

#

except for realllllllllly small projects

patent horizon
#

can anyone link me to a resource for editing players names in tablist? all im finding is forum posts of broken code

grim ice
#

do u wanna prefix it or change it

simple anvil
#
if (!(sender instanceof Player)){
            sender.sendMessage("Only players can use this command");
            return true;
        }

        if (command.getName().equalsIgnoreCase("ci")){
            SelectionScreen gui = new SelectionScreen();
            p.openInventory(gui.getInventory());
            p.sendMessage(ChatColor.AQUA + "please make a selection");
        }

should the bottom if statment be in the top else statment?

lost matrix
#

Yes 99% of servers shouldnt need to optimize much. People sometimes underestimate how powerful modern
CPUs are. As long as you prevent crucial mistakes like IO on the main thread you should be fine.

patent horizon
devout canyon
grim ice
grim ice
patent horizon
#

Note that this name will not be displayed in game, only in chat and places defined by plugins.

wet breach
grim ice
#

3*

simple anvil
#

so

#
if (!(sender instanceof Player)){
            sender.sendMessage("Only players can use this command");
            return true;
        }else 
(command.getName().equalsIgnoreCase("ci")){
            SelectionScreen gui = new SelectionScreen();
            p.openInventory(gui.getInventory());
            p.sendMessage(ChatColor.AQUA + "please make a selection");
        }
#

like this?

grim ice
#

tbf im happy i can be in coding servers, since without them my ego would skyrocket

#

since in my country i'm basically a genius

#

having a source to lower ur ego is pretty useful

#

being in a country that isnt 3rd world and is outside of africa is way more useful tho

#

oops this should be in general

simple anvil
#
if (command.getName().equalsIgnoreCase("ci")){
            SelectionScreen gui = new SelectionScreen();
            p.openInventory(gui.getInventory());
            p.sendMessage(ChatColor.AQUA + "please make a selection");
        }

        return true;
    }

why do i need to do getcommand.get name?
wont the main class do that?

quaint mantle
#
String pString = "players." + p.getUniqueId().toString();
            FileConfiguration conf = EmeraldsPlugin.data.getConfig();
            if(!conf.contains(pString)){
                conf.set(pString + ".balance", 0);
                EmeraldsPlugin.data.saveConfig();
            }

            int bal = conf.getInt(pString + ".balance");
            p.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Your Balance: " + ChatColor.RESET + ChatColor.GREEN + bal + " Coins");

Why when I run my command, it just says /balance and nothing else?

#

Is my code here wrong?

grim ice
#

static abuser!

quaint mantle
#
package me.emerald.emeraldsplugin.data;

import me.emerald.emeraldsplugin.EmeraldsPlugin;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;

public class UserData {
    private EmeraldsPlugin plugin;
    private FileConfiguration dataConfig = null;
    private File configFile = null;

    public UserData(EmeraldsPlugin plugin){
        this.plugin = plugin;
        saveDefaultConfig();
    }

    public void reloadConfig(){
        if(this.configFile == null)
            this.configFile = new File(this.plugin.getDataFolder(), "data.yml");

        this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
        InputStream defaultStream = this.plugin.getResource("data.yml");
        if(defaultStream != null){
            YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
            this.dataConfig.setDefaults(defaultConfig);
        }
    }

    public FileConfiguration getConfig() {
        if(this.dataConfig == null)
            reloadConfig();

        return this.dataConfig;
    }

    public void saveConfig(){
        if(this.dataConfig == null || this.configFile == null)
            return;

        try {
            this.getConfig().save(this.configFile);
        } catch (IOException e) {
            plugin.getLogger().log(Level.SEVERE, "Could not save config to " + this.configFile, e);
        }
    }

    public void saveDefaultConfig() {
        if(this.configFile == null)
            this.configFile = new File(this.plugin.getDataFolder(), "data.yml");

        if(!this.configFile.exists()){
            this.plugin.saveResource("data.yml", false);
        }
    }
}
#

Conf code

quaint mantle
grim ice
#

java isnt a scripting langauge lol

quaint mantle
#

well not a function

quaint mantle
grim ice
#

thats not how to use it

quaint mantle
#

*in this code

#

DAMN

#

no statics are used

ancient jackal
#

script

quaint mantle
#

dont abuse it

grim ice
#

FileConfiguration conf = EmeraldsPlugin.data.getConfig();

quaint mantle
#

but anyways, is something wrong?

grim ice
#

EmeraldsPlugin

#

.data

#

that is static

quaint mantle
#

public static UserData data;

#

only this

grim ice
#

ok

quaint mantle
#

data = new UserData(this);

grim ice
#

?learnjava

undone axleBOT
quaint mantle
#

@grim ice fine ill use
new EmeraldsPlugin()

#

new EmeraldsPlugin().data

grim ice
#

is ur emerald plugin ur main

quaint mantle
#

yep

grim ice
#

then learn spigot

#

and java

quaint mantle
#

wh why

young knoll
#

Can’t make an instance of your main class

grim ice
#

IllegalArgumentException: Plugin Already Initialized!

#

t he only one allowed to make an instance of ur main is bukkit

#

?di

undone axleBOT
grim ice
#

and ?learnjava

tardy flame
#

pls

young knoll
#

You killed the bot

grim ice
#

and never do public static

quaint mantle
#

okay then ill just use static

#

A

#

fine private static\

sterile token
grim ice
#

u should learn java btw

#

jk no one will learn java if they were told to

sterile token
grim ice
#

not even u learnt java when they told u to tho so ig

quaint mantle
#

i legit watched tutorials yesterday

#

on java

grim ice
#

(i assumed)

grim ice
#

more

quaint mantle
#
java.lang.IllegalArgumentException: The embedded resource 'data.yml' cannot be found in plugins/EmeraldsPlugin-1.0.0.jar
#

found the error

sterile token
#

Please learn java

#

Its really annoying to be all time asking and asking

quaint mantle
sterile token
#

If you atleast know java you wont be asking for that type of error

quaint mantle
#

what did I generate the file incorrectly?
this.configFile = new File(this.plugin.getDataFolder(), "data.yml");

sterile token
#

That literally say what happening

quaint mantle
#

You got data.yml in resource folder /generated right?

quaint mantle
#

maybe im missing smth

torn badge
#

PlayerBucketEmptyEvent

lost matrix
#

Because its not placing a Block. This can be detected with other events.

#

Well then update to a supported version

wet breach
#

all you are doing with that is creating a new File() object

#

not necessarily creating the file itself

torn badge
#

It should though

tacit drift
#

PlayerInteractEvent

lost matrix
#

Search in old forum posts. You might find something. But 1.8 is an ancient version and support
was dropped years ago. Just update. Only a minority still plays that version anyways.

river oracle
#

Ahhh there are always people who just need to support 1.8 if the server supports the old combat I don't mind. And it's not like the old combat is objectively better anyways ahaha

torn badge
#

Yeah I was pretty sure about that

patent horizon
#

So I'm using luckperms as my permissions plugin, and I want to check that a player isn't assigned to any group. When looking at the luckperms developer api, it looks like they just use the player.hasPermission("group.<group>") to find someone's group. how can i do the opposite, and see if a player isn't in any group?

sullen marlin
#

there would be an API to get a list of groups

#

then just call .isEmpty

patent horizon
#

.isEmpty for what?

lost matrix
sullen marlin
#

User user = luckPerms.getUserManager().loadUser(who);

#

Collection<Group> inheritedGroups = user.getInheritedGroups(user.getQueryOptions()).isEmpty()

#

or something

#

idkj Im just copy pasting the wiki

patent horizon
#

oh

#

thought u meant get all the groups in the server notlikethis

rotund pond
#

Hello !
I have a little question java side:
The methiod Bukkit#getOnlinePlayers return a "Collection<? extends Player>"

How can a class (?) extends Player even tho Player is an interface, and not an object ?
To me, it should be "Collection<? implements Player>" but it's not x)

sullen marlin
#

I dont think implements is a java keyword in that context

#

extends means the same thing

lost matrix
#

^

sullen marlin
#

as for why the API returns that its because stupid

#

just treat it as Player

rotund pond
#

Well xD

#

Okay ty

lost matrix
#

I literally went through a library today and found this gem:

sullen marlin
#

love it

grim ice
#

Lol

frosty minnow
#

moss is dead, can somebody please help me figure out gradle? i just need to know how to import local dependency

sullen marlin
#

wtf is moss

#

do I even want to know

torn badge
#

RIP Moss, he was a good one

frosty minnow
frosty minnow
#

essx switched to fudging gradle and now i can't build it

#

and i really need to because i run a custom one

fossil lily
#

Where would I put this?

young knoll
#

Why is moss dead

frosty minnow
lost matrix
sullen marlin
#

what issue with gradle are you having specifically

quiet ice
#

Probably just another person that declares a channel dead after 10 seconds of being there

grim ice
sullen marlin
#

is mavenLocal() a repo

grim ice
#

Ur class name lol

sullen marlin
#

if so should just be able to add it like a maven depend/

frosty minnow
sullen marlin
#

otherwise idk, gradle sucks

frosty minnow
sullen marlin
#

like a maven system depend?

young knoll
#

Conclure comin in hot

ivory sleet
frosty minnow
quiet ice
dire salmon
#

md_5 is online

#

Pog

frosty minnow
quiet ice
quiet ice
#

If not impossible actually

frosty minnow
# quiet ice yep

nope:

Build file 'C:\Users\Leo\Desktop\Plugin Edits\3. Currents Edited\Essentials-2.x\build.gradle' line: 17

* What went wrong:
A problem occurred evaluating root project 'EssentialsXParent'.
> Could not find method compileOnly() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.```
quiet ice
#

Which is why I always use gradle if I have to depend on local jars

grim ice
#

Chat goin hot

quiet ice
#

Nvm, it's groovy

frosty minnow
rotund pond
lost matrix
quiet ice
young knoll
quiet ice
young knoll
#

Is it .gradle.kts or just .gradle

quiet ice
#

it's build.gradle

frosty minnow
grim ice
#

And you can pass in an implementation of that interface

quiet ice
#

Oh I think I have heard about this issue

grim ice
#

Anyways there is no ? implements so we usin ? extends

young knoll
quiet ice
#

I know

#

please wait a while I need to find how to do it correctly again

frosty minnow
quiet ice
#

there is

#

And make sure that this file actually exists

frosty minnow
#

it does, it's in the same folder as build.gradle, same folder i'm running the gradle command from

#

god damn it essentialsx

lean gull
#

so i managed to make my custom config file with a tutorial, and now i have another question: how can i use this custom config file for my "bot"? i wanna make it so i can just input an input and an output + custom expressions, for example:

input: [can you say] "%message%" [for] %player%
output: send message %message% for %player%

quiet ice
ivory sleet
frosty minnow
frosty minnow
quiet ice
#

What happens if you remove the ./?

torn badge
quiet ice
ivory sleet
#

no dont

frosty minnow
#

now it changed to this error instead:

A problem occurred evaluating root project 'EssentialsXParent'.
> Build was configured to prefer settings repositories over project repositories but repository 'flatDir' was added by build file 'build.gradle'```
quiet ice
ivory sleet
#

implementation assumes runtime classpath dependence

quiet ice
#

Show us your entire build.gradle

ivory sleet
#

which is probably not what you want

frosty minnow
#
    id("essentials.parent-build-logic")
}

group = "net.essentialsx"
version = "2.19.4-SNAPSHOT"

project.ext {
    GIT_COMMIT = !indraGit.isPresent() ? "unknown" : indraGit.commit().abbreviate(7).name()
    GIT_DEPTH = GitUtil.commitsSinceLastTag(project)
    GIT_BRANCH = GitUtil.headBranchName(project)

    FULL_VERSION = "${version}".replace("-SNAPSHOT", "-dev+${GIT_DEPTH}-${GIT_COMMIT}")
}

repositories {
  flatDir {
    dir '.'
  }
}

dependencies {
  compileOnly name: 'PlayerTracking.jar'
}```
quiet ice
#

what is the settings.gradle file?

ivory sleet
#

wait how is the project setup?

#

you might wanna add the repo and dep to your subprojects rather

frosty minnow
simple anvil
ivory sleet
#

can you link?

frosty minnow
quiet ice
#

oh

#

That gradle file isn't meant to be used I think

quiet ice
#

Yeah

ivory sleet
#

this is unorthodox

quiet ice
ivory sleet
#

both groovy and kotlin dsl

frosty minnow
quiet ice
#

It is basically the root maven pom

#

In maven speak

#

It however depends on what you are actually trying to do

frosty minnow
ivory sleet
#

yeah adding the flatfile jar to the subproject is much more reasonable

young knoll
frosty minnow
#
A problem occurred evaluating project ':EssentialsX'.
> Build was configured to prefer settings repositories over project repositories but repository 'flatDir' was added by build file 'Essentials\build.gradle'```
#

what the hell

quiet ice
#

Use my approach

frosty minnow
#

for fuck's sake is there something like a gradle2maven converter somewhere

quiet ice
#

Partially that is

ivory sleet
#

^

frosty minnow
ivory sleet
#

yeah

frosty minnow
#

wait what do i put in the blob

ivory sleet
#

flatDir {
dir(".")
}

(settings.gradle.kts)

frosty minnow
quiet ice
#

Just add the compileOnly files("file.jar") in Essentials/build.gradle

#

without anything else

#

That should work

patent horizon
#
    public void updatePlayerTablist(Player player) {
        UUID uuid = player.getUniqueId();
        PlayerData data = Main.getPlayerControl().getInstance(uuid);
        User user = Main.luckPerms.getPlayerAdapter(Player.class).getUser(player);
        String name = !user.getInheritedGroups(user.getQueryOptions()).isEmpty() ? utility.f("&f" + player.getName()) : utility.f("&7" + player.getName());
        String prefix = Main.luckPerms.getUserManager().getUser(uuid).getCachedData().getMetaData().getPrefix();
        String guild = !data.guild.equals("") ? utility.f("&8[&7" + data.guild + "&8]") : utility.f("&7");
        String bounty = data.bounty != 0 ? utility.f("&6&l$" + data.bounty) : utility.f("&7");
        player.setPlayerListName(prefix + name + " " + guild + " " + bounty);
    }```
frosty minnow
lean gull
#

you can't have components in tab, also ew plexpvp

patent horizon
#

youch

simple anvil
#

how do i respond to a command in the console?

young dome
#

Can we detect if an inventory is not a default inventory in spigot ? (so an inventory created on the client side with packets or else)

quiet ice
patent horizon
#

how do i color stuff in tab then

simple anvil
#

§

frosty minnow
quiet ice
#

just do my compileOnly files("file.jar") approach

#

Or edit the root settings.gradle.kts

lean gull
#

try ChatColor.translateAlternateColorCodes

frosty minnow
patent horizon
#

thats what im doing

#

utility.f() is a shortened function for it

lean gull
#

honestly ask someone else idk crap about java

#

also, ew, plexpvp :)

patent horizon
#

k then

quiet ice
lean gull
ivory sleet
#

Acc might be
compileOnly name: "File"

#

Without .jar

frosty minnow
# quiet ice is that in the dependencies block?

ok i still had the flat thing on it lol, i removed it and it seemed to make some progress, but it failed again with this:

Execution failed for task ':EssentialsX:compileJava'.
> Could not resolve all files for configuration ':EssentialsX:compileClasspath'.
   > Could not find :./PlayerTracking.jar:.
     Required by:
         project :EssentialsX```
ivory sleet
#

Remove .jar

simple anvil
#

how to i respond to the console?

frosty minnow
#

and yes it's in dependencies block

quiet ice
#

try ../PlayerTracking.jar

frosty minnow
# ivory sleet Remove .jar
Execution failed for task ':EssentialsX:compileJava'.
> Could not resolve all files for configuration ':EssentialsX:compileClasspath'.
   > Could not find :./PlayerTracking:.
     Required by:
         project :EssentialsX```
quiet ice
#

since you are no longer in teh root folder

#

I think so at least

frosty minnow
#

oh my god

#
Execution failed for task ':EssentialsX:compileJava'.
> Could not resolve all files for configuration ':EssentialsX:compileClasspath'.
   > Could not find :C:/Users/Leo/Desktop/Plugin Edits/3. Currents Edited/Essentials-2.x/PlayerTracking.jar:.
     Required by:
         project :EssentialsX
#

not even full fucking path works

#

what the fuck

#

why can't it find it

#

it's literally right there

quiet ice
#

Windows moment

ivory sleet
#

But like where is the jar located?

#

Root dir?

frosty minnow
frosty minnow
#

god damn it

lean gull
vocal cloud
#

Gotta verify

frosty minnow
#

PLEASE DONT GO ANYWHERE GUYS i have to upload this to imgur real quick

#

please stay

ivory sleet
#

Lol

quiet ice
patent horizon
ivory sleet
#

I and geol will be here, like I also wanna know how to do this and why it doesn’t work lol

lean gull
#

"clickEvent=null"

frosty minnow
#

that folder

quiet ice
#

It is probably EssX own build logic that interferres here

frosty minnow
#

grrrrrrrrr

quiet ice
frosty minnow
#

this is what i hate about both maven and gradle they're both too fucking complicated

ivory sleet
#

flatDir{
dir(rootProject.dir)
}
perhaps?

frosty minnow
ivory sleet
#

Yes

#

settings

quiet ice
#

the repository would need to be declared in the settings.gradle.kts file

#

around line 3

frosty minnow
# quiet ice the repository would need to be declared in the settings.gradle.kts file

this good?

        maven("https://hub.spigotmc.org/nexus/content/groups/public/")
        maven("https://papermc.io/repo/repository/maven-public/")
        maven("https://jitpack.io") {
            content { includeGroup("com.github.milkbowl") }
        }
        maven("https://repo.codemc.org/repository/maven-public") {
            content { includeGroup("org.bstats") }
        }
        maven("https://m2.dv8tion.net/releases/") {
            content { includeGroup("net.dv8tion") }
        }
        maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") {
            content { includeGroup("me.clip") }
        }
        maven("https://libraries.minecraft.net/") {
            content { includeGroup("com.mojang") }
        }
        mavenCentral {
            content { includeGroup("net.kyori") }
            content { includeGroup("org.apache.logging.log4j") }
        }
        flatDir {
            dir '.'
        }
    }```
quiet ice
#

However it is likely that it uses different syntax

ivory sleet
#

Yes

ivory sleet
frosty minnow
#

i haven't wanted to shoot myself in the head this much in a long time... this wasn't supposed to take all fucking saturday

fossil lily
frosty minnow
quiet ice
young dome
quiet ice
#

It always takes a while to figure out what to do with these projects

trail pilot
#

how i can make max homes?

frosty minnow
fossil lily
#

Oh

#

I see

quaint mantle
#

Hi everyone, I've got a question for yall.

So I've been trying to make custom islands that have their own world, but I ran into the issue of not enough memory.
My question now is, is there a way to limit as to how many chunks a world has/can load just like what hypixel does, and with limiting the world data size.
I searched the whole #WorldCreator but nothing that can help me there.

If anyone is able to help me, that'd be great.

frosty minnow
# ivory sleet Yes
Settings file 'C:\Users\Leo\Desktop\Plugin Edits\3. Currents Edited\Essentials-2.x\settings.gradle.kts' line: 25

* What went wrong:
Script compilation errors:

  Line 25:             dir(rootProject.dir)
                                       ^ Function invocation 'dir(...)' expected

  Line 25:             dir(rootProject.dir)
                                       ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
                                           public inline fun SourceSetOutput.dir(dir: Any, vararg options: Pair<String, Any?>): Unit defined in org.gradle.kotlin.dsl```
ivory sleet
#

dirs(rootProject.dir) maybe

frosty minnow
prime reef
#

so how exactly does creating an NPC work? in other words an entity that looks like a player but isn't

ivory sleet
#

Ah it’s such a mess, ain’t even home kinda potato

#

maybe you can toFile() it

#

Or sth x)

frosty minnow
#

toFile() it?

prime reef
#

trying to search for any information just keeps pulling up Citizens lmao

prime reef
#

should return a java File

quiet ice
#

nah

frosty minnow
prime reef
frosty minnow
prime reef
#

that's the problem

quiet ice
#

We are talking about how to do something in kotlin gradle

prime reef
#

I don't know shit about Kotlin, my bad

#

gradle I can use but kotlin...

frosty minnow
#

neither do i... maven used xml which is like older than my grandma

#

everyone knows fucking xml

prime reef
#

xml is nice because it's a very clear cut format

#

and can be used for anything

quiet ice
#

The alternative is that you manually upload it to mavenLocal and use that

prime reef
#

gradle decided it was going to make its own fucking syntax

frosty minnow
#

you can take 2 days at a high school html web design class and already understand god damn xml

quiet ice
#

you'd need to declare mavenLocal manually however

prime reef
#

it's just

quiet ice
#

but it should just be a mavenLocal()

prime reef
#

"Put this shit in brackets"

frosty minnow
quiet ice
#

XML is pretty standardised afaik

prime reef
#

you can parse any old angle bracket markup language with an XML parser because that's the point of xml

#

eXtensible Markup Language

#

i like it though

frosty minnow
prime reef
#

^

quiet ice
prime reef
#

I was gonna say "oh you just mvn install" but

#

gradle just

frosty minnow
#

ok how do i do that?

#

i do have maven installed

quiet ice
#

okay, copy upload was the wrong word

prime reef
#

not sure what you're trying to accomplish

trail pilot
quiet ice
#

@lost matrix So how do we install a file again?

prime reef
#

usually it helps to describe what you're trying to do in a general sense rather than asking about a very specific thing

#

and I say this because more often than not, I'll see a question in here that has me kind of confused because there's no reason for the person asking to be doing what they're trying to do

frosty minnow
#

@quiet ice thanks for your help but i'm gonna move on to updating the next plugin now, hopefully it won't be such a fucking nightmare

#

i can live with old essentials

prime reef
frosty minnow
#

i knew how to edit the code back when they used maven

#

but now i'm just shit outta luck

quiet ice
#

If it is simple work you might also be able to use Recaf ... that should certainly work just could be gruesome if you are no familiar with it

frosty minnow
#

i mean if it's a gradle plugin then i can only build it with gradle... i've tried making an intellij project from scratch with the .jar files (it took fucking hours to import everything into the correct folder structure) but that just didn't work

quiet ice
#

Plus you'd need to reapply the step over and over again every time you want to update EssX as there is not patch format for java bytecode

frosty minnow
#

.java* files

#

i meant

quiet ice
#

Recaf is a dedicated bytecode editing IDE

frosty minnow
quiet ice
#

Yes, overkill

ivory sleet
#

I am almost home, so can test it soon otherwise in case you still haven’t fiddled it out

frosty minnow
young dome
# prime reef inventory owner?

No, it's not really that, I want to know how spigot handles inventories that are not listed in spigot (the GUIs added with the client)

quiet ice
#

Also if it is really simple work you might just be able to use reflection or method handles and this stuff

#

Would save you from depending on an external jar directly

frosty minnow
trail pilot
frosty minnow
#

i don't even use maven/gradle for my plugins, just intellij and file folders

prime reef
#

because like

#

that's the thing i'm good at

#

lmao

prime reef
#

i've never dug too deep into packets/etc. as far as Spigot is concerned

#

you may be interested in ProtocolLib though, that's one of the few times I'd firmly recommend using a library

quiet ice
#

it depends on what you want to do. For example calling a static method is:

try {
   Method method = MyClass.class.getMethod("name", Parameter1Class.class, Parameter2Class.class);
   method.invoke(null, parameter1, parameter2);
} catch (Throwable t) {

}
fossil lily
#

Adding the repository didnt work :(

quiet ice
#

?paste I guess you could paste the entire pom.xml

undone axleBOT
fossil lily
quiet ice
fossil lily
#

hm

#

Oh

quiet ice
#

also the repository you added is superflous

fossil lily
#

After reloading it worked

quiet ice
#

Java IDE moment

fossil lily
#

Thanks

vestal barn
#

i have a map in a config file but it is just empty when i try to get anything from it
code
config.getMapList("classEmojis")
config

classEmojis:
  warriorEmoji: ⚔️
  archerEmoji: 🏹
  tankEmoji: 🛡️️
  wizardEmoji: 🪄
quiet ice
#

Wouldn't it be getMap?

young dome
vestal barn
#

there isnt a get map

quiet ice
#

getMapList would be a list of maps, but this is a map

#

?jd-s I do not believe that

undone axleBOT
vestal barn
#

Cannot resolve method 'getMap' in 'FileConfiguration'

quiet ice
#

actually yes, you are right

#

You can still get the keys via .getKeys however

#

it is named strangely, but it should be what you are searching for

ivory sleet
#

@frosty minnow okay Im cloning now

#

lol

frosty minnow
#

lemme get u the changed files

frosty minnow
#

no other file is changed

#

btw there's a chance for syntax errors since i just copypasted code from an older version of the same files, but i can deal with that after i get it to at least see the dependency

prime reef
#

and shit like this is why

#

or part of it, anyway

#

the other part being how verbose config reads are

quiet ice
#

spigots config API is at least miles better than snakeyaml

prime reef
#

that's true, but it's still kinda shit compared to jackson

#

snakeyaml is basically a fossil at this point

#

the one thing i do like about spigot's config api is that it's really damn easy to use

#

and pathing through a config file is simple

quiet ice
#

I prefer org.json:json but noone is going to use a json-based config so I do not use it in minecraft space

prime reef
#

i just wrote a library that reads yml/xml/json into a format-neutral config tree

chrome beacon
#

Night config is nice, been using it with Forge

prime reef
#

made my life 10x easier

frosty minnow
#

🤞 🤞 🤞 on conclure figuring it out

prime reef
#

combines the ease of spigot config with the not having to hardcode aspect of jackson

quiet ice
#

I've used sponge's configurate once, it is kinda nice though complicated to get started

frosty minnow
#

@ivory sleet by the way you're gonna have to run gradle like this: gradle build -x checkStyleMain

#

for some reason they think it's okay to treat styling choices as syntax errors without that option

ivory sleet
#

oo

frosty minnow
#

like spaces vs. tabs what the actual fudge

quiet ice
#

as I said, enterprise development

#

Mixing spaces with tabs may lead to issues

frosty minnow
#

certainly not in java

#

i should be able to fit an entire method in 1 line with no spacing at all if i wanted to lol and still can idk why it tries to styleblock me by default though that's just flat out rude

quiet ice
#

Certainly yes. Readability concerns are worth noting

quiet ice
#

And it should be noted that not all IDE installs are going to show 1 tab as 4 spaces for example. Some may opt in for 1 tab = 2 spaces and the extra exotic variant is 1 tab = 3 spaces. Some are like 2020 me and have it set at 1 tab = 16 spaces so they will instantly notice when there is a rouge tab.

prime reef
#

16 spaces
i felt pain

#

I use 4 in intelliJ and 2 in VS for C++

quiet ice
#

Nowadays I just have the "show whitespace characters" option on however

prime reef
#

not sure why

wet breach
quiet ice
#

There are too many variants to count with people being able to set them as they please

wet breach
#

I have my IDE set to convert tabs to spaces, and just like you have it show whitespace characters on all the time

#

its more handy when I work on some other project as opposed to my own projects for the white spacing characters

#

However though there is no standard for how many spaces for a tab

#

and this has to do with history and mechanical type writers where a tab was just a physical stop for the carriage return

quiet ice
#

I mean that is kinda what makes tab so great

lost matrix
frosty minnow
#

@ivory sleet any luck at all?

#

🙏 thank you lord, the other plugin i wanted to update is still on maven

#

thank you thank you thank you thank you

ivory sleet
#

okay

quiet ice
#

I wish you can pin messages for later.
Oh well

ivory sleet
#

@frosty minnow

#

flatDir {
dirs(rootProject.projectDir)
}

#

that

frosty minnow
ivory sleet
#

and then the compileOnly name: 'JarFileWithoutDotJar'

#

ye

#

lol

frosty minnow
#

let's try

frosty minnow
quaint mantle
#
new File("src/main/resources/data.yml");

Any reason why it isnt able to make the file VIA a plugin?

quiet ice
#

...

#

What exactly are you trying to do?

ivory sleet
quiet ice
#

It is likely that you are trying to do new File(getDataFolder(), "data.yml") - in that case, use that instead

quaint mantle
west oxide
#

hey everyone

quaint mantle
#

So I was hoping a direct path would help

quiet ice
#

Or if you are trying to use getResource("data.yml") use that instead

west oxide
#

can someone tell me how to import this ?
import com.mojang.authlib.GameProfile;

ivory sleet
#

looks like its imported already

quaint mantle
#

But, im trying to create the resouce first

quiet ice
#

Alternatively, saveResource

west oxide
#

when i do that

#

it shows error

quiet ice
#

Do you want to create an empty file in the plugin's directory or what?

frosty minnow
quaint mantle
#
String pString = "players." + p.getUniqueId().toString();
            FileConfiguration conf = EmeraldsPlugin.data.getConfig();
            if(!conf.contains(pString)){
                conf.set(pString + ".balance", 0);
                EmeraldsPlugin.data.saveConfig();
            }

            int bal = conf.getInt(pString + ".balance");
            p.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Your Balance: " + ChatColor.RESET + ChatColor.GREEN + bal + " Coins");
#

Part of my balance command

#
public static UserData data;
data = new UserData(this);
quiet ice
#

ah then you only need an empty file

frosty minnow
#

ahh yes lol they seem to have restructured their class... guess i'll have to do some coding after all

#

thank you @ivory sleet

quaint mantle
#

Named "data.yml"

quiet ice
#
File f = new File(getDataFolder(), "data.yml");
f.getParentFile().mkdirs();
f.createNewFile();

something like this

west oxide
quaint mantle
#

lettme try it rq

frosty minnow
#

@ivory sleet wait never mind it's still not working... actually i removed all of my changes and it still won't build

ivory sleet
#

what does it say

frosty minnow
#

nevermind... i just ran it a second time on a cleared screen and it built fine

#

now let's try with my edits

#

ahh ok yes lol it's just my code that's wrong @ivory sleet

ivory sleet
#

nice

frosty minnow
#

yes lol very 😄 thanks

quaint mantle
#

@quiet ice tysm

#

it works now

steel reef
#

how do i craft hearts????

marble rivet
#

how do i summon a horizontal firework that crossbows shoot?

gaunt moss
#

Hi, I have a problem. I use the variable ${project.name} in the plugin.yml but there is an error Schema validation: String violates the pattern: '^[A-Za-z0-9_\.-]+$

wet breach
#

there is still people that don't know how to craft hearts?

#

@tender shard

quaint mantle
#

Is creating a players data when joining for the first time efficient?

#
public void PlayerJoined(PlayerJoinEvent event){
        Player p = event.getPlayer();
        String pString = "players." + p.getUniqueId().toString();
        FileConfiguration conf = EmeraldsPlugin.data.getConfig();

        if(!conf.contains(pString))
            EmeraldsPlugin.data.createUserData(p);
    }
#

Like so

worldly ingot
#

I don't see why not. Pretty common to do that. If you're loading data from file or something though, be sure to do it asynchronously

arctic moth
worldly ingot
#

Not sure. You're on Purpur, a very far derivative of Spigot

#

Doing some weird fuckery in the damage event handling. I would forward that error to them instead

#

Preferably on their JIRA/GitHub issues/however they track bugs

ancient plank
#

?whereami

worldly ingot
#

lmao that's great

#

I've not seen that one before

frosty minnow
#

@ivory sleet @quiet ice @prime reef i have successfully built my essentials jar 🥳 if it weren't for you guys i'd still be in anxiety hell right now so thank you all very very much ❤️

ancient plank
quaint mantle
#

Is there a way to copy a world with all the exact blocks that it contains?

brave sparrow
gaunt moss
gaunt moss
#

Yep

brave sparrow
#

You just can’t use {}

eternal oxide
#

you have to set <filtering>true</filtering> in the build section of your pom so those entries get replaced with their real values before they are put in the jar

brave sparrow
#

Aha that’s a spigot error, gotcha

#

Thought they were getting a maven error

waxen plinth
brave sparrow
#

^

#

Gonna be the fastest way to do it

quaint mantle
#
String value = item.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(EmeraldsPlugin.jp, "coin"), PersistentDataType.STRING);

                if(value == "iron"){
                    FileConfiguration conf = EmeraldsPlugin.data.getConfig();
                    String pString = "players." + p.getUniqueId().toString();
                    conf.set(pString + ".balance", conf.getInt(pString + ".balance") + 1);
                    EmeraldsPlugin.data.saveConfig();
                    PluginFuncs.consumeItem(p, 1, item);
                    p.sendMessage(ChatColor.GREEN + "Added 1 coin to your balance.");
                }|
#

My code litterally crashed my server

#

Any idea why?

brave sparrow
#

First of all

#

You don’t compare strings with ==

quaint mantle
#

forgot .equals

earnest forum
#

.equals

#

or equalsignorecase

quaint mantle
night torrent
#

can the artifactID have capitals?

eternal oxide
brave sparrow
night torrent
#

thanks

quaint mantle
#

I think this is the log?

brave sparrow
#

I’m on mobile on an airplane

#

Use ?paste

quaint mantle
#

?paste

brave sparrow
#

Lol

undone axleBOT
quaint mantle
fossil lily
#

How would I change this so that instead of a string I had an integer?

brave sparrow
#

What is properties

fossil lily
tall dragon
#

show properties class

quaint mantle
#

Maybe the error was caused by different means.

fossil lily
brave sparrow
#

I only have the official Mojang repo on my phone

lost matrix
quaint mantle
# brave sparrow Can you look at the mappings and tell me what ItemStack#N is
Items ironCoin = Items.newItem("ironCoin", null);

        ItemStack itemD = new ItemStack(Material.IRON_NUGGET, 1);
        ItemMeta metaD = itemD.getItemMeta();
        metaD.setDisplayName(ChatColor.GRAY + "Iron Coin");
        NamespacedKey keyD = new NamespacedKey(EmeraldsPlugin.jp,"coin");
        metaD.getPersistentDataContainer().set(keyD, PersistentDataType.STRING, "iron");
        ArrayList<String> loreD = new ArrayList<>();
        loreD.add(ChatColor.GOLD + "An iron coin. Right click to gain 1 coin.");
        metaD.setLore(loreD);
        itemD.setItemMeta(metaD);
        ShapedRecipe recipeD = new ShapedRecipe(NamespacedKey.minecraft("ironcoin"), itemD);
        recipeD.shape(" I ","IBI"," I ");
        recipeD.setIngredient('I',Material.IRON_INGOT);
        recipeD.setIngredient('B',Material.IRON_BLOCK);

        ironCoin.setItem(itemD);
        ironCoin.setRecipe(recipeD);
#

Here is the item in question

brave sparrow
#

I don’t want your code

#

I want net.minecraft.world.item.ItemStack

#

That’s the method where the server crashes

#

I need to know what N is

quaint mantle
#

ItemStack item = event.getItem();

quaint mantle
#

Here possibly?

wet breach
#

they are most likely removing an item incorrectly somewhere

lost matrix
# fossil lily

Why did you decide to use the Properties class instead of just using spigots FileConfiguration?

quaint mantle
#

Thats the only ItemStack#N I can see

brave sparrow
#

And tell me what the obfuscated method N is

wet breach
brave sparrow
#

For net.minecraft.world.item.ItemStack

quaint mantle
lost matrix
quaint mantle
#

anywhere

wet breach
#

let me guess you are reducing the number in the itemstack?

brave sparrow
quaint mantle
#
public static void consumeItem(Player player, int count, ItemStack item) {
        Map<Integer, ? extends ItemStack> ammo = player.getInventory().all(item);

        int found = 0;
        for (ItemStack stack : ammo.values())
            found += stack.getAmount();
        if (count > found)
            return;

        for (Integer index : ammo.keySet()) {
            ItemStack stack = ammo.get(index);

            int removed = Math.min(count, stack.getAmount());
            count -= removed;

            if (stack.getAmount() == removed)
                player.getInventory().setItem(index, null);
            else
                stack.setAmount(stack.getAmount() - removed);

            if (count <= 0)
                break;
        }

        player.updateInventory();
    }
wet breach
#

you need to check if the itemstack only has 1 item, if they do, you need to set the item to air

#

instead of reducing it to 0

quaint mantle
#

May I ask why

lost matrix
quaint mantle
#

why would that crash a server lol

quaint mantle
#

Whats the method

wet breach
#

setting it to 0 is the same as setting it to null. This doesn't work because itemstacks are asserted to not be null

#

hence the assert error being TRAP

#

now everyone else learned what it means for assert to be TRAP 🙂

lost matrix
#

Example:

    /**
     * Removes 10 apples and returns an int that defines how
     * many apples couldnt be removed.
     */
    public int removeTenApples(Player player) {
        return player.getInventory().removeItem(new ItemStack(Material.APPLE, 10)).size();
    }
quaint mantle
#

Would you mind helping me with that ?

vocal cloud
#

Copy pasting a folder?

lost matrix
quaint mantle
brave sparrow
#

@wet breach I need to satisfy my curiosity now, would you be a doll and tell me what the actual name for the obfuscated method net.minecraft.world.item.ItemStack#N is

#

I can’t find a mapping on my phone

lost matrix
#

"would you be a doll"
I cant imagine that this is an actual saying...

brave sparrow
#

It is

wet breach
#

Its more common to hear in southern states

lost matrix
#

I believe i spider

brave sparrow
#

Wot

vocal cloud
#

Would you be a dear is usually what you hear

brave sparrow
wet breach
lost matrix
hexed hatch
quaint mantle
#

@brave sparrow #N is an iron nugger

#

nugget

#

im p sure

brave sparrow
brave sparrow
#

It’s ok, you don’t understand what I’m asking for

lost matrix
quaint mantle
#

you can remove

lost matrix
brave sparrow
#

Let me see if I can find a mapping somewhere in the git repo

wet breach
#

either use what 7smile7 said or use this

if (item.getAmount() == 1) {
    player.getInventory().setItemInMainHand(null);
} else {
    item.setAmount(item.getAmount() - 1);
}

better to use the API though like 7smile7 showed 🙂

brave sparrow
#

Nope, not in the repo

#

Darn it

lost matrix
#

Pretty sure setting the amount to 0 is now allowed and will remove the ItemStack

brave sparrow
#

Is anyone on PC and able to download the mapping?

wet breach
#

well I guess it depends which API method they were using

brave sparrow
lost matrix
brave sparrow
#

That’s why I asked if you could

#

Lmao