#help-development

1 messages · Page 2183 of 1

pastel juniper
#

In hypixel skyblock if you click on a player a player profile opens. There you can see his armor and main hand and whenever he changes on of them the inventory updates

humble tulip
#

Also 50 items, that's allot to do with out a loop

crisp steeple
slate mortar
humble tulip
#

Lol

#

It'll update when they player equips and unequips armor

#

U can create an armorequipevent

slate mortar
#

yea i never messed with custom events, at least not in spigot

pastel juniper
#

and how can I update a specific item slot

#

???

slate mortar
#

for custom events i always use my shitty horrible optimized own api lol

humble tulip
#

Inventory.setItem(int slot, ItemStack)

slate mortar
iron glade
#

I guess

#

does this make sense

slate mortar
#

with get its contents you hopefully mean the player's contents, and not the gui's contents

#

in that case, it does indeed make sense

#

i mean, when you jut set the contents to what is already set, it'd change nothing lol

humble tulip
daring lark
#

did Class InventoryOpenEvent cares about chestd etc. or only player inv?

stuck flax
#

how would i kill all dropped items without using /kill @e

quaint mantle
#

Please help
I have a list of Protection, but I cant get the list from config

c3c73faa-eeef-2f10-9bae-67abcdd00f5f:
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
  owner: &id001
    ==: Player
    name: Armando_Sales
  location:
    ==: org.bukkit.Location
    world: world
    x: 13.0
    y: -60.0
    z: -4.0
    pitch: 0.0
    yaw: 0.0
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
  owner: *id001
  location:
    ==: org.bukkit.Location
    world: world
    x: 18.0
    y: -60.0
    z: -5.0
    pitch: 0.0
    yaw: 0.0
CustomConfig.getContainersConfig().getList(onlinePlayer.getUniqueId().toString()); //is null
slate mortar
humble tulip
#

Player inventory is always marked as open

slate mortar
#

lol

humble tulip
#

InventoryCloseEvent is claled when it's closed though which is dumb and inconsistent

#

But it's mojangs fault

daring lark
humble tulip
#

Yes u can

daring lark
#

cool

slate mortar
#

i mean, try it out and print out a message

#

if it prints that message, you can

humble tulip
#

It worksfor chests

slate mortar
#

if not, you can't

#

i may actually create a clientmod someday which extends the amount of things that send packets

#

it's so dumb to see how many things don't inform the server about what happened

iron glade
#

Levitation effect is not triggered under water

slate mortar
iron glade
#

Now I have to check if the player is in the water and teleport him to the first block that is not water

#

so annoying

slate mortar
#

i love that it is like this

#

imagine looting endcities without that

#

water is the best thing against that stupid effect

iron glade
#

:(

#

in my case it's just annoying

#

that it's like that

midnight shore
#

does anyone know why when i have a prepareitemcraftevent and i get the crafting inventory, i set the result item and it only shows when i remove the current result in the crafting grid?

lethal python
#

guys i know this isn't a development question but i have a really large build that i want to move (including mobs, inventories, biomes, etc) to another world, the place would be too large to do with litematica, is there anything like the old mcedit which can do that these days?

eternal oxide
lethal python
#

okey

iron glade
#

Simple way to check if player is in water is to check if the block at his eye position is type = water?

tall dragon
#

That would not detect if only his feet are in the water

iron glade
#

I don't care about his feet as the Levitation effect triggers as soon as your head is outside of the water

#

okay nevermind

crimson scarab
#

what is the event for a player setting on fire

#

find the answer

#

it was entitycombustevent

iron glade
#

.playEffect() is deprecated, what should be used instead?

ivory sleet
#

yeah

quiet ice
#

are you sure that you cannot write to it?

#

The different icon can be explained by it being empty

thorny dawn
#

pls tell me u arent creating a datastore system with yml files

#

it can get quite messy and bad if the server grows

#

id say its good for storing temp data

quiet ice
#

Temp data?

thorny dawn
#

if you want a stable database consider SQL or Mongo

thorny dawn
quiet ice
#

I prefer my DataInputstream & DataOutputStream

quiet ice
thorny dawn
#

oh alright

quiet ice
#

Proper databases are overrated

thorny dawn
#

no they arent

#

sql is overrated because its dogshit

ivory sleet
#

wut

thorny dawn
#

there are way better databases to use

ivory sleet
#

such as?

thorny dawn
#

mongo is way better

quaint mantle
#

Please can anyone help me with this thing

c4c5af3a-ee3f-3f90-91ae-67a5cfd00f6c:
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
  owner: &id001
    ==: Player
    name: Armando_Sales
  location:
    ==: org.bukkit.Location
    world: world
    x: 2.0
    y: -60.0
    z: 21.0
    pitch: 0.0
    yaw: 0.0
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
  owner: *id001
  location:
    ==: org.bukkit.Location
    world: world
    x: 1.0
    y: -60.0
    z: 19.0
    pitch: 0.0
    yaw: 0.0
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
  owner: *id001
  location:
    ==: org.bukkit.Location
    world: world
    x: 0.0
    y: -60.0
    z: 18.0
    pitch: 0.0
    yaw: 0.0

I'm trying to deserialize a list of Protections but the objects are all null

      for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
            if (CustomConfig.getContainersConfig().getList(onlinePlayer.getUniqueId().toString()) != null) {
                List<?> list = CustomConfig.getContainersConfig().getList(onlinePlayer.getUniqueId().toString());
                for (Object object : list) {
                    EventoBlockPlace.getProtections().add(((Protection) object));
                }
            }
        }

[null, null, null]

ivory sleet
#

mongo isnt relational though

#

they serve different purposes

#

(ideally)

#

then if you use it for something else thats on you

quiet ice
#

See, DataInputStream & DataObjectStream is much better if done properly

thorny dawn
#

its easier to use mongos driver for maven

quiet ice
#

The only issues are spontaneous crashes or power losses - but most DBs have similar issues.
And you don't want to have this anyways

ivory sleet
#

yes but for scalability you dont always want to run a mongodb

thorny dawn
#

why not

ivory sleet
#

because complex queries can be much more scalable w/ sth like postgre for instance

#

postgre is enterprise gold

quiet ice
#

What does it say?

#

Then you are not writing to it

thorny dawn
#

well i dont wanna go through the process of learning how to use another database since mongo provides me with more than enough to do what i want

quiet ice
#

How do you write to it?

#

that alone does not write anything

ivory sleet
thorny dawn
ivory sleet
#

dont spread fud about technologies that are actually really useful and meaningful

#

lack of compactness?

#

mind elaborating on these points you're making

thorny dawn
#

there are 469 keywords in sql

ivory sleet
#

and, you dont need to know them all to be able to use sql?

vocal cloud
#

Man hate SQL all you want but it's lighter than a lot of others (looking at you mongo)

ivory sleet
#

if you know the 36 most used ones then you're already quite knowledgeable in sql

vocal cloud
#

SQLite is also really nice

ivory sleet
#

for instance mongo is unstructured, and internally it saves everything to json documents, so it is efficient if you are gonna store key-value blobs, but for structured data sql is almost always the way to go whenever you actually want to seriously scale something (horizontally ofc)

thorny dawn
#

mongodb vs sql ill let u pick

#

look at the huge mess of shit sql creates

vocal cloud
#

Lmfao I love the argument that less is always better.

ivory sleet
#

I mean you usually put your statements in constants and format them in a more readable way, anyway this is entirely besides the point

thorny dawn
#

u can shoot yourself in the foot so easily with sql

ivory sleet
#

its not like you're writing a million lines of sql queries tho lol

#

I mean then you get a syntax error which takes a minute at most to fix (presupposing you wrote it syntactically wrong)

quaint mantle
vocal cloud
#

Plus you can always use intellij to prep your queries in advance.

quiet ice
#

Welp, this reinforces my assumption that all DBs are shit

ivory sleet
#

And like sure, thats a nice java wrapper for mongo ceryth

#

but those exist for sql impls as well

thorny dawn
#

i can still use mongo more easily with my other applications if i want to access that data

ivory sleet
#

elaborate?

vocal cloud
#

Also if you've used Linq SQL can look way better than anything mongo has.

thorny dawn
#

say you would like to make a discord bot for your discord server that verifies the player based on ingame data, or get their stats by running /stars <player> on discord

ivory sleet
#

and its not like one is harder to setup or anything fyi

#

both have docker containers on docker hub etc

iron glade
#
final int points = 18;
        final double size = 8;
        int upper = 256;
        int lower = p.getLocation().getBlockY();

        Bukkit.getOnlinePlayers().forEach(all -> {

            for (int k = lower; k < upper; k+=4) {

                for (int i = 0; i < 360; i += 360 / points) {
                    final double angle = (i * Math.PI / 180);
                    final double x = size * Math.cos(angle);
                    final double z = size * Math.sin(angle);

                    final Location locnew = p.getLocation().add(x, lower, z);

                    all.playEffect(locnew, Effect.MOBSPAWNER_FLAMES, 1);
                    all.playSound(locnew, Sound.ENTITY_ENDERMAN_AMBIENT, 5L, 5L);
                }

            }
        });```


Are those too many particles or why is it not showing any??
vocal cloud
#

Imo people who hate SQL are just mad cause bad.

ivory sleet
#

well mongo isnt bad

vocal cloud
#

Now OracleSQL that's something to hate

ivory sleet
#

they just have different core purposes

#

lol

vocal cloud
#

I use both

ivory sleet
#

same

quaint mantle
#

#help-development message

    public PrimeiroPlugin() {
        ConfigurationSerialization.registerClass(Protection.class);
    }
public class Protection implements ConfigurationSerializable {

    @Override
    @Nonnull
    public Map<String, Object> serialize() {
        Map<String, Object> stringObjectMap = new HashMap<>();
        stringObjectMap.put("location", location);
        stringObjectMap.put("owner", owner);
        return stringObjectMap;
    }

    private final Location location;
    private final Player owner;


    public Protection(Location location, Player owner) {
        this.location = location;
        this.owner = owner;
    }

    public Location getLocation() {
        return location;
    }

    public Player getOwner() {
        return owner;
    }

    @Override
    public String toString() {
        return "Protection{" +
                "blockLocation=" + location +
                ", owner=" + owner.getName() +
                '}';
    }
}

@quiet ice

vocal cloud
#

SQL is for lighter applications

#

Mongo is for heavier

ivory sleet
#

yeah or well if you wanna take advantage of its structuring implementation

limber owl
#

why did this function returned null
public void removeLevel()

#

it's my custom function

#

and there's normal code

#

and like

#

what

quiet ice
#

...

#

Are we supposed to be witches?

thorny dawn
quiet ice
#

Knowing everything in the universe?

thorny dawn
#

even if i created a single plugin, i doubt i would get myself through the process of writing sql

ivory sleet
#

anyway for instance Netflix, Twitch and Instagram are some services that use postgresql due to the fact that its a good sql impl

vocal cloud
#

Plus you can write the constraints and what not in your create query and that makes me happy cause then it's just simple inserts from there.

limber owl
#
public void removeLevel() {
        if (world == null || startLocation == null || name == null) return;

        try {
            LevelsConfig.set("levels." + name, null);
            LevelsConfig.save();
        } catch (Exception e) {
            Bukkit.getLogger().log(java.util.logging.Level.SEVERE, e.getMessage());
            if (WaterRun.get().getConfig().getBoolean("debug"))
                e.printStackTrace();
        }

        if (WaterRun.getDatabase() != null && WaterRun.getDatabase().isConnected()) {
            try {
                if (WaterRun.getDataHandler().isInLevels(this)) {
                    WaterRun.getDataHandler().removeLevels(this);
                } else {
                    Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Level "+name+" isn't in database");
                }
            } catch (Exception e) {
                Bukkit.getLogger().log(java.util.logging.Level.SEVERE, e.getMessage());
                if (WaterRun.get().getConfig().getBoolean("debug"))
                    e.printStackTrace();
            }
        }
    }
``` can someone help why did this return null exception
vocal cloud
#

Have you ever configured a cisco router?

ivory sleet
#

lets say you have a table of users that have some columns such as name, number and geolocation, with sql you'd be able to efficiently only get a number, or a geolocation for all or one user in a horizontally scalable manner

topaz moon
ivory sleet
#

in mongo, internally even though you might only want the number of all users it'd have to query entire blobs still

#

this becomes especially powerful with relational tables (sql)

limber owl
#

[22:23:20] [Server thread/ERROR]: null

vocal cloud
#

Ah beautiful

thorny dawn
#

idk man sql sounds a bit edgy for me

#

u need to take care of so many exceptions and errors

ivory sleet
#

wat

limber owl
vocal cloud
#

Well yeah but mongo just throws them secretly and if you get hit with one good luck. SQL has the balls to warn you in advance

thorny dawn
#

mate have u seen mongo logs

vocal cloud
#

Yes

thorny dawn
ivory sleet
#

its not like thats impossible to do with sql since thats a mere wrapper (logging)

vocal cloud
#

Throw secretly as in you don't know something can throw an exception (like a query) until it does

limber owl
#

there's nothing else, I know ho to go through the statrace and it's just pointing from where in code it moved there, and for real, I have no idea why did this happend, i think something corrupted interrupted it and broke it

ivory sleet
vocal cloud
#

Man doesn't know what his db do

thorny dawn
#

i just found it trash that i have to learn an entire new language for such simple shit

ivory sleet
#

it takes like 20 mins to learn

vocal cloud
#

Yes but it's worth it

ivory sleet
#

and its not dogshit because you avoid learning it

#

thats a you problem only

topaz moon
limber owl
#
    public void createLevels(Level level) {
        db.update("INSERT INTO Levels (Name, World, LocationX, LocationY, LocationZ, DoorX, DoorY, DoorZ\n)" +
                "VALUES ('" + level.getName() + "', '" + level.getWorld().getName() + "', '"
                + level.getStartLocation().getX() + "', '" + level.getStartLocation().getY()
                + "', '" + level.getStartLocation().getZ() + level.getDoorLocation().getX()
                + "', '" + level.getDoorLocation().getY() + "', '" + level.getDoorLocation().getZ()
                + "')");
    }
#

mysql, the update method is just querry

thorny dawn
ivory sleet
#

ok?

limber owl
#

but it would throw this:

    public int update(String query) {
        try {
            return conn.createStatement().executeUpdate(query);
        } catch (Exception e) {
            plugin.getLogger().info(" ");
            Bukkit.getConsoleSender().sendMessage("§c - Query failed! §4" + query);
            Bukkit.getConsoleSender().sendMessage("§c - Error: " + e.getMessage());
            return -1;
        }

//        System.out.println("UPDATE - "+ query);
    }
ivory sleet
thorny dawn
vocal cloud
#

Kek mongo takes longer to learn the little things. Plus you need a tonne of libraries to make it functional

vocal cloud
#

Yes?

quaint mantle
#

can any one tell me how should I use the static deserialize method? Please

thorny dawn
#

lol

vocal cloud
#

Bson?

ivory sleet
#

yes but prepared statements make it safer to use, why wouldnt you want to exercise best practices?

topaz moon
thorny dawn
#

querrying for me is easier in mongo

ivory sleet
#

that still has to correlation to why sql would be dogshit

crude cobalt
#

Hello everyone, anyone fumbling for MySQL? I hope so. In general - what kind of error:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'enduranceY (NAME, UUID) VALUES ('MrLadad13','bdc1f5f7-413b-3775-96a7-eed8857f...' at line 1

Code:

PreparedStatement ps2 = pl.SQL.getConnection().prepareStatement("INSERT IGNORE INFO enduranceY"
                        + " (NAME, UUID) VALUES (?,?)");
upper vale
#

INFO?

#

Should be INTO no

thorny dawn
vocal cloud
#

As if with just a few seconds of boilerplate you can produce a faster, more effective method of doing things

ivory sleet
upper vale
#

why is a mysql vs mongo debate turning into personal attacks 💀

thorny dawn
#

its not lol

vocal cloud
#

to the untrained, sql developer eye

topaz moon
#

oh

thorny dawn
ivory sleet
#

billion lines?

quaint mantle
#

@vocal cloud Do you know ho can I use this method?

#

public static Protection deserialize(Map<String, Object> args)

ivory sleet
#

its not like the sql query is gonna be harder, more verbose or more complicated if you wanted to write something sql equivalent

vocal cloud
#

Compact? Sure. Compared to the amount of memory mongo uses? I'll take it

topaz moon
#

everything has its use-case

vocal cloud
upper vale
#

General rule of thumb for me when choosing between SQL or Mongo is just if the data is relational or not

ivory sleet
#

^

ivory sleet
#

structured vs unstructered

#

none of those are dogshit

ivory sleet
#

none are inherently worse than the other unless you define a particular use case

topaz moon
#

to quote a reddit comment


SQL is like a shop, everything is laid out on the shelf. It's easy to pick what you need, but to do the job you have to walk up and down the isles to get each bit.

NoSQL is great of you're always making the same thing. SQL is great if you make a variety of things. Use the right tool for the job.```
upper vale
vocal cloud
#

Also if it's multithreaded or not. If it's never multithreaded then I just use SQLite

crude cobalt
topaz moon
#

says INFO

#

instead of INTO

#

you got a typo there

thorny dawn
#

as i said, coming from creating web apps i dont wanna learn sql when i can already adapt easier with mongo

ivory sleet
#

sure if thats your opinion

#

but dont go around spreading shit about sql when you havent even taken the time to learn it

thorny dawn
#

i didnt say that objectively its my opinion

crude cobalt
ivory sleet
#

bit unorthodox to form an opinion about something you scarcely know about, then going on to make points that aren't even correct, anyway guess we're done debating now

topaz moon
humble tulip
#

I had a thread spamming my sqlite database and my plugin still functioned

#

It was to stress test it

vocal cloud
humble tulip
#

Nope

#

You can disable it

#

It's on by defualt

vocal cloud
#

THONK I guess I'm just old

ivory sleet
#

I mean most of them have to be thread safe

#

else the world would have met its demise long time ago

vocal cloud
#

SQLite is really nice hes_UwU

humble tulip
#

It's basically sql but faster

#

Great if you don't need the data anywhere else

ivory sleet
#

yeah as a mock implementation its rather nice

topaz moon
#

wrong quote

topaz moon
vocal cloud
#

Yeah but for my application (lightweight program meant to run on a low-spec server) it's a lot better and you don't need the bloat of a db running alongside it. If I needed more complex types I'd be toast

topaz moon
#

perfect for a lightweight use-case

humble tulip
#

Yep

#

I made a pos system for fun and used sqlite

#

just create a file

#

Lol

tender shard
#

new File("asd.yml").create();

vocal cloud
#

^

tender shard
#

or new YamlConfiguration().save(new File("asd.yml"));

vocal cloud
tender shard
#

or you rename an existing file and make it empty

#

wdym you cant write to it? whats the error message?

#

and how exactly can you "not" write to it?

humble tulip
#

What are you usingnto write to the file?

tender shard
#

set a value in the file?

#

whut?

humble tulip
#

When u set, yu need to save

little trail
#

Does using set() on the FileConfiguration actually save automatically to config.yml

humble tulip
#

Not save every time

#

Save every x mins and on disable

#

Or if it's a one time set

#

You can save right after

little trail
tender shard
#

FileConfiguration.save(File)

humble tulip
#

^^

#

😐

little trail
#

What, you were the one that put two carets

#

i completely forgor what java/kotlin does with pass-by-reference and value if any, would this actually edit and save the config

ivory sleet
#

iirc yes

next zinc
#

Does #damage() ignore armor?

tender shard
#

IIRC it deals exactly the amount of damage you specify

#

so it basically "ignores" armor

ivory sleet
#

^

next zinc
#

Is there a way to not ignore the armor?

tender shard
#

none that I know of

topaz moon
#

is armor a value you can substract from damage?

eternal oxide
#

you can throw an event and see what the resulting damage is

ivory flume
#

wait question

next zinc
#

Ill try that

ivory flume
#

how are you supposed to even update your plugins when rhey have the version of the api u use in the package name of bukkit stuff?

#

manually change all of them?

tender shard
#

just do search & replace

crude cobalt
#

@upper vale Thanks for the help with SQL, bro

next zinc
#

I think I found a better way to tackle the problem tysm for the help

ivory flume
#

sorry then

tender shard
#

only CraftBukkit and NMS classes (prior to 1.17) had the version in the package name

#

if you stick to the Bukkit API, then plugins will basically run in every version

quaint mantle
#

can anyone help me learn databases? i've been trying to make a system where you can set a default kit then the player can re arrange the kit to how they like and save it

tardy delta
sacred mountain
#

or a way to do it that i can write myself

maiden vapor
#

Are you trying to predict what the damage will be, or modify the damage?

sacred mountain
#

modify

#

well acute at ye the fbe a tan fb se terry aei o the p i ato bc t sang at of

#

wtf

maiden vapor
#

Damage events have something like getDamage(DamageModifier.Armor) that gives you the reduction the armor does. If you did setDamage(DamageModifier.Armor,0), armor would be completely ignored

sacred mountain
#

its a co syykk@

#

whay is wtrong with mykeyyyaird

tender shard
patent horizon
#

is there no easy way to make a dictionary/map in java?

eager knoll
#

I'm getting ClassNotFoundException and I tried multiple things including checking the directory that plugin.yml leads to, I can't seem to find the issue, any help?

ivory sleet
#

there is

#

Map.of()

patent horizon
#

wowza

sacred mountain
# tender shard it's drunk

ok so what i was trying to say, is that im dealing with particles and i need to deal damage and not modify its

patent horizon
#

so u can only have up to 10 values?

sacred mountain
#

since particles dont damage players

tender shard
#

just create a new Map yourself

patent horizon
tender shard
#
Map<String,String> map = new HashMap<>();
#

then add as many stuff as you want

sacred mountain
#

can you put values here?
HashMap<>(....);

tender shard
sacred mountain
#

oh right

tender shard
#

also the "here" part is called the constructor 😄

ivory sleet
#

well

#

there's Map.ofEntries() also :333

sacred mountain
#

is <> just accepting a type and () the consturcutr

#

HashMap<T>

#

something with generics idk

tender shard
#

a HashMap has two generic types

#

one for the key, one for the value

sacred mountain
#

ah right so

#

T, T?

tender shard
#

nope

sacred mountain
#

pr is it K, V

tender shard
#

two different names

#

it doeesnt matter

#

it could also be called HashMap<Peter,Alex>

sacred mountain
#

so you could name it anything?

tender shard
#

sure

#

T is short for "Type"

sacred mountain
#

but dont types have to be existing classes or sum

tender shard
#

"K,V" is short for "Key" and"Value"

sacred mountain
#

to use them

compact haven
#

Generics aren’t classes

sacred mountain
#

or is that only in the constructor

tender shard
sacred mountain
#

i though that was <?>

#

oh thats for

compact haven
#

That’s another type of generic

#

That’s a wildcard

sacred mountain
#

unknown soemthing but known type?

#

nvm

compact haven
#

It’s when you don’t know the type of the generic

sacred mountain
#

ohk

tender shard
compact haven
#

When you define a class using a generic, you use a letter or word like T or Type

sacred mountain
compact haven
#

When you use a class using a generic, you use the class or ? if you don’t know the class yet

#

Optional<?> for example is an Optional of an unknown type

native nexus
#

You don’t specifically have to use the keyword T

sacred mountain
#

so if i wanted to create a method that only works with my Effects abstract class i could use

public void blah(? extends Effect)

ivory sleet
#

I mean you also use wildcards with super/extends for generic sub-/supertyping

compact haven
#

no you can’t do that

tender shard
#

why would you need generics if you know what parameter you expect

sacred mountain
#

true

#

i see

tender shard
#

just take a list for example

native nexus
#

Use interfaces

tender shard
#

you can have lists of ANYTHING

#

so list is generic

#

your method takes an effect and not a string or an integer or a player

#

so yours isnt generic 😄

sacred mountain
compact haven
#

You can do something like that with

public <T extends Effect> blah(T effect){}
sacred mountain
compact haven
#

That does, properly, what you sent above

sacred mountain
#

or like anything

tender shard
#

an interface is like a radial piston pump

sacred mountain
#

should i know what that is

tender shard
#

this is a radial piston pump

compact haven
#

It’s an abstraction for simplicity. Imagine if list.get(5) returned an Object, then you needed to cast that to a Player when you know every element in that list is a Player

limber mica
#
Exception in thread "Thread 1" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 19 path $
    at com.google.gson.JsonParser.parseReader(JsonParser.java:66)
    at com.google.gson.JsonParser.parseString(JsonParser.java:47)
    at com.google.gson.JsonParser.parse(JsonParser.java:98)
    at com.yk.handlers.JsonHandler.getKnowledge(JsonHandler.java:40)
    at com.yk.handlers.JsonHandler.clearCache(JsonHandler.java:74)
``` ```java
            JsonArray array = parser.parse(content).getAsJsonArray();
ivory sleet
#

show your json

subtle folio
#

hello friends what does this error mean? ```[22:04:32 ERROR]: Error occurred while enabling TazpvpCore v1 (Is it up to date?)

java.lang.NoClassDefFoundError: net/tazpvp/tazpvpcore/Commands/admin/GmcCMD

at net.tazpvp.tazpvpcore.TazpvpCore.registerCommands(TazpvpCore.java:37) ~[tazpvpCore-1.jar:?]

at net.tazpvp.tazpvpcore.TazpvpCore.onEnable(TazpvpCore.java:25) ~[tazpvpCore-1.jar:?]

at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:541) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:560) ~[paper-1.18.2.jar:git-Paper-341]

at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:474) ~[paper-1.18.2.jar:git-Paper-341]

at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:664) ~[paper-1.18.2.jar:git-Paper-341]

at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[paper-1.18.2.jar:git-Paper-341]

at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:316) ~[paper-1.18.2.jar:git-Paper-341]

at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-341]

at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-341]

at java.lang.Thread.run(Thread.java:833) ~[?:?]

Caused by: java.lang.ClassNotFoundException: net.tazpvp.tazpvpcore.Commands.admin.GmcCMD

at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:151) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]

... 13 more```
tender shard
subtle folio
#

it is

native nexus
limber mica
sacred mountain
#

not seeing it

tender shard
undone axleBOT
subtle folio
#

mk

tender shard
round finch
#

can someone help me?
where can I find some good spigot code examples of yamlconfiguration / configuration / memory

sacred mountain
tender shard
#

lol

native nexus
#

Interfaces are just classes with predefined functions that you want to inherit in multiple instances

#

But I also am not good at explaining things

#

So

#

Uh

sacred mountain
tender shard
#

I was always told "an interface is a contract"

tender shard
ivory sleet
#

the huge benefit of interfaces is that they do not allow instance fields and one class can inherit multiple interfaces

tender shard
#

FileCOnfiguration etc extends Memoryconfiguration

ivory sleet
#

@round finch

sacred mountain
#

o

ivory sleet
#

what example precisely

sacred mountain
#

oops

ivory sleet
#

like in terms of design? Or something else?

round finch
#

what about Serializable?
i forgor

limber mica
#

It doesn't look like its an issue in my json because I believe I formatted it correctly

ivory sleet
#

Serializable is crappy java serialization

subtle folio
#

line 75 of interest

ivory sleet
#

ConfigurationSerializable is what you probably mean

#

but that is also kinda meh

tender shard
round finch
tender shard
#

for example the alias thing never works for me

#

bukkit still saves it using the full class name

native nexus
#

Depends how readable you want to make your files but I would just stick to gson

ivory sleet
#

writing a strategy object to serialize and deserialize objects is probably the wisest choice

sacred mountain
subtle folio
tender shard
subtle folio
#

thanks..

limber mica
sacred mountain
ivory sleet
#

I mean doesnt javadocs suffice for that?

round finch
#

reason for i'm asking i used hours to get hashmap in hashmap

tender shard
ivory sleet
#

oh

round finch
#

i thought to myself maybe i'm being dumb and lack of understanding

limber mica
ivory sleet
#

itsvollx a good way is to write a facade and data transfers that carries the config data

tender shard
tender shard
#

oh you did send it above lmao

#

sorry

sacred mountain
#

put it into a json checker

limber mica
#

says its valid

sacred mountain
#

idk looks correct but i dont even know json syntax

round finch
tender shard
#

that's not the valid that threw the error

limber mica
#

No?

tender shard
#

your first line only has one character

#

or did you parse it without newlines in one line?

limber mica
#

Wait what

#

First line in the json?

#

Is it not suppose to have one character?

#

I thought it was suppose to be just [

native nexus
#

Like @sacred mountain said put it in a json checker…

limber mica
#

I did

sacred mountain
#

thay was before i knew it was valid

#

also i thought it was a large file didnt see how simple it was

tender shard
ivory sleet
#

interface ConfigFacade {
  void load();

  ConnectionCredentials getConnectionCredentials();
}

class YamlConfigFacadeImpl implements ConfigFacade {
  final Path path;
  final FileConfiguration config;
  
  YamlConfigFacadeImpl(Path path) {
    this.path = path;
    this.config = new YamlConfiguration();
  }

  @Overide void load() {
    try (var reader = Files.newBufferedReader(this.path)) {
      config.load(reader);
    }
  }

  @Overide ConnectionCredentials getConnectionCredentials() {
    return new ConnectionCredentials(
      config.getInt("db.port"),
      config.getString("db.address"),
      config.getBoolean("db.ssl")
    );
  }
  
}

record ConnectionCredentials(int port, String host, boolean useSsl){}

@round finch

#

just an example (and yes you could load and store the connection credential in a field from load if you wanna use more memory for faster access) [entirely up to you]

sacred mountain
#

question mark paste when

shadow gazelle
#

Are there any examples of allowing people to make recipes in a config anywhere?

sacred mountain
#

what is var

limber mica
#

Apparently it's not formatted but its not

shadow gazelle
#

I'm not sure how I what should do it

subtle folio
#

fix was cleaning it

#

lolz

sacred mountain
#

is var just a generic type that accepts anything given

ivory sleet
#

nope

#

it infers the type

native nexus
#

Welcome to Java 10

tender shard
# shadow gazelle Are there any examples of allowing people to make recipes in a config anywhere?
GitHub

Avoid writing the same code over and over again - use JeffLib for your Spigot plugins! - JeffLib/RecipeUtils.java at a56e94dd3b9d227775449cee58e3846fc66a760e · JEFF-Media-GbR/JeffLib

sacred mountain
#

oh right ok

shadow gazelle
#

Never mind, I found something

tardy delta
#

var str = null kekw

ivory sleet
#

var x = "hi"
compiles to
String x = "hi"

#

(the type String gets inferred)

sacred mountain
#

so you can supply it with anything you want

ivory sleet
#

well once defined you cant assign random values to it

#

var x = 1;
x = "kappa"; //this would yield a compile error

tender shard
#

"var" is just short for "use the type of what's behind the = sign"

sacred mountain
#

behind?

tender shard
#

on the right side

sacred mountain
#

oh

tender shard
#

you know what I mean lol

sacred mountain
#

lmao

#

my computing teacher is currently teaching cubism art in inkscape

ivory sleet
sacred mountain
#

im not sure how this is gonna help me in my finals

tardy delta
#

hehe i know

sacred mountain
#

he never teaches much

#

we're currently learning in VB.NET which is quite a bit older than me

round finch
tardy delta
#

visual basic meh

ivory sleet
#

yeah I mean that would actually specify the file

tardy delta
#

i have to be honest but the windows font looks better than the linux one on discord lol

sacred mountain
#

i can atleast make my own windows program now

ivory sleet
#

so you could do something like
new YamlConfigFacadeImpl(plugin.getDataFolder().toPath().toAbsolutePath().resolve("epicconfiggamer.yml")) or sth

#

gets a bit long

round finch
#

i barely knows any sql

ivory sleet
#

same

round finch
#

data tables is confusing :(

ivory sleet
#

tho you dont need to know a lot of sql to be able to use it adequately

sacred mountain
sacred mountain
limber mica
round finch
sacred mountain
#

i see sqlite and mysql code and all the tables are just strings of mysql commands

round finch
#

all those shity tut got my head in pain with sql

sacred mountain
#

i guess thats the way to run them

ivory sleet
#

yes

sacred mountain
#

till someone said it sucked

ivory sleet
#

You can still use yaml

#

its good as a mock implementation

#

you know, for testing

round finch
#

isn't there sql manage api?

for people with java skills

sacred mountain
tardy delta
#

alot of sql libraries

tardy delta
#

which handle writing the queries for yo

ivory sleet
#

its doable lightfury

sacred mountain
#

well it didnt look good to me

ivory sleet
#

not scalable

#

but doable

sacred mountain
#

yeah

#

with a lot of players

#

which i do not havve

#

because i have no friends

compact haven
#

I mean you could use yaml on a replicated remote storage that every other instance also uses

sacred mountain
#

but at least now its more efficient :D

compact haven
#

It’s not impossible, but not recommended…

sacred mountain
#

i debated on whether to try mongodb

ivory sleet
#

you should get familiar with mongo

#

definitively

sacred mountain
#

apparently its better for bigger data

round finch
#

i probably gotta learn mysql w-w

ivory sleet
#

myeah sorta, I mean depends on use case

sacred mountain
#

document based nosql stuff idk

compact haven
#

PostgreSQL is best for large structured sets

ivory sleet
#

for structured data, postgre as itzdlg mentioned is gold beyond everything

sacred mountain
#

what do you think the best storage system is?

#

im probably gonna get a "it depends"

tall dragon
#

feel like there is no best

ivory sleet
#

idk depends on the system's needs

tall dragon
#

depends on your needs

#

xD

sacred mountain
#

called it

native nexus
#

depends

sacred mountain
#

lmaoo

native nexus
#

🖕

sacred mountain
#

yeh i see

native nexus
#

❤️

#

hehe

ivory sleet
#

I mean redis has become really powerful recently

sacred mountain
#

yeah i was thinking about mongodb and redis for async across servers

ivory sleet
#

but it has some inevitable cons also

round finch
#

wait wait faster data storage?

tall dragon
#

yea i use alot of redis as well

native nexus
#

HikariCP and redis still superior

sacred mountain
tall dragon
#

mostly pub/sub is rlly nice from redis

ivory sleet
#

myeah

sacred mountain
#

what is pubsih

#

pub/sub

tall dragon
#

u have channels

ivory sleet
#

an event bus implementation

tall dragon
#

u can publish messages

#

and other programs can subscribe

ivory sleet
#

like bukkit's event system

sacred mountain
#

ohk

ivory sleet
#

but deployable through multiple nodes

tall dragon
#

yea i got a full on packet system for communication between my servers

#

works very nicely

sacred mountain
#

the only thing i ever used packets for was showing the minecraft demo mode screen

native nexus
#

A lot of plugins don't need to take it that far tho

sacred mountain
#

on a different note ive been thinking about creating some of my own custom events

PlayerCosmeticSwitchEvent and a couple others

how do i make it accessible by other plugins?

#

making it an api or something

round finch
#

does anything go to your bungeecord?

tall dragon
#

no

round finch
#

tell me your stuff

#

magic man

tall dragon
#

well its fairly simple. have a packet that you can serialize/deserialize, send, receive them using redis

#

in short

round finch
#

those all your servers communicate with each another?

tall dragon
#

yea

round finch
#

woaw 😮

tall dragon
#

all servers send statistics like logins, tps, bunch of other stuff

sacred mountain
#

is it possible to create a bungee plugin that allows the player to stay "connected" to a server whilst its restarting (bungee proxy)

tall dragon
#

and thats displayed using grafana

tender shard
tall dragon
#

so i can see everything

tender shard
#

other plugins then have to check if your plugin is installed, and if yes, register their listeners for your events

sacred mountain
#

okay

tall dragon
#

really quite simple

tardy delta
#

gn

round finch
#

some packet api?

tall dragon
#

no

tardy delta
round finch
#

Among SUS

sacred mountain
#

what is @NoArgsConstructor and @AllArgsConstructor? sounds a bit counterproductive lmao

tardy delta
#

constructor without and with all args as parameters (all fields i guess)

tall dragon
#

i need a constructor with no args to create the class when deserializing, and one with all when you want to send the packet

round finch
tall dragon
#
public abstract class Packet
{

    public abstract void send(BaosOutputStream out) throws IOException;

    public abstract void receive(BaosInputStream in) throws IOException;
}

no i made it myself. but this is all it is

tender shard
round finch
#

🤌 perfection

#

do you make a listener for ips?

tall dragon
#

no. redis allows you to publish on channels with certain names

#

you just listen to those

round finch
#

Dammm

tender shard
#

is there actually ever ANY reason to use Class.cast(Object) unless you want to use getDeclaredField / getDeclaredMethod later on?

ivory sleet
#

method reference

#

like map(Blah.class::cast)

#

(reducing boilerplate)

tender shard
#

makes sense

#

I just wonder because I just found code like this

        final Object craftAdv = CLASS_CRAFTADVANCEMENT.cast(adv);
        final Object advHandle = getObject(CLASS_CRAFTADVANCEMENT, craftAdv, "getHandle");
#

and after that, craftAdv is never used again

ivory sleet
#

uh

tender shard
#

so the cast is totally useless here

ivory sleet
#

ye

#

looks like it

tall dragon
#

oh @tender shard i meant to tell you. i actually managed to make the cow thing work

tender shard
#

nice, how?

tall dragon
#

like that

#

it bassically reregisters the mob with my own method for checking if it can spawn

buoyant viper
tall dragon
#

Byte Array Object Serialization / ByteArrayOutputStream

tender shard
#

oh ok nice

tall dragon
#

didnt fully do that myself tho

#

i got big brain friend haha

tender shard
#

who volunteers to write javadocs for me lol

ornate patio
#

I'm trying to create a custom horse using NMS, here's what I got:

public class SuperiorHorse extends EntityHorse {
    public SuperiorHorse(World world) {
        super(EntityTypes.M, ((CraftWorld) world).getHandle());
    }
}

public enum EntityTypes {

    SUPERIOR_HORSE("Horse", 54, SuperiorHorse.class); 

    private EntityTypes(String name, int id, Class<? extends Entity> custom)
    {
        addToMaps(custom, name, id);
    }

    public static void spawnEntity(Entity entity, Location loc) {
        WorldServer worldServer = ((CraftWorld) loc.getWorld()).getHandle();
        entity.teleportTo((WorldServer) worldServer, new BlockPosition(loc.getX(), loc.getY(), loc.getZ()));
    }

    private static void addToMaps(Class<? extends Entity> clazz, String name, int id) {
        ((Map) Utils.getPrivateField("c", net.minecraft.world.entity.EntityTypes.class, null)).put(name, clazz);
        ((Map) Utils.getPrivateField("d", net.minecraft.world.entity.EntityTypes.class, null)).put(clazz, name);
        ((Map) Utils.getPrivateField("f", net.minecraft.world.entity.EntityTypes.class, null)).put(clazz, Integer.valueOf(id));
    }
}
tender shard
#

are you on 1.17+?

ornate patio
#

the EntityTypes enum is mostly just copy pasted from online

ornate patio
ornate patio
#

is there a more modern tutorial for custom entities?

ornate patio
tender shard
#

I'd use mojang mappings for 1.17+, then you don't have to worry about weird field names like "c", "d", "f"

winged anvil
#

since persistent data cant be applied to blocks, does someone have an idea how I would store if the block has already been mined by a player?

tender shard
#

with mojang mappings, you can use the "real" names for methods and fields

#

the names that mojang themselves chose

ornate patio
# tender shard what's the error?
Caused by: java.lang.ClassCastException: class net.minecraft.world.entity.EntityTypes cannot be cast to class java.util.Map (net.minecraft.world.entity.EntityTypes is in unnamed module of loader java.net.URLClassLoader @18769467; java.util.Map is in module java.base of loader 'bootstrap')
#

i understand what it means, i just have no idea what im doing

ornate patio
#

if mojang is giving out the obfuscation map out for everyone, why do they still obfuscate -.-

tender shard
#

what is the addToMaps method supposed to do btw?

tender shard
#

still better than not having any obfuscation map 😄

#

but yeah it's so stupid

ornate patio
#

no clue lemme find the tutorial and see

#

it was a really old tutorial so im pretty sure its outdated

ornate patio
tender shard
#

lol

#

well I'd simply comment it out for now

ornate patio
#

or wait

#

I found this comment

#

ok nevermind

#

I think its meant to add the entity to bukkit

#

so that I can spawn it

tender shard
#

oh uuugh

#

that's not a good idea

#

idk but hacking into existing enums is a pretty dirty solution

#

also it's not needed at all

ornate patio
#

what's the preferred way of doing it

tender shard
#

just do the rest as you already did but ignore the "addToMaps" part

winged anvil
#

is this persistent?

tender shard
winged anvil
#

sure??

tender shard
#

yes

#

that's the whole idea for it lol

winged anvil
#

hmm

tender shard
lethal coral
#
    @EventHandler
    public void onProjHit(ProjectileHitEvent event){
        if(event.getHitEntity() != null){
            event.setCancelled(true);
            return;
        }
        Projectile projectile = event.getEntity();
        if(!projectile.hasMetadata("gunType")) return;
        Location location = projectile.getLocation();
        Block block = event.getHitBlock();
        assert block != null;
        if(block.getType() == Material.BARRIER || block.getType() == Material.AIR) return;
        block.setType(Material.AIR);
        location.getWorld().playSound(location, block.getBlockSoundGroup().getBreakSound(), 0.75f, 1f);
        location.getWorld().spawnParticle(Particle.BLOCK_CRACK, block.getLocation(), 10, block.getBlockData());

why don't the particles spawn

tender shard
#

because AIR doesn't have any "breaking" animation

vocal pine
#

Hi sorry to kinda interrupt whats going on above - Anyone have any idea how to make Minecarts NOT collide with players & people? I've tried cancelling the event - but it loses all velocity - And tried cancelling the collision - but it launches backwards

Is there a way to make pairs of entity instances have no collisions specifically for each other without affecting anything else?

#

I want minecarts to just pass through each other and people with 0 velocity change

#

Searched & searched and there's lots of threads with no answers

tender shard
lethal coral
#

😩

vocal pine
#

Thank you

tender shard
#

np. if you find a way to do it, I'd be interested in how it works 😄

#

probably you can override some method from your custom minecart class but I am not sure whether its actually part of the minecart class, or of the world itself or sth

quaint mantle
#

wouldn't scoreboard teams also work

vocal cloud
#

Isn't that player only

quaint mantle
#

I thought it could be used with other entities too

tender shard
# vocal pine Yikes ok I'll take a look

I just checked. the collisions and physics are inside AbstractMinecart(or in spigot mappings: EntityMinecartAbstract) in the method "tick()". You could override it but it contains the whole logic so it's pretty long....... I fear what you wanna do is quite complicated lol

#

this is the method you'd have to override

lethal coral
#

meta.displayName(MINI_MESSAGE.deserialize("<reset><gradient:gold:yellow>Feather Powerup"));
why is it still italicized

#

(this is for an item name btw)

vocal pine
ornate patio
#

wrong reply oops

tender shard
#

most casses have different names in mojang mappings

#

for example EntityArmorStand is simply ArmorStand in remapped

ornate patio
#

oh

#

I see

tender shard
#

you basically now have exactly the names for everything like mojang themselves are using

#

does someone know if I can tell javadoc to add certain text to the generated method description when there's a certain annotation on the method?

#

For example here, I annotated it with "@NeedsNMS". I want the javadocs to automatically add an additional sentence for every method with this annotation

sullen marlin
#

you could make a doclet probably

#

thats all I know

tender shard
#

alright thx Imma google that

ornate patio
#

@tender shard figured everything out after installing mojang mapped, thanks!

#

god this is so much easier i wish i knew this earlier

tender shard
#

perfect!

tender shard
#

I knew they existed for a year before I switched to them

#

I was afraid of all this pom.xml stuff lol

ornate patio
#

this is my first time working with nms

#

i was expecting it to be a huge pain

#

but this makes things so much easier

#

just one more thing

#

is this a good way to spawn my custom entity?

public static void spawnEntity(Entity entity, Location spawnLocation) {
    ServerLevel serverLevel = ((CraftWorld) spawnLocation.getWorld()).getHandle();
    serverLevel.addFreshEntity(entity);
    entity.setPos(spawnLocation.getX(), spawnLocation.getY(), spawnLocation.getZ());
}
tender shard
#

looks fine to me

#

but I have to add that I never did any "custom entity" stuff myself

ornate patio
#

alright

winged anvil
#

?paste

undone axleBOT
winged anvil
fossil lily
#

Can I use .getDisplayName() on a default item?

ivory sleet
#

there is

humble tulip
#

U can use existing ones like lamp or acf which is annotation driven and really easy to use

#

Or u can create your own but a hashmap in the command to the subcommand is possible

ivory sleet
#

Pebble so basically a full command is a tree of literals and arguments

#

and each branch executes basically

#

what you got as of now?

humble tulip
#

Hashmaps are for fast access so u don't iterate thru em

waxen plinth
#

Are you looking to have even better abstractions or are you trying to build stuff yourself?

humble tulip
waxen plinth
#

Well here's how I write commands:

#
kill player:target {
  hook kill
  permission kill.use
}```
#
@CommandHook("kill")
public void kill(CommandSender sender, Player target) {
  target.damage(1000);
}```
#

That's a basic example

#

Funnily enough I'm deprecating this library soon in favor of one I'm currently working on, but the concept is more or less the same so it's pretty effortless to port projects over

humble tulip
waxen plinth
#

If you want to compare how you'd implement commands in mine vs others, I'd be happy to give more examples

tender shard
waxen plinth
#

Actually come to think of it I should make a spigot forum thread for my new library when it's ready

tender shard
#

it's just to notify people that this method uses NMS

tender shard
ivory sleet
#

yes

tender shard
#

while methods without @NeedsNMS will continue to work fine without needing updates for the lib

waxen plinth
#

Yeah breaking it up into methods is always a good idea

tender shard
#

breaking people's legs however is not a good idea

dusk flicker
#

i mean

#

fuck the legs

humble tulip
#

U can do both

#

Basically if subcommand is in map execute that

#

If not let the command be the executor

#

So if you have /mine craft create dirt

tender shard
humble tulip
#

If craft is in the map, oass create dirt to your subcommand

humble tulip
#

If not, let your command handle it

tender shard
humble tulip
#

🏳️‍🌈

humble tulip
#

is that the Why are you gay dude?

quaint mantle
#

"You are gae"

tender shard
humble tulip
#

😂

winged anvil
#

?paste

undone axleBOT
crisp steeple
winged anvil
tender shard
#

but what did you expect? that code was written by a tiny studio in sweden and suddenly the game became sooo big

quaint mantle
#

guys im selling my iphone 2

tender shard
slate mortar
tender shard
#

you know that situation when you start a new project and you do everything as clean and good practice as possible

#

and a year later it's all messed up lol

crisp steeple
#

yep

tender shard
#

happens to me all the time

quaint mantle
#

and he also wrote it in java

crisp steeple
#

"well im not going to be using this too much so its ok if its a little messy"

quaint mantle
#

fuck java

tender shard
#

exactly lol

tender shard
quaint mantle
#

i like the syntax and stuff

#

but

#

its not low level enough for me

#

and the jvm takes too much memory

tender shard
#

yeah well

#

java not being low level is both good and bad

waxen plinth
tender shard
quaint mantle
tender shard
#

huh?

#

windows uses pretty few ram

#

linux always uses as much as it can

waxen plinth
#

lol

tender shard
#

for disk caching etc

lethal coral
#
public static List<Block> getNearbyBlocks(Location location, double radius) {
        List<Block> blocks = new ArrayList<>();
        for(double x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
            for(double y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
                for(double z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
                    blocks.add(location.getWorld().getBlockAt((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z)));
                }
            }
        }
        return blocks;
    }

why does this give me a cube

quaint mantle
#

i saw something where windows would use like 4gb if you used 16gb or something

tender shard
#

I got anno 1800, fl studio, photoshop, 11 intellij projects, about 100 tabs in chrome open and still it's not at 100% lol

waxen plinth
lethal coral
#

😩

lethal coral
#

a sphere 💀

waxen plinth
#

Why

winged anvil
#

what

lethal coral
#

I didn't look into the math

quaint mantle
#

LMAO

tender shard
#

you could simply only add the blocks if the distance to the center is less than X but the proper way would be to improve your math 😛

crisp steeple
waxen plinth
#

If you want a sphere then filter it to only blocks with a distance from the center <= radius

quaint mantle
waxen plinth
#

It's a good way

lethal coral
waxen plinth
#

Just use distanceSquared instead of distance

crisp steeple
#

also theres no reason to Math.floor

waxen plinth
#

Well

tender shard
waxen plinth
#

It does technically have different behavior

tender shard
#

because it loops over blocks that you don't actually need

#

but too lazy to look up the proper math

waxen plinth
#

floor always rounds down

#

(int) rounds towards zero

crisp steeple
#

i suppose yeah

#

but that just seems like it would make it inaccurate

waxen plinth
#

But you want the consistency here anyways

#

Just cast to int

lethal coral
#

🤔

quaint mantle
waxen plinth
waxen plinth
carmine valley
#

hey guys, what is the proper event for if I want to check if a player hit another player?

waxen plinth
quaint mantle
#

why

waxen plinth
carmine valley
waxen plinth
#

.-.

quaint mantle
waxen plinth
#

No

#

It's impossible to check that on 1.8

quaint mantle
waxen plinth
#

Plugins can't listen for events on 1.8 you just have to poll the player's health every tick

#

/s

#

I'm gonna go get ice cream

carmine valley
#

what I'm trying to make is a plugin that would increase the amount of knockback a player gets depending on how many times he has been hit, are you saying such plugin is not possible on 1.8.x ?

tender shard
waxen plinth
#

So?

tender shard
#

so it'd be better to narrow down the loop somehow 😄

lethal coral
#
    public static List<Block> getNearbyBlocks(Location initLoc, double radius) {
        List<Block> blocks = new ArrayList<>();
        for(double x = initLoc.getBlockX() - radius; x <= initLoc.getBlockX() + radius; x++) {
            for(double y = initLoc.getBlockY() - radius; y <= initLoc.getBlockY() + radius; y++) {
                for(double z = initLoc.getBlockZ() - radius; z <= initLoc.getBlockZ() + radius; z++) {
                    Block block = initLoc.getWorld().getBlockAt((int) x, (int) y, (int) z);
                    if(initLoc.distanceSquared(block.getLocation()) <= radius)
                        blocks.add(block);
                }
            }
        }
        return blocks;
    }

does this look overly inefficient :troll:

tender shard
#

but who cares

waxen plinth
#

To my knowledge there isn't really a better way

tender shard
#

radius should be radius*radius

#

because you use distanceSquared

lethal coral
#

I see

waxen plinth
#

Like yes there are algorithms that would get you to iterate over only blocks within the sphere to begin with

#

But the overhead of those algorithms negates the benefit

tender shard
#

if(initLoc.distanceSquared(block.getLocation()) <= radius * radius)

tender shard
waxen plinth
# carmine valley .

Instead of asking me if an event exists in 1.8.8 you could just type it into your IDE

#

It will tell you very quickly

lethal coral
carmine valley
waxen plinth
#

I should make an n-dimensional for loop utility

quaint mantle
lethal coral
#

I typically only use brackets if it's > 1 line

carmine valley
#

is there any other proper events I can call to make such knockback plugin?

lethal coral
#

😁

waxen plinth
quaint mantle
waxen plinth
#

You have to use brackets if it's more than one line

quaint mantle
#

@tender shard why the bitshifts

    public static List<Chunk> getChunks(final World world, final BoundingBox box, final boolean onlyLoadedChunks) {
        final int minX = (int) box.getMinX() >> 4;
        final int maxX = (int) box.getMaxX() >> 4;
        final int minZ = (int) box.getMinZ() >> 4;
        final int maxZ = (int) box.getMaxZ() >> 4;
waxen plinth
#

Same as * 16

#

Wait no

#

/ 16

#

<< 4 is * 16

lethal coral
tender shard
waxen plinth
#

1 is the same as dividing by 2 (rounding down)

quaint mantle
#

nerds man

waxen plinth
#

It's faster than division

quaint mantle
#

by 2

waxen plinth
#

Division is one of the slowest operations a CPU can do

#

Yes

tender shard
waxen plinth
#

Probably not

tender shard
#

because I mean... why wouldn't it do that?

waxen plinth
#

The java compiler makes very few optimizations

tender shard
#

but why

waxen plinth
#

The JVM might

#

But it's an implementation detail

quaint mantle
tender shard
#

yeah anyway the bitshifts are there to turn world coords into the chunk's coords imajin

quaint mantle
#
String a = getSomeString();
return new SomeObject(a);

the bytecode will store a then load a after

#

i think the jvm might optimize this

waxen plinth
#

¯_(ツ)_/¯

#

You don't need to worry about that kind of thing unless you're really trying to squeeze every possible drop of performance out of your code

#

It's a micro-micro-optimization

tender shard
#

yeah same for the bitshifting thing

#

I just used it because I thought "why not"

quaint mantle
waxen plinth
#

Rounding down

#

Or towards zero rather

#

Actually no

#

Rounding down

#

Because of two's complement

quaint mantle
#

twos complement is stewpid

#

i like unsigned

waxen plinth
#

Ok go write everything without negative numbers

quaint mantle
#

i could

waxen plinth
#

boolean negative;

quaint mantle
#

yup.

waxen plinth
#

I bet you'd do that

#

Extra 8 bits

#

Or up to 64 depending on jvm

quaint mantle
#

we need to make an OS that stores booleans as one bit

waxen plinth
#

That would be extremely dumb

quaint mantle
#

ik

waxen plinth
#

boolean[]s though

#

I think the JVM can optimize them into one bit each

quaint mantle
#

if its length % 8 == 0

#

probably

#

🤨

waxen plinth
#

Why would it need to be

#

Just reserve the extra unused bits, it doesn't matter

quaint mantle
#

oh ye

waxen plinth
#

Worst case scenario you've got an extra 7 bits which is the minimum wasted on each boolean otherwise

quaint mantle
#

you should add that into the jvm

waxen plinth
#

The tradeoff is that it's slower to mutate and access the booleans

waxen plinth
humble tulip
#

Booleans aren't one bit?

lethal coral
#

y'know I'm thinking this sphere isn't very good 😂

#

I mean it's fine like I'll still use it, just odd

waxen plinth
#

No, how could they be?

humble tulip
#

0 or 1

waxen plinth
#

The minimum indexable address on any system is 8 bits

humble tulip
#

Really