#help-development

1 messages · Page 1638 of 1

quaint mantle
#

how can I change the amount of experience for a player?

compact crane
quaint mantle
#

no

#

I don't need a level, but experience

torn oyster
#

Caused by: java.lang.ClassNotFoundException: net.maxicraft.capturetheclayplugin.minigame.EndReason

#

what

#

that class very well exists

#

it just decided for it not to exist

#

runtime

#

Caused by: java.util.zip.ZipException: ZipFile invalid LOC header (bad signature)

tepid parrot
waxen plinth
minor garnet
#
[09:23:04] [Server thread/WARN]:     at java.lang.Class.getDeclaredMethod(Unknown Source)
[09:23:04] [Server thread/WARN]:     at vinnydgf.deangroup.bukkit.listener.ReflectionUtil.getMethod(PlayerList.java:934)
[09:23:04] [Server thread/WARN]:     at vinnydgf.deangroup.bukkit.listener.ReflectionUtil.invokeMethod(PlayerList.java:804)
[09:23:04] [Server thread/WARN]:     at vinnydgf.deangroup.bukkit.listener.ReflectionUtil.invokeMethod(PlayerList.java:781)
[09:23:04] [Server thread/WARN]:     at vinnydgf.deangroup.bukkit.listener.PlayerList$1.callBack(PlayerList.java:513)
[09:23:04] [Server thread/WARN]:     at vinnydgf.deangroup.bukkit.listener.Skin$3$1.run(PlayerList.java:1129)
[09:23:04] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:64)

#
                @Override
                public void callBack(Skin skin, boolean successful, Exception exception) {
                    Object profile = GAMEPROFILECLASS.cast(ReflectionUtil.invokeMethod(data, "a", new Class[0]));
                    if (successful) {
                        try {
                            Object map = ReflectionUtil.invokeMethod(profile, "getProperties", new Class[0]);
                            if (skin.getBase64() != null && skin.getSignedBase64() != null) {
                                if (!ReflectionUtil.isVersionHigherThan(1, 13)) {
                                    ReflectionUtil.invokeMethod(map, "removeAll", new Class[] { String.class },
                                            "textures");
                                } else {
                                    ReflectionUtil.invokeMethod(map, "removeAll", new Class[] { Object.class },
                                            "textures");```
hard radish
#

How would I setup a gradle kotlin and Java project?

stone sinew
raven rampart
#

I need some help in tying the World to the namespaced key that Minecraft uses. I do not currently see a way to link them. World.getName() isn't it, the closest I could see is World.Environment.... which uses NORMAL, NETHER, THE_END. So... I tried to create an EnumMap to handle manually tying them together. It used to work flawlessly, and now that I've pulled it out into a separate plugin, I am getting null values:

public enum Dimension {
    OVERWORLD(World.Environment.NORMAL,"minecraft:overworld"),
    NETHER(World.Environment.NETHER,"minecraft:the_nether"),
    END(World.Environment.THE_END,"minecraft:the_end");
    
    private final String namespace;
    private final World.Environment environment;
    
    private static final Map<World.Environment, String> byEnvironment = new EnumMap<World.Environment, String>(World.Environment.class);
    
    static {
        for(Dimension d : values()) {
            byEnvironment.put(d.environment, d.namespace);
        }
    }
    
    private Dimension (World.Environment environment, String namespace) {
        this.namespace = namespace;
        this.environment = environment;
    }
    
    public static String getNamespace(Location location) {
        return byEnvironment.get(location.getWorld().getEnvironment());
    } 
}
#

if there is a better way to do this, I'd be happy to hear it. I just couldn't seem to get that info with Spigot. PaperMC downstream has a getKey() off of world which may work, but I was trying to stay upstream.

stone sinew
raven rampart
#

Maybe

#

It doesn't affect the outcome of the problem I'm having though

stone sinew
raven rampart
#

I have a task that gets a location and calls Dimension.getNamespace(location); returns null

raven rampart
stone sinew
#

I maybe reading it wrong but the for loop namespace would be null when its first ran wouldn't it?

raven rampart
#

It's an enum, so the fields would have already been instantiated.

stone sinew
raven rampart
#

... I suppose you get a lot of people in here who don't do that first, but I have and use Discord as a last resort.

ivory sleet
#

What’s the issue

raven rampart
#

The values are coming back as null

ivory sleet
#

What values specifically:0

raven rampart
#

Something is going on with the static block

#

as if it is not executing

warm galleon
#

1.16.5 there is no getView, getName or getTitle for e.getClickedInventory in Inventory Click Event what do i do

ivory sleet
#

Why not do everything inside?

stone sinew
#

I just tested your class it seems to be working fine for me... Are you sure the location isn't null?

raven rampart
#

Yes.

ivory sleet
#

static {
Map<K,V> map = EnumMap.noneOf(K.class);
Arrays.asList(K.values()).forEach(e -> {
map.put(...);
});
byEnvironment = map;
}

raven rampart
#

There is some odd race condition with that static block. and to @ivory sleet's point, I didn't want to have to have an instantiated reference of the class, so enum made sense, but that I would have to do it statically

warm galleon
#

1.16.5 there is no getView, getName or getTitle for e.getClickedInventory in Inventory Click Event what do i do

raven rampart
#

I just tried a different implementation:

public class Dimension {
    
    private static final Map<World.Environment, String> byEnvironment = new EnumMap<World.Environment, String>(World.Environment.class);
    
    static {
        byEnvironment.put(World.Environment.NORMAL, "minecraft:overworld");
        byEnvironment.put(World.Environment.NETHER, "minecraft:the_nether");
        byEnvironment.put(World.Environment.THE_END, "minecraft:the_end");
    }
    
    public static String getNamespace(Location location) {
        return byEnvironment.get(location.getWorld().getEnvironment());
    } 
}

Still the byEnvironment enumMap is empty

ivory sleet
#

Hmm yeah thats odd

stone sinew
# raven rampart I just tried a different implementation: ```java public class Dimension { ...
public static String getNamespace(Location location) {
    if(byEnvironment.isEmpty()) {
        byEnvironment.put(World.Environment.NORMAL, "minecraft:overworld");
        byEnvironment.put(World.Environment.NETHER, "minecraft:the_nether");
        byEnvironment.put(World.Environment.THE_END, "minecraft:the_end");
    }
    return byEnvironment.get(location.getWorld().getEnvironment());
} 
```Try this for the hell of it
ivory sleet
#

Yeah for the record are you doing this on the main thread or not?

raven rampart
#

yes, main thread

ivory sleet
#

Then yapperyaps lazy initialization should work

raven rampart
#

wait

#

yes, it is the main thread

hasty prawn
#

My only guess is that static clauses are called when the class is first referenced, so maybe since you're first referencing it with a another static method, the method fires, and then the static clause is called after? Thonk

stone sinew
ivory sleet
#

Yeah cause Enum maps are not thread safe by default

raven rampart
#

So yes, adding to the map in the static method did work. I would probably throw my computer out if it didn't

#

Seems, dirty, but whatever this only exists because it's dirty

#

Thank you for your help @ivory sleet .

ivory sleet
#

Thank the others also but nice you solved it

raven rampart
#

Yeah, I hit enter too quickly, I was trying to tag @stone sinew as well.

#

Thank you

ivory sleet
#

Alrighty cool

stone sinew
#

I didn't do much but you're welcome lol

quaint mantle
#

I have a tpData.json file but does anyone know how I can get my reader to use it without the absolute path?

#
Reader reader = Files.newBufferedReader(Paths.get("C:\\Users\\gaela\\IdeaProjects\\AdvancedChorusFruit\\src\\main\\java\\me\\jiovannyalejos\\advancedchorusfruit\\tpData.json"));

I'm trying to find a way so that it'd work without an absolute path so probably a relative path or smt, so that others could also use it

ivory sleet
#

Yes

#

Path.of(".") should give you the directory the application was bootstrapped in

stone sinew
ivory sleet
#

x)

iron basin
#

Does anyone know how to add custom entry fees for Portals?

quaint mantle
#

hmm so like would this work?

Reader reader = Files.newBufferedReader(Paths.get(".\\AdvancedChorusFruit\\src\\main\\java\\me\\jiovannyalejos\\advancedchorusfruit\\tpData.json"));
ivory sleet
#

Yeah well how are you running this?

#

Is it like dev environment runtime?

quaint mantle
#

?

ivory sleet
#

Obviously that code of yours can’t be production ready

quaint mantle
#

it's in a listener class that reads the tpdata file so it knows where to teleport the player

#

w-wait wdym?

ivory sleet
#

You’re running a server in your dev workspace src folder?

quaint mantle
#

no, i'm running it in a separate folder and the plugin is just in the plugins folder in the same directory as the server

#

or as the server startup jar

ivory sleet
#

I’m confused but I guess, isn’t that path wrong then?

quaint mantle
#

wait, how so?

ivory sleet
#

Usually data is stored in plugin folders

#

Not in the java source folder of your work space

stone sinew
quaint mantle
#

wha- sry i'm just learning some new things rn, so the getdatafolder() would get it in which directory? and could it get the json file if i move it there?

ivory sleet
#

Yes

stone sinew
fluid cypress
#

whats the difference between Bukkit.getPluginManager().isPluginEnabled() and getServer().getPluginManager().isPluginEnabled()?

silver shuttle
#

Bukkit.getPluginManager().disablePlugin(this);
Does that in the main class disable the plugin?

quaint mantle
#

so that would be in this dir, right? but i don't see it i think

stone sinew
stone sinew
quaint mantle
#

th-the compiler?

stone sinew
quaint mantle
#

ohh, i thought you meant the thing that turns the readable code to macine code

#

i think-

#

unless you meant smt different-

stone sinew
#

No you're right. Just drag and drop the file where you want it to be saved in your project

quaint mantle
#

ahh ok

ivory sleet
#

If we talk about unit testing the instance call is better

#

Even when we talk about object orientation

#

There might be a reason that more than one server instance exist at the same time which the Bukkit class obviously wouldn’t be capable of handling however in a spigot plugin context using the Bukkit class is probably benefiting since it’s less verbose.

quaint mantle
#

So you made me realize something, this is the directory to my json file that's being used in my ide but not for the one that would be in my compiled jar file....

Reader reader = Files.newBufferedReader(Paths.get("./src/main/resources/TeleportData.json"));

but to get it from the plugin folder, i have to use JavaPlugin.getDataFolder() which would be the resources folder? but then the "./src/main/resources/TeleportData.json" bit wouldn't make sense I think, and there's a plugin.yml file in resources as well, so how do i specify?

torpid zinc
#

How could I check if a player sent 3 or more messages in the last 5 seconds?

#

I made a player cache, I figured I would log chat messages but I can't seem to find a way to know when they were sent nor when to delete that data to limit ram usage

stone sinew
stone sinew
quaint mantle
#

so getResource is a method in the Javaplugin class so I have to use it in my main (?) so i assume i have to use

File TeleportData = new File(getResource("TeleportData.json").getBufferedReader());

as a variable that i can get in my listener class?

#

but the getBuffered reader doesn't seem to be a method i could use, since it isn't showing up(?;-;?)

silver shuttle
#
Bukkit.getPlayerExact(args[0]) == null && Bukkit.getOfflinePlayer(args[0]) == null

Is this true if args[0] is the name of a non existing Player?

stone sinew
stone sinew
silver shuttle
#

I'll test it

#

welp it always returns false

#

if he hasnt joined and if he doesnt exist

stone sinew
#

👍

silver shuttle
#

How would I check if a player name simply exists? Without the UUID?

stone sinew
#

You would have to check the mojang api

silver shuttle
#

there's no other way?

stone sinew
silver shuttle
#

okay

quaint mantle
#

sorry, i took a bit since i had to do a chore, so the path would be something along this line?

Reader reader = Files.newBufferedReader(Paths.get(new AdvancedChorusFruit().info));

which i feel is almost what i'm supposed to do...

#

toString would not return the path right?

stone sinew
stone sinew
quaint mantle
#

oh, ok

quaint mantle
stone sinew
quaint mantle
#

ohhhh

stone sinew
undone axleBOT
quaint mantle
#
InputStream infoFile = getResource("TeleportData.json");
public static BufferedReader info = new BufferedReader(new InputStreamReader(infoFile));

so i'd do this in main and then just get it in the Paths.get() except getting the path first(??)

stone sinew
quaint mantle
#

the- the first line has an error warning when i try to make it static
Non-static method 'getResource(java.lang.String)' cannot be referenced from a static context

stone sinew
quaint mantle
#

ohh, that's actually pretty smart

silver shuttle
#

how to get the current UNIX timestamp?

stone sinew
silver shuttle
#

thats not the unix timestamp

stone sinew
silver shuttle
#

Is it this maybe?
System.currentTimeMillis() / 1000L

#

just remove the milliseconds?

stone sinew
#
Date date = new Date();
date.getTime();
quaint mantle
#

So i feel like i'm very close, but i'm not sure how to get the file path of info, which, i'm not exactly sure what the BufferedReader type object is so i'm not sure if i actually need the path still

Reader reader = Files.newBufferedReader(Paths.get(AdvancedChorusFruit.getInstance().info));
stone sinew
quaint mantle
#

i did

stone sinew
quaint mantle
stone sinew
# quaint mantle
InputStream infoFile = <ClassName>.getInstance().getResource("TeleportData.json");
public BufferedReader info = new BufferedReader(new InputStreamReader(infoFile));
CoordinateData data = gson.fromJson(reader, CoordinateData.class);
if(data.locNames.contains(itemDisplayName.substring(5))) {
    String[] coords = data.coordinates.get(data.locNames.indexOf(itemDisplayName.substring(5))).split(Pattern.quote("|"));
    event.setTo(new Location(player.getWorld(), Double.parseDouble(coords[0]), Double.parseDouble(coords[1]), Double.parseDouble(coords[2])));
    reader.close();
}
quaint mantle
#

wh-

#

oh

#

oh ok i thought all that was new

#

ohh, so i only needed the class instance and not have the inputstreamstuff in it

silver shuttle
#

How do I get the timezone the server is in?

#

In the format "GMT-4" for example

#

nvm

vast sapphire
#

my simple explosive bow isn't creating an explosion at the arrow location? ```java
@EventHandler
public void bowShoot(ProjectileHitEvent e) {
Player p = (Player) e.getEntity().getShooter();
assert p != null;
if (p.getInventory().contains(arrow())) {
if (p.getInventory().getItemInMainHand() == bow()) {
e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 1, false);

            e.getEntity().getWorld().playEffect(e.getEntity().getLocation(), Effect.WITHER_BREAK_BLOCK, 1);
            e.getEntity().remove();
        }
    }
}```
stone sinew
stone sinew
vast sapphire
#

just testing the bow atm

real spear
#

Question: what is the best method for making your commands autocomplete?

vast sapphire
#

why isn't the bow working?

quaint mantle
stone sinew
quaint mantle
stone sinew
vast sapphire
stone sinew
vast sapphire
#

alright

stone sinew
#

And remember you're using ProjectileLandEvent not ProjectileLaunchEvent (I say this because the method is named bowShoot)

silver shuttle
#

How do I essentially cancel the PlayerJoinEvent? Or prevent them from joining

silver shuttle
#

simply that on joinevent?

#

and it doesnt cause any interference with other joinevents?

silver shuttle
#

What is the check with vault to see if an OfflinePlayer has a specific permission?

torn oyster
#

what would be the most efficient way

#

to find all the possible spawns in skywars

#

like

#

how do i iterate through all the blocks

#

and find all the locations

#

in the glass cages

#

or do i have to manually enter them in

quaint mantle
#

just save the locations?

rigid otter
#

Hello! What difference between getBlock() and getBlockPlaced() in BlockPlaceEvent?

vague oracle
torn oyster
#

im thinking of adding a /addspawn

#

it literally just adds a spawn at ur location in a config

#

then when the game starts it iterates through all of them, adds em to a list

hexed hatch
young knoll
#

Check the javadocs

#

?jd

silver shuttle
quaint mantle
#

Hey y'all!
Is there a way to store data in an items's PersistentDataContainer as an ItemStack?

torn oyster
#

how

#

do i get this

#

Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}

#

and make it a location object

stone sinew
torn oyster
#

hey yappery

#

could you help

stone sinew
#

I can try, no promises

torn oyster
stone sinew
torn oyster
#

im trying to convert it to a location

stone sinew
torn oyster
#

ok

stone sinew
torn oyster
#

i did location.tostring

#

and im retreiving a list<String> from my config of all the locations

stone sinew
torn oyster
#

uhm

#

that doesnt apply to me

stone sinew
#

Where are you putting the location that you need .toString() then?

torn oyster
#
spawns:
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=-43.5,y=73.0,z=0.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=-14.5,pitch=0,yaw=360}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=-42.5,pitch=-0,yaw=-360}
- Location{world=CraftWorld{name=world},x=-13.5,y=73.0,z=-28.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=14.5,y=73.0,z=-28.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=-14.5,pitch=0,yaw=-360}
- Location{world=CraftWorld{name=world},x=44.5,y=73.0,z=0.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=15.5,y=73.0,z=29.5,pitch=0,yaw=90}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=44.5,pitch=0,yaw=180}
- Location{world=CraftWorld{name=world},x=-14.5,y=73.0,z=29.5,pitch=0,yaw=270}
#

thats what my list looks like

#

i want to turn that into a list of locations

stone sinew
# torn oyster ```yaml spawns: - Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pi...

Why not just create your own string of the location then so its easier to grab?

public String locationToString(Location loc) {
    return loc.getWorld().getName()+","+loc.getX()+","+loc.getY()+","+loc.getZ()","+loc.getYaw()+","+loc.getPitch();
}

public Location stringToLocation(String string) {
    String[] data = string.split(",");
    return new Location(Bukkit.getWorld(data[0]), Double.valueOf(data[1]), Double.valueOf(data[2]), Double.valueOf(data[3]), 
        (float) Double.valueOf(data[4]), (float) Double.valueOf(data[5]))
}
torn oyster
#

12

stone sinew
torn oyster
#

okay

eternal oxide
#

Locations are already serializable, you can literally put the list into the config with one line of code

stone sinew
eternal oxide
#

yes, once added they are auto serialized, which means you can easily retrieve them

stone sinew
eternal oxide
#

Those are simple toString() of Locations, so he has them in code already

#

its 10 seconds to output in teh correct format

worn oak
#

i'm pretty sure you can fetch from json as a raw object then try casting it to Location

torn oyster
#

already did it

#

managed to do it

#

i used json parsing and something idk

paper geyser
#

ok so i deleted this bc i thought i figured it out but i was wrong-

native nexus
#

That’s strange because underscores are perfectly legal for table names.

paper geyser
#

yeah

#

what do you think i should do? Just change the name of the table to MANAREGEN

native nexus
#

Give that a go and see if it makes a difference.

#

Do you have the full code snippet?

paper geyser
#

uhhh sure

#

but I've just changed it to not have the underscore

#

well

#

for some reason that fixed it?

native nexus
#

Yeah that is bizarre

paper geyser
#

oop

#

but

#

the code only runs on first join and when I joined a 2nd time

#

now theres 2 of my uuid and stats

#

here's my full code

#

yup

#

it also doesn't update when i leave?

eternal oxide
#

in your schema set your UUID column as a primary key/unique

paper geyser
#

im sorry this is my first time using SQL what does that mean-

hardy swan
#

a primary key and unique keys are columns that accepts no duplicates

#

simply put

paper geyser
#

ahhh

#

how would I do that with phpmyadmin?

#

wait

#

i can google that

hardy swan
#

you should declare your tables' schema that uuid is your primary key

hardy swan
paper geyser
#

wait-

#

im using phpMyAdmin for my db

#

i think thats what you're asking? But if you dont know its a MySQL database

#

if thats what you're asking

#

i'm so sorry i'm not very knowledgeable in mysql stuff haha

hardy swan
#

I mean MySQL haha

paper geyser
#

alright cool

hardy swan
#

phpMyAdmin is just a software helping you manipulate the sql database

late stone
#

is there any way to disable firecharge (projectile) from exploding and setting fire

paper geyser
#

swag

paper geyser
rustic gale
#
 public HashMap<String, String> PlayerGuilds = new HashMap<String, String>();

 public void UpdatePlayerGuilds(String player, String guildName) {
        PlayerGuilds.put(player, guildName);
    }

UpdatePlayerGuilds is called from a seperate class like this

PlayerGuildData playerGuildData = new PlayerGuildData();
playerGuildData.UpdatePlayerGuilds(player.getName(), "test");

the problem is that the hash map doesn't save. when this function is called

public String GetPlayerGuild(String player) {
        if (PlayerGuilds.get(player) != null) {
            return PlayerGuilds.get(player);
        }

        return "Error - Player is not in a guild";
    }

Error - Player is not in a guild is returned because PlayerGuilds.get(player) is null.

#

so why doesnt the hash map save?

maiden thicket
#

pls use camelCase 🥲

#

but uh

#

are you reloading after running the update method

#

are you restarting

lost matrix
lost matrix
lost matrix
lost matrix
paper geyser
#

hmm?

#

so like \

#

basically the situation is

#

on first join it adds them to the thingy

#

and saves when they leave

#

would that still produce alot of lag often?

#

bc itd be used in those situations

lost matrix
#

Events are executed on the main thread. If you connect to a database in an event and the connection starts hanging then you block the whole server. If this lasts several seconds then the server just crashes.

paper geyser
#

ahhh

#

whats a better way to do this then?

#

also i've changed my code

#

idk how much it helps but

fluid cypress
#

can a World object change somehow? besides deleting it. is it safe to use it as a map key?

paper geyser
lost matrix
lost matrix
paper geyser
#

ahhh ok

#

ok but then how do I get the event player?

#

i see event.getUniqueId

#

but i'd have to change alot of stuff for that to work

lost matrix
#

You dont.

paper geyser
#

ahhh ok-

#

but the event.getUniqueId is the player's UUID right?

lost matrix
#

If the user is not in the DB then just set default values.

paper geyser
#

alright cool

wispy monolith
#

why does mojang still uses this very old mechanic and uses the single-thread server, is there a way to change that using a plugin or something in spigot?

lost matrix
wispy monolith
paper geyser
#

is there any async quit event? I cant find anything so I'm assuming no

#

but i figured i'd try my luck haha

regal moat
#

Guys. Help. I want to summon a falling block and teleport it wherever the player looks

ionic reef
#

Quick question: should I create a MySQL table for each part of my plugin, or join a few together and have a few seperate. e.g Do I create a table called 'playerdata' which can store their friends, their balance, profile info etc, or do I have one table for friends, one table for economy, etc

lost matrix
paper geyser
#

yup! just figured it out but thanks for the reply

#

appreciate people like you alot smile, helping people out just to help :)

lost matrix
paper geyser
ionic reef
#

hmm yeah

#

which one would you say would be easier to work with/more organised

lost matrix
ionic reef
#

Yeah that makes sense

#

cheers man

ionic reef
#

so should I make a new table for every new type of data or not

lost matrix
#

If you want to use a relational database then yes. You should make a new table for different types of data.
But it also depends on the scope of your project.

#

If your plugin is a monolith that is used to run a server then you should def split up your data. If you only provide a plugin for others to use then you can get away with just one table containing all your player data.

ionic reef
#

It's going to be used to run the core aspects of a server so sounds like splitting it up is the way to go

#

tysm for the clarification

#

once again cheers :)

torn oyster
#

Unexpected character (L) at position 0.

                    JSONParser parser = new JSONParser();
                    JSONObject data = (JSONObject) parser.parse(s);```
help plz
#

s is valid json

#

i think

lost matrix
#

Jackson?

torn oyster
#

unless this isnt json
Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}

lost matrix
#

This isnt json

torn oyster
#

what is it then

#

i did Location.toString() how do i do something like Location.fromString()

lost matrix
#

lol

torn oyster
#

idk lol

lost matrix
#

Where do you want to store the location. In a yml file?

torn oyster
#

yes

lost matrix
#

Then just throw it in. Location already implements ConfigurationSerializable.

torn oyster
#

its in a string list

fluid cypress
#

if i throw an exception, i dont have to return to stop the code execution, right?

lost matrix
ionic reef
#

Also another question: can I/how can I store lists in a MySQL table?
(Friends list)

fluid cypress
lost matrix
lost matrix
# torn oyster its in a string list

Serialize one Location

    YamlConfiguration configuration;
    Location location;
    configuration.set("SomeLocation", location);

Deserialize one Location

    final YamlConfiguration configuration;
    final Location location = configuration.getLocation("SomeLocation");

Serialize a List of Locations

    YamlConfiguration configuration;
    List<Location> locationList;
    configuration.set("ABunchOfLocations", locationList);

Deserialize a List of Locations

    final YamlConfiguration configuration;
    final List<Location> locationList = (List<Location>) configuration.getList("ABunchOfLocations");
torn oyster
#

oh okay lol

#

hopefully this works >.<

#

java.lang.ClassCastException: class java.lang.String cannot be cast to class org.bukkit.Location (java.lang.String is in module java.base of loader 'bootstrap'; org.bukkit.Location is in unnamed module of loader 'app')

lost matrix
#

Dont throw in a List<String>

torn oyster
#
spawns:
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=-43.5,y=73.0,z=0.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=-28.5,y=73.0,z=-14.5,pitch=0,yaw=360}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=-42.5,pitch=-0,yaw=-360}
- Location{world=CraftWorld{name=world},x=-13.5,y=73.0,z=-28.5,pitch=0,yaw=-90}
- Location{world=CraftWorld{name=world},x=14.5,y=73.0,z=-28.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=-14.5,pitch=0,yaw=-360}
- Location{world=CraftWorld{name=world},x=44.5,y=73.0,z=0.5,pitch=0,yaw=-270}
- Location{world=CraftWorld{name=world},x=29.5,y=73.0,z=15.5,pitch=0,yaw=-180}
- Location{world=CraftWorld{name=world},x=15.5,y=73.0,z=29.5,pitch=0,yaw=90}
- Location{world=CraftWorld{name=world},x=0.5,y=73.0,z=44.5,pitch=0,yaw=180}
- Location{world=CraftWorld{name=world},x=-14.5,y=73.0,z=29.5,pitch=0,yaw=270}```
#

thats my ymal

#

yaml

lost matrix
#

Yes. Thats a bunch of random unusable data.

#

Dont throw in a List<String>

rigid otter
torn oyster
lost matrix
lost matrix
rigid otter
#

In image

torn oyster
#

okay

lost matrix
rigid otter
#

Item#ItemMeta(), it return a cloned item meta

#

Why don't just not clone, then we no need to Item#setItemMeta() when set

lost matrix
#

Yes. But we need more context or else we cant say if it makes sense or not. Generally you dont want to clone objects unless you want to provide immutablity.

#

Ah i see. So the context is: This is spigot source code

torn oyster
#

i guess i gotta remake all those locations

#

rip

rigid otter
#

World#getBlockAt() is not cloned

lost matrix
#

Changes to the ItemMeta would not be reflected to the NMS ItemStack anyways. So making it immutable makes it more clear.

rigid otter
lost matrix
#

Because ItemMeta has no direct handle like Block has.

#

Its an abstract model introduced by spigot

rigid otter
#

Then, they update the item when applying item meta? Ok!

lost matrix
#

You could make changes to the NMS ItemStack every time the ItemMeta changes. But that would be way more expensive than just applying all changes in bulk once.

#

So spigot (or rather bukkit) opted for this approach.

rigid otter
#

Ok thank you!

regal moat
#

the code

#

it just breaks the block

#

no falling block entity

lost matrix
regal moat
#

at all times

lost matrix
lost matrix
#

Dont

#

Where do you want to store the ItemStack?

lost matrix
#

ItemStack implement ConfigurationSerializable.
So you should try to serialize/deserialize the class using those methods. Try putting the Map<> returned by ItemStack#serialize() into Gson

#

Might work

#

Doesnt work...

#

Does it need to be readable? Or can it also just be a Base64 String?

#

Ill just give you my methods. You need NMS on your classpath for this to work:

  public static String serialize(final ItemStack itemStack) {
    final NBTTagCompound tag = new NBTTagCompound();
    CraftItemStack.asNMSCopy(itemStack).save(tag);
    return tag.toString();
  }

  public static ItemStack deserializeItemStack(final String string) {
    if (string == null || string.equals("empty")) {
      return null;
    }
    try {
      final NBTTagCompound comp = MojangsonParser.parse(string);
      final net.minecraft.world.item.ItemStack cis = net.minecraft.world.item.ItemStack.a(comp);
      return CraftItemStack.asBukkitCopy(cis);
    } catch (final CommandSyntaxException ex) {
      ex.printStackTrace();
    }
    return null;
  }
grim ice
#

@lost matrix btw

#

is it fine if i dont understand any shit in nms

#

its all random letters and shit

opal juniper
lost matrix
# grim ice its all random letters and shit

In 1.17 its all obfuscated. You need to apply the mojang mappings in order to understand anything in there. I could just extrapolate on previous versions because i have been digging in NMS for a while so i can find out what methods/filds do/mean
just by looking at return types and patterns etc. But if you want to properly understand whats written there you can just apply moj mappings

lost matrix
grim ice
#

aaaa ok

opal juniper
#

i’m using that atm

#

will have to have a look

#

you can just base64 it right? i seem to remember that being a thing

lost matrix
#
    final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();

    final ItemStack itemStack = new ItemStack(Material.DIAMOND_AXE);
    final ItemMeta meta = itemStack.getItemMeta();
    meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    meta.setDisplayName("§eCool Axe");
    meta.addEnchant(Enchantment.ARROW_DAMAGE, 3, true);
    itemStack.setItemMeta(meta);

    System.out.println("Item: " + itemStack);
    System.out.println("------------------------------------");
    final String json = gson.toJson(itemStack.serialize());
    System.out.println(json);
    System.out.println("------------------------------------");
    final ItemStack deserializedItem = ItemStack.deserialize((Map<String, Object>) gson.fromJson(json, Map.class));
    System.out.println("Item: " + deserializedItem);
    final String json2 = gson.toJson(deserializedItem.serialize());
    System.out.println(json2);

Made:
Item: ItemStack{DIAMOND_AXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"yellow","text":"Cool Axe"}],"text":""}, enchants={ARROW_DAMAGE=3}, ItemFlags=[HIDE_ATTRIBUTES]}}
to
Item: ItemStack{DIAMOND_AXE x 1}
One could probably figure out whats wrong but i didnt really bother

opal juniper
#

myeah

paper geyser
#

hi me again uhmm

#

ive been struggling with this for about an hour and I just can't get it so-

grim ice
#

Where are the mojang mappings?

paper geyser
#

im trying to update a player's stats

#

Main.prepareStatement("UPDATE playerinfo SET MANA = '100', MAXMANA = '100', MANAREGEN = '2' WHERE UUID = '" + player.getUniqueId() + "'").executeUpdate(); doesn't work

lost matrix
grim ice
#

oh god ok

opal juniper
#

yeah it talks about the buildtools command

paper geyser
#

java.sql.SQLException: No value specified for parameter 1

#

wait-

#

let me try something

#

yeah no that didn't work

#

I'm just extremely confused and lost and in need of resources or just assistance

grim ice
#

eh

#

i wont bother with nms tbh

#

too complicated for me

lost matrix
#

What do you want to achieve?

#

Ok. So for saving you probably want to upsert.
Upsert means -> Insert but if key exists then update

paper geyser
#

but ig I could just have it do the actually variables? idk why I hardcoded it

old sun
#

well I’m sorry but just shut ur trap then would u

paper geyser
old sun
#

sheesh so annoying

paper geyser
#

much appreciated thank you smile

old sun
#

Happy now 🙂

paper geyser
#

id like to share

#

that the issue that I was struggling with for 2 hours was because I had this line of code

#

final static String INSERT_QUERY = "INSERT INTO playerinfo (UUID,MANA,MAXMANA,MANAREGEN) values(?,?,?,?)";

#

lol

#

thought that was funny

#

anyways

opal juniper
#

how to encode itemstacks in b64?

#

wait nvm

#

needed to scroll xD

lost matrix
opal juniper
#

ok

lost matrix
#

Something like this:

  public static String itemStackToBase64(final ItemStack item) {
    final String line;
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try (final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream)) {
      dataOutput.writeObject(item);
      line = Base64Coder.encodeLines(outputStream.toByteArray());
    } catch (final IOException e) {
      e.printStackTrace();
      return null;
    }
    return line;
  }
opal juniper
#

thanks

#

saved me from stack overflow cringe

#

what is the best way to get back to ItemStack

#

cause the ItemStack#deserialise takes a map

#

not b64

eternal night
#

the bukkit object input stream ? 😅

opal juniper
#

myea

#

but how do i get object from it

#
final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(base64));
final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
#

damm

#

im dumb

eternal night
#

I think ObjectInputStream#readObject

opal juniper
#

yep

#

idk how i missed that

regal moat
#

@lost matrix i was having breakfast

#

can u say that again

#

hello?

regal moat
#

read the messages before that

#

i have an item when you right click blocks with it, the block turns into a falling block and teleports itself 5 blocks from your eye location
https://paste.md-5.net/amonaqajew.java
the code
it just breaks the block
no falling block entity

#

help

regal moat
#

help

lost matrix
# regal moat help

This plugin will be quite hard to write as the movement of falling blacks doesnt seem fully server authoritative:

paper geyser
#

you could do it better with command blocks

lost matrix
#

Fks up your performance

paper geyser
#

fair

#

probably bad option for servers

lost matrix
#

You need to do that with packets and some NMS

paper geyser
#

but i've seen it smoother with command blocks at least

paper geyser
lost matrix
#

Let me try a quick setup

quaint mantle
#

Why would command blocks Change anything?

paper geyser
#

im not really good with command blocks but

#

it goes off 2 ideas

#
  1. I've seen command blocks do a good job with this exact thing
  2. I trust smile's statement that the falling block option wouldn't work the way it's desired
#

but the command block option presents issues for server side things

quaint mantle
#

They (the commands) are not sent to the client

quaint mantle
#

So If it works with command blocks it will also work with plugins

paper geyser
#

probably

regal moat
eternal night
#

turning off gravity prevents an entities velocity from being applied tho

#

it is a shitty system

regal moat
#

huh

eternal night
#

oh you don't use velicity

#

you just teleport

#

then yea

regal moat
regal moat
#

yeah

lost matrix
#

This seems to work and is packet based so the falling block doesnt get ticked.

oblique pike
#

Is there any way to get nearby tileentities?

paper geyser
#

do you guys mind if I nab it? (Core and Smile)

regal moat
paper geyser
#

if not totally understandable

#

bc its your project and your idea and your code

#

but i figured why not ask haha

regal moat
paper geyser
#

cool!

regal moat
#

if smile ever sends the code to me

paper geyser
#

haha

paper geyser
lost matrix
paper geyser
#

:0

#

smile do you mind if I use your code?

lost matrix
#

Sure go ahead.

paper geyser
#

great!

tardy delta
#

do you know a good one?

regal moat
#

Cannot resolve method 'runTaskTimer(works.net.Worksnet, works.net.Worksnet, int, int)'

#

i am using intellij

#

fixed it

tardy delta
eternal oxide
#

you are loading locations before the world are loaded

tardy delta
#

owh

#
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§c100 / 100"));```
and for some reason this also isnt working
quaint mantle
#

In which context?

tardy delta
#

it doesnt do anything

#

it should make an actionbar

rigid otter
#

Hello! Why is this cause?
[12:10:20 WARN]: Player SivannGaming just tried to change non-editable sign

regal moat
#

how can i set the velocity of EntityFallingBlock?

tardy delta
#

.setVelocity() ?

regal moat
#

not FallingBlock

#

EntityFallingBlock

#

it doesnt have

#

#setVelocity()

tardy delta
#

probably cast it to something

regal moat
#

tried

lost herald
#

Hey guys, help me please
Wondering if i can put EntityType enum in broadcastMessage() parentheses, will it convert automatically or should i use .name()?

supple elk
#

it will automatically run toString()

lost herald
#

Ok thanks

supple elk
#

if you do something like (EntityType.WHATEVER + "")

#

that might not be the same as .name() however so be careful

lost herald
#

Can it cause an internal irror?

quaint mantle
lost herald
#

ingame

quaint mantle
#

If it returns a string then go for it, but I feel it does not

#

So you’d need to use .name

supple elk
#

entity type is an enum not a function, it doesn't return anything :?

quaint mantle
#

Oh yea shit

lost herald
#

🙂

quaint mantle
#

I just woke up leave me be 😂🤣

supple elk
#

lol

#

anyone know why this isn't working?

tardy delta
#

@Getter @Setter lol

supple elk
#

I'm trying to cast from MCUTeam to DecisionDomeTeam. DecisionDomeTeam extends MCUTeam

quaint mantle
#

Lombok 🙈

#

Hover over the error

supple elk
#

Why not use lombok

#

no error my guy

#

that's a warning

tardy delta
#

WhAt Is LoMbOk?

supple elk
#

for some reason it's saying I can't cast

unreal quartz
#

because it is not an insnace of decisiondome

supple elk
#

I'm not trying to cast to DecisionDome

unreal quartz
#

ddt

supple elk
#

I'm trying to cast to DecisionDomeTeam which extends MCUTeam

unreal quartz
#

yk what i meant

supple elk
#

oh right

unreal quartz
#

yes but it is not an instance of decisiondometeam

#

it's an instance of mcuteam

supple elk
#

oh so I can't cast like that

unreal quartz
#

no

supple elk
#

ugh

lost herald
#

guys if i do that if statement do i need ((LivingEntity) entity)?

unreal quartz
#

i suppose the sethealth method is a member of livingentity, so yes

supple elk
#

what do I do instead then? I have a bunch of minigames, through which the teams earn points across

#

for each game I want to store information about each team, but I don't want to put that information in the team class as it's only used for the one minigame

lost herald
unreal quartz
#

yes but the sethealth method is defined by the livingentity class so you must cast it to use it

supple elk
#

oh

#

I use a wrapper

#

that's what I do

#

I'm fucking dumb

unreal quartz
#

i am going to take a wild guess and say you're a fan of MCC? @supple elk

supple elk
#

I'm not but a friend is

#

who wanted me to code something similar

unreal quartz
#

sounds very MCC inspired

supple elk
#

yeah it is lmao

#

I thought it would be a fun thing to try doing

regal moat
#

?paste

undone axleBOT
regal moat
#

stays still at air

stiff topaz
#

I'm trying to use the API to return a plugins version on my website but it's failing the connection

#

However it works with other PHP fiels

oblique pike
#

I'm setting a persistent data to a tileentity, but it does not set (whenever i check it on other events it does not have data that I've set)

@EventHandler
    public void onPlace(BlockPlaceEvent event){
        if (!isBeaconBlocker(event.getItemInHand())) return;
        new Area(event.getBlockPlaced().getLocation(), radius);
        TileState state = (TileState) event.getBlockPlaced().getState();
        state.getPersistentDataContainer().set(Main.beaconKey, PersistentDataType.INTEGER, 1);
        System.out.println(state.getPersistentDataContainer().getKeys());
        MessageUtils.sendMessage(Main.getInstance().getConfig().getString("messages.blocker-placed"), event.getPlayer());
    }```
#

Anything i missed?

oblique pike
#

Solved

stiff topaz
quaint mantle
#

how can I check if a player has any inventory open?

crude charm
stiff topaz
#

This is spigot related

#

Not php

crude charm
#

?

oblique pike
crude charm
#

send code

stiff topaz
#

My php code works fine but cannot connect to the spigot api

crude charm
#

?paste

undone axleBOT
quaint mantle
oblique pike
# quaint mantle that can't be null?

Gets the inventory view the player is currently viewing. If they do not have an inventory window open, it returns their internal crafting view.

supple elk
#

How can I sort a list of this class in order of sheep from highest to lowest

oblique pike
quaint mantle
#

isn't the internal crafting view the players own inv?

oblique pike
#

It is

quaint mantle
#

I wan't to check if the player has any inv open

#

also the own

oblique pike
#

🤔

#

Opening player inventory does not event fire an event

#

So i guess it's client-sided

quaint mantle
#

Yes I tried InventoryOpenEvent & InventoryCloseEvent event It didnt fire

green forum
#

Hello i'm trying to send two PacketPlayOutNamedEntitySpawn with same UUID in the GameProfile for spawn two NPC with same skin but just one is visible, someone know about this probleme ?

vale cradle
vale cradle
supple elk
#

how is this possible...

#

every time change is set true it should then detect it

ancient plank
#

maybe because it runs through the for loops b4 reaching your if(change) part?

supple elk
#

yes but it's not like I set it false again

#

these events are spaced out

#

each change set true you can see in that screenshot is an entirely different run over of the for loop

#

anyway I fixed it by using an atomic

regal moat
#

help

vale cradle
supple elk
#

why would that be a problem?

vale cradle
#

when the scope is called again, you'll have the variable false again

regal moat
vale cradle
#

Which NMS version are you using?

supple elk
#

I know it resets to false every time, that's the point

#

the problem is that I run code immediately after setting it to true

#

but for some reason it's been set to false again before that

regal moat
supple elk
#

I check immediately after it's set to true before it should have the chance to be set back to false

vale cradle
#

which event was being called from?

regal moat
#

it just

#

stuck midair

#

gravity is on for the falling block btw

tardy delta
#

is this something?

public class ActionBar extends BukkitRunnable {

    private final Player player;
    private final String text;
    private final int seconds;
    private int start = 0;

    public ActionBar(Player player, String text, int seconds) {
        this.player = player;
        this.text = text;
        this.seconds = seconds;
    }

    @Override
    public void run() {
        start++;
        Utils.sendActionBar(player, text);
        if (start == seconds) cancel();
    }
}
quaint mantle
#

Likely

tardy delta
#

yes

quaint mantle
#

?stash

undone axleBOT
tardy delta
quaint mantle
#
TextComponent component = new TextComponent();
        component.setText(message);
        component.setColor(color);
        p.spigot().sendMessage(ChatMessageType.ACTION_BAR, component);
#

Alternatively use something like that, that should work 100%

regal moat
lost matrix
regal moat
#

explained it

#

replied to it i mean

#

i also tried to add fallingBlock.show()

#

but it just made it dissapear

#

wait

#

i am trying something

lost matrix
#

The StaticFallingBlock class is completely packet based. That means setting the velocity of it wont cause the Block which is shown to a user to fly because the user doesnt receive the movement packets.
Also, the velocity is set using the setMot() method

regal moat
#

now i can drop the block

#

but not give it velocity

#

and the falling block just stays there

#

not turning into a block

lost matrix
#

Because its not actually there. The client only thinks its there.

#

The server doesnt know the block exists so it wont turn it into a block.

regal moat
#

oh

#

so using setMot() would fix it?

lost matrix
#

Nope

regal moat
#

?paste

undone axleBOT
regal moat
#

i am currently using this

lost matrix
#

Im also not sure if the packet approach is good here. You should probably just spawn a FallingBlock with velocity turned off and overwritten move() or tick() method to make it teleport to the users crosshair,

regal moat
#

wha

#

i am pretty new to nms 😅

lost matrix
#

Then this might be a very hard project for you.

regal moat
#

i like to challenge myself though

regal moat
lost matrix
#

Eh. You can get creative with this.

#

Actually spawn the block in or do a bunch of logic yourself.

#

Spawn the block in and overwrite some stuff so it does what you want it to do idk

tardy delta
lost matrix
quaint mantle
#

hi

tardy delta
#

change the text after it has been sent

#

like i want to use it to display the health of the player

lost matrix
tardy delta
#

ah just a new

quaint mantle
#

i want to change only sword displayname when player pickup it if the sword equals player name
i tried to use this code:

if (item.getType() == Material.DIAMOND_SWORD && item.getItemMeta().hasDisplayName()) {
            if (item.getItemMeta().getDisplayName().contains(event.getPlayer().getName())) {

                event.setCancelled(true);

            } else {
                normal.setDisplayName(ChatAPI.color("&eDiamond Sword"));
            }```
#

the code works but they don't change item name

#

if the sword don't equals player name it's change it to &eDiamond Sword

lost matrix
quaint mantle
#

else cancel pickup

#

okay @lost matrix

#

yes i did

#
    @EventHandler
    public void onPick(PlayerPickupItemEvent event) {
        ItemStack item = event.getItem().getItemStack();
        ItemStack original = new ItemStack(Material.DIAMOND_SWORD);
        ItemMeta normal = original.getItemMeta();

        original.setItemMeta(normal);
        if (item.getType() == Material.DIAMOND_SWORD && item.getItemMeta().hasDisplayName()) {
            if (item.getItemMeta().getDisplayName().contains(event.getPlayer().getName())) {

                event.setCancelled(true);

            } else {
                normal.setDisplayName(ChatAPI.color("&eDiamond Sword"));
            }
        } else {
            return;
        }
    }```
#

oh

tardy delta
#

is there something like an .setCollidable(false) in the entitySpawnEvent?

quaint mantle
#

i forget to set item meta?

#

yes i did 🙂

tardy delta
#

😳

quaint mantle
#

Hello, guys!
I want to modify the BookMeta of a Book and Quill when the player opens it to provide a translated version of a text based on the client's language, but the book UI is first opened and then the Meta modified, no the changes are not noticeable until you reopen the book.

I tried force-closing the book by closing the inventory of the player and then using player.openBook(), but the Material needs to be WRITTEN_BOOK and i need it to be WRITABLE_BOOK.

Any ideas?

chrome beacon
tardy delta
#

no naturally

chrome beacon
#

Aight dely that with one tick

tardy delta
#

but there is no such method

#

throws Exception

quaint mantle
chrome beacon
quaint mantle
#

last question is there anyway to update scoreboard with out flicker

young knoll
#

Prefix and suffix

stone sinew
rare cave
#

try it

tardy delta
#

yes

stone sinew
# tardy delta yes

That would require the method to be enclosed in a try catch... which is what I am trying to clean up

lost matrix
#

You want this only for checked exceptions?

tardy delta
#

or let the jvm handle the exceptions

stone sinew
rare cave
#

its ok to have many try catch blocks

stone sinew
tardy delta
lost matrix
# stone sinew yes posted an example of the code it runs in try catch

Im this far right now:

@FunctionalInterface
public interface ThrowingConsumer<T, E extends Exception> {

  void accept(T t) throws E;

  static <T> Consumer<T> wrapper(final ThrowingConsumer<T, Exception> throwingConsumer) {
    return value -> {
      try {
        throwingConsumer.accept(value);
      } catch (final Exception ex) {
        throw new RuntimeException(ex);
      }
    };
  }

}

Let me make it a bit more modular...

#

Wait i should test if this works first...

tardy delta
#

💀

chrome beacon
tardy delta
#

i did

#

on playerjoin

lost matrix
stone sinew
rare cave
#

hm

lost matrix
stone sinew
regal moat
#

@lost matrix i am totally confused with the materials. i can use #getMaterial() but that doesnt return org.bukkit.Material

#

im confused

stone sinew
#

I'll try to implement it. Thanks

stone sinew
lost matrix
#
  @Override
  public void onEnable() {
    final File targetFile = new File("test");
    final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(targetFile);
    ThrowingConsumer.<File>wrapper(file -> this.doRandomStuffToFile(configuration, file)).accept(targetFile);
  }

  private void doRandomStuffToFile(final YamlConfiguration configuration, final File file) throws Exception {
    // Do a bunch of stuff in here
  }
tardy delta
#

wew

stone sinew
hollow bluff
fading lake
#

You need the repository

hollow bluff
#

I have it.

fading lake
#

unless its on maven centeal

quaint mantle
#

case sensitive, are you using jitpack

hollow bluff
#

no

quaint mantle
#

add it as a repository

#

nvm

#

it uses this repo

#
<​repositories​>
        <​repository​>
            <​id​>eldonexus</​id​>
            <​url​>https://eldonexus.de/repository/maven-releases/</​url​>
        </​repository​>
</​repositories​>
#

wtf is this

regal moat
#

@lost matrix i am totally confused with the materials. i can use #getMaterial() but that doesnt return org.bukkit.Material

#

help

quaint mantle
#

this is a horrible dependency setup

#

shame on that developer

hollow bluff
#

I do have the correct repository but it doesnt find the dependency

quaint mantle
#

contact the dev

fading lake
#

does anyone have any idea how you'd go about hosting your maven artefacts on your own site?

regal moat
#

but that returns net.minecraft.world.level.material.Material

#

and not org.bukkit.Material

tardy delta
#

stupid actionbar doesnt work

regal moat
regal moat
fading lake
#

Material.valueOf(net.minecraft.world.level.material.Material#name) should work surely

#

unless the names are differennt

#

and since NMS Material and Bukkit Material do the same thing, I'd see no reason as to why they'd be different

#

but theres no direct way to get the bukkit one from the NMS one since bukkit is built on top of NMS, so NMS has no idea bukkit exists, hence it not being able to give an NMS -> Bukkit method

#

@regal moat

fading lake
tardy delta
#

uhh this is my code

public class ActionBar extends BukkitRunnable {

    private final Player player;
    private final String text;
    private int start = 0;

    public ActionBar(Player player, String text) {
        this.player = player;
        this.text = text;
    }

    @Override
    public void run() {
        start++;
        Utils.sendActionBar(player, text);
    }
}

and inside the playerjoin i use new ActionBar(p, sometext).run()

dusk flicker
#

Why are you creating an object for it?

lost matrix
fading lake
#

Ah, can I see where you attach ActionBar to the scheduler, and show is the code to Utils#sendActionBar

tardy delta
#
public static void sendActionBar(Player player, String message) {
        player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message));
    }```
fading lake
#

and the scheduler attachment?

tardy delta
#

huuh

fading lake
#

basically wherever you ran ActionBar bar = new ActionBar() you need to put something like Bukkit.getScheduler().runTaskTimer(plugin, () -> bar.run());

tardy delta
#

oh

tardy delta
fading lake
lost matrix
#

Thats like double wrapping

#

Its already a BukkitRunnable

fading lake
#

I'm half asleep, takeoverpls I can't think straight

#

but that'd work anyhow

lost matrix
#

new ActionBar().runTaskTimer(plugin, 1, 1);

quaint mantle
#

No

dusk flicker
#

I still think that a object for this is overkill but it works

tardy delta
#

so something like this?

public void run() {
        Bukkit.getScheduler().runTask(Main.getInstance(), () -> Utils.sendActionBar(player, text));
    }
fading lake
#

OH YEAH

#

no

tardy delta
#

😳

quaint mantle
#

Wtf

fading lake
#

essentially

quaint mantle
#

Then get rid of "extends Runnable" please

fading lake
#

forgot how the scheduler worked for a sec there

#

the extends runnable is what allows him to attach it to the scheduler in the way he's doing kt

#

@tardy delta you good now?

tardy delta
#

uhh i'm reading

lost matrix
quaint mantle
#

Was replying to an earlier message

#

I blame my highly unstable net

tardy delta
#

and why not runTask() instead of timer?

#

to wait one tick?

dusk flicker
#

I believe the idea here is to make it go on for a set amount of time

regal moat
ivory sleet
#

Wth

regal moat
#

i have no idea

ivory sleet
#

Hmm yeah I can tell

regal moat
#

what can i do

#

in this situation

ivory sleet
#

What are you trying to do?

ivory sleet
#

No it won’t

#

Unless Material::toString calls Material::name

quaint mantle
#

Unless the Enum member declarations Match up

#

By default it should (for toString = Name)

fading lake
#

afaik, all enums toString return the name?

ivory sleet
#

Yeah Idk if it’s overridden or something

fading lake
#

at least they always have for me

#

oh possibly

quaint mantle
#

Name cannot

fading lake
ivory sleet
#

I thought any derivative of the Enum class by default just returns its garbage value

fading lake
#

yeah, but I dont see why it would be, its worth checking though

quaint mantle
#

Lemme see

fading lake
#

I'd be able to test it but I'm not at my PC

ivory sleet
#

Hmm alright good to know

regal moat
#
Provided: Material```
#

@fading lake

quaint mantle
#

Enum#name ALWAYS returns String

regal moat
#

i am using intellij

fading lake
#

Material#name doesnt return Material

quaint mantle
#

Then fuck IJ - though I think you Just plainly messed up

regal moat
#

so what should i do here

quaint mantle
#

Make Sure you call .name

fading lake
#

could you take a screenshot of the error?

#

and what the code is causing it?

quaint mantle
#

(is NMS Material even an Enum?)

fading lake
#

oh that could be it

#

uh oh

quaint mantle
#

?stash

undone axleBOT
eternal night
#

It isn't

#

Nms has moved away from enum representation for a while

fading lake
#

whats the point in that

quaint mantle
#

Mods

fading lake
#

?

#

why cant mods use enums

quaint mantle
#

Converting enums into registries is a PITA

fading lake
#

sorry, whats a PITA

quaint mantle
#

Especially If you have the kind of insanity that the Bukkit Material Enum has

#

Pain in the ass

fading lake
#

ah

#

not me googling it and it returning results for pita bread

#

?stash

undone axleBOT
fading lake
#

there's no way to look at NMS code without decompiling it is there?

#

(like no github or stash)

quaint mantle
#

NMS = mojang

regal lake
#

Somebody know why a drinkable instant damage potion don't trigger the EntityDamageEvent ?

quaint mantle
#

I. E. All Rights Reserved

regal lake
#

The throwable potions trigger the event with the cause "magic" but the drinkable not 😄

chrome beacon
#

I would report that as a bug

#

If you're up to date

quaint mantle
#

Apparently suicide does no damage

regal lake
#

The lingering potions will also not trigger the event

#

😄

fading lake
#

what doesn't kill you makes you stronger

chrome beacon
quaint mantle
#

Как можно у игроков забирать опыт?

fading lake
#

hes talking about spigot/bukkit

regal lake
fading lake
quaint mantle
#

No

#

Не работает

fading lake
#

какие ошибки в консоли?

quaint mantle
#

Может позвоню?

#

Ты русский?

#

Ошибка там типо пишет что не может быть больше 1

#

Это полоска

#

Но giveExp получается выдавать

#

А забрать никак

fading lake
#

Я использую сайт переводов, возможно, я не смогу

quaint mantle
#

Оу

#

Sorry

fading lake
quaint mantle
#

секунду
just a second

rigid otter
#

Hello! I have a problem with my local maven repo, after built BuildTools. That is, when I add as a dependency in IntelliJ(as a library), I can't see its commets. Just like it make library file simply small and has no comment, and some of variable show only var0, var1, var2, etc. It is hard to read and follow the library. How to deal with that?

#

Here is example:

eternal oxide
#

did you add javadocs to your pom?

rigid otter
ivory sleet
#

Yeah

quaint mantle
#

@fading lake

ivory sleet
#

You’re depending on a decompiled jar just like that? Not a maven artifact dependency or anything like that.

rigid otter
quaint mantle
#

[19:09:42 ERROR]: Could not pass event PlayerInteractEvent to asas v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:72) ~[patched_1.12.2.jar:git-Paper-1618]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:513) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:236) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PlayerInteractManager.a(PlayerInteractManager.java:486) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1011) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PacketPlayInUseItem.a(PacketPlayInUseItem.java:5) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.2.jar:git-Paper-1618]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_291]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_291]

#

at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:850) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:774) ~[patched_1.12.2.jar:git-Paper-1618]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:666) ~[patched_1.12.2.jar:git-Paper-1618]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.lang.IllegalArgumentException: Experience progress must be between 0.0 and 1.0 (-1394.0625)
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:191) ~[patched_1.12.2.jar:git-Paper-1618]
at org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer.setExp(CraftPlayer.java:981) ~[patched_1.12.2.jar:git-Paper-1618]
at test.Ender.Two(Ender.java:115) ~[?:?]
at test.Ender.Two(Ender.java:50) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor110.execute(Unknown Source) ~[?:?] at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1618]
... 17 more

#

1

#

1

#

1

#

Caused by: java.lang.IllegalArgumentException: Experience progress must be between 0.0 and 1.0 (-1394.0625)

rigid otter
quaint mantle
#

okay

eternal oxide
ivory sleet
#

You probably want to add the respective sources jar to your classpath

rigid otter
#

Ohh

fading lake
ivory sleet
#

You see when compiling, local variable and parameter names are lost

rigid otter
fading lake
ivory sleet
#

So we need to add a sources jar to the classpath which contains all the classes from the dependency but not compiled to class files (they’re still .java files)

quaint mantle
#

I also use a translator.

#

it just removes the experience scale

#

@fading lake

fading lake
#

потому что вы берете больше опыта, чем у них

rigid otter
eternal oxide
rigid otter
#

Then it show an error

#

And library is lost

fading lake
#

ошибка говорила, что вы пытались установить их опыт на -1394.0625

eternal oxide
#

did you fill in the version?

rigid otter
#

Filled

eternal oxide
#

it works fine, you have to have one for the spigot-api and one for the javadocs

rigid otter
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <type>javadoc</type>
            <scope>provided</scope>
        </dependency>
fading lake
#

подожди, ты имеешь в виду уровень или опыт

quaint mantle
#

exp

eternal oxide
#

This is minexml <!--Bukkit/Spigot API --> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>${project.spigotVersion}</version> <scope>provided</scope> </dependency> <!-- Spigot Javadocs --> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>${project.spigotVersion}</version> <type>javadoc</type> <scope>provided</scope> </dependency>

rigid otter
#

Ohh

rustic gale
fading lake
#

пытаться player. setTotalExperience(Math.max(0, player.getTotalExperience() - сумма чтобы взять));

vale ember
#

please help, i need to replace all '&#(a-fA-F0-9)' with ChatColor.of("#(a-fA-F0-9)")

rigid otter
eternal oxide
rigid otter
#

Still the same as before

eternal oxide
#

have you manually added some other jars?

rigid otter
#

What others?

quaint mantle
#

this simply resets the experience scale

eternal oxide
# rigid otter What others?

It works perfectly if you've not added somethign manually ```java
/**

  • Represents a player, connected or not
    */
    public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient {

    /**

    • Gets the "friendly" name to display of this player. This may include
    • color.
    • <p>
    • Note that this name will not be displayed in game, only in chat and
    • places defined by plugins.
    • @return the friendly name
      */
      @NotNull
      public String getDisplayName();```
#

that is what I see for Player

rigid otter
#

Yeah, for me don't😔

eternal oxide
#

what dependencies do you have in yoru ide?

quaint mantle
#

@fading lake

lost matrix
fluid cypress
#

what is the type of a function function or whatever is used in java for callbacks? specifically o want to send a lambda expression to a function to call when finishing something

quaint mantle
rigid otter
# eternal oxide what dependencies do you have in yoru ide?

Only this

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <type>javadoc</type>
            <scope>provided</scope>
        </dependency>
    </dependencies>
lost matrix
fading lake
#

что показывает player.getTotalExperience() - сумма чтобы взять

eternal oxide
lost matrix
lost matrix
quaint mantle
eternal oxide
#

Your first and second screenshot you showed us

#

What IDE are you using?

rigid otter
#

I'm using IntelliJ

quaint mantle
#

@lost matrix

eternal oxide
#

do all the dependencies show as fine in Intelij? No red underscores