#help-development

1 messages · Page 342 of 1

lost matrix
#

Then its quite expensive. Get all Blocks around the player (NxNxN dim) and check the distance between the players AABB and every Blocks AABB.
Schedule this. You can greatly improve the performance while losing a little bit of precision by evenly distributing your scheduler over several ticks.

So instead of checking every player every tick you could check 1/3 of all players every 3 ticks in a round robin fashion.

#

?scheduling

undone axleBOT
lost matrix
#

?distro

#

uhm...

remote swallow
#

?workdistro

lost matrix
#

Ah thx

#

Hm you might be able to change the friction of a block type via reflections...

swift lark
#

Sounds pretty complicated but if there's no other way I'll try that. Couldn't I also use the PlayerVelocityEvent? When you touch a honey block you slow down and if I permanently increase the speed of the player the event is called permanently, right?

haughty granite
#

from the config variable, how can I get the withdrawn option?

remote swallow
#

remove the getKeys(true) and make the variable a config section

#

then you can use .getString(path) etc

naive bolt
#

for withdrawn it would be ##.getBoolean("gizeh.withdrawn")

haughty granite
#

indeed it was all stupid, thank you

remote swallow
#

if its aconfig section you dont need the gizeh.

naive bolt
haughty granite
#

but yes it is indeed a boolean

lost matrix
haughty granite
remote swallow
#

yeah

haughty granite
#

I already have the gizeh via the slugItem

remote swallow
#

then call .getBoolean from that variable

haughty granite
#

yes ty

rough drift
#

Understanding it correctly, if I set a Damageable item's damage to 0 it will be at full durability right?

haughty granite
#

no need to set if(config.getBoolean("withdrawn") == true) ?

lost matrix
#

PS: constantly reading and writing from/to FileConfigurations is bad practice

rough drift
#

you should do config.getBoolean("withdrawn", false) though

naive bolt
#

I dont have the block

rough drift
#

as otherwise you risk checking a null value

naive bolt
#

only a vector

haughty granite
lost matrix
rough drift
#

Also, a == returns a boolean, so if you already have a boolean, you can just pass it in

naive bolt
#

im rotating a clipboard

remote swallow
#

just call it once where its needed and make it a variable

rough drift
#

But why?

#

getConfig doesn't reload it you know that right

#

it's just a variable

lost matrix
remote swallow
rough drift
#

It.. it doesn't

rough drift
#

that's what reloadConfig is for

remote swallow
lost matrix
rough drift
hazy parrot
naive bolt
rough drift
#

so it reloads it if it hasn't already

remote swallow
remote swallow
#

someone here had that font

naive bolt
#

minecraft plugin in minecraft font. 100% understandable

mortal hare
#

thats actually pretty cool tbh

rough drift
#

yeah

mortal hare
#

but its probably too big for laptop screens

rough drift
remote swallow
#

@buoyant viper all the letters in mc font

mortal hare
#

it gives me commodore 64 vibe

rough drift
torpid blaze
#

Hey,
How can I code a Player Spawn protection of just half a second?

mortal hare
#

maybe bukkitrunnable with a flag for each player

naive bolt
#

I like this font

mortal hare
#

if flag is set for the player cancel the event

#

if not do not cancel damage event

remote swallow
mortal hare
rough drift
#

I use the Fira Code font

torpid blaze
#

ok, seams legit

rough drift
#

Fira Code Normal*

naive bolt
#

idk how to change actual code font

torpid blaze
#

thanks

rough drift
#

Sexy font

naive bolt
#

thats just side bar and menus

rough drift
#

Nope

#

changes in code too

#

not default intellij

quiet ice
#

I use the standard font supplied with eclipse, which is DejaVu Sans Mono. It's nice

naive bolt
#

must have dogy intelij

rough drift
#

oh

#

what the hell

#

I swear it changes for me

lavish hemlock
lavish hemlock
naive bolt
lavish hemlock
#

Do any of you have the beta UI enabled btw?

naive bolt
#

na

lavish hemlock
#

I think it looks pretty nice

naive bolt
#

dont like it

#

hate it. no meany to the devs

quaint mantle
#

It's alright, just don't like that they collapse the top bar

naive bolt
#

yeah too many more sub menus

lavish hemlock
mortal hare
#
public class SpawnProtectionHandler implements Listener {
private final Set<Player> protected = new HashSet<>();

private final Plugin plugin;
public SpawnProtectionHandler(Plugin plugin) {
  this.plugin = plugin;
}

@EventHandler
public void onPlayerRespawn(PlayerRespawn event) {
  Player player = event.getPlayer();
  players.add(player);
  new BukkitRunnable() -> {
    players.remove(player);
  }.runTaskLater(this.plugin, 10);
}

@EventHandler
public void onPlayerDamage(PlayerDamageEvent event) {
  if (this.protected.contains(event.getPlayer()) event.setCancelled(true);
}

}
#

forgive me i havent wrote for bukkit api for a long time

#

but this is how i easily would implement spawn protection for a half a second

rough drift
#

you typed players instead of protected

#

also you should use player UUID's

#

otherwise this looks fine

mortal hare
#

why use player uuids for protection

#

i need player objects which are online only

quaint mantle
#

for half a second it wouldn't matter

rough drift
#

Because if a player disconnects the player object won't be valid anymore

mortal hare
#

it doesnt make any difference in this case

#

if he disconnects i would cancel the spawn protection anyways

rough drift
#

Also, it removes spawn protection after 0.5s

mortal hare
#

it should be removed

#

tho

rough drift
#

I mean I guess

#

That works then yeah

#

Still would use a UUID because of the hashset

#

I feel like UUID hash is cheaper to calc

mortal hare
#

true

eternal night
#

I mean, a players hashcode is just the uuids hashcode

#

but cached

#

soooo

#

evil people would say, the hashCode() function of a Player might be faster than a UUIDs

rough drift
#

I mean technically

mortal hare
#

it should be weak hashmap because it fails to clean stale uuids and objects or implement the player disconnect event to clean it up manually

#

too

#

its broken code, but i wrote this totally out of my head without any help 😄

rough drift
#

Me on my way to remove a player from spawn protection on spawn:

mortal hare
#

after not doing plugins since august 2022

mortal hare
eternal night
#

yea

mortal hare
#

is it initialized whenever server constructs an object or whenever you call the hashcode func for the first time

#

?

eternal night
#

its a lazy value

#

initialised first when needed

opal juniper
#

im lazy

eternal night
mortal hare
#

i actually never knew that hashcode is cached

#

good to know

#

but it probably depends on the server software fork too

#

since its not spec

eternal night
#

that should be spigot level

#

so, any fork should have that

mortal hare
#

man firefox have improved so much

buoyant viper
#

hashbrowns

mortal hare
#

its so snappy for me

#

and it supports css theming

#

you can make browser ui however you want

buoyant viper
#

has for a long time now

#

userChrome.css go brrrr

mortal hare
#

i use dark magic theme

#

from extension store

#

pretty simple but so nice looking

quiet ice
eternal night
#

what

quiet ice
#

You can't easily fit 128 bits of data into a 32 bit integer

eternal night
#

eh

#

yes

#

but that same issue is on uuid

quiet ice
#

Oh, you're talking about using Players vs UUIDs on hashtables

eternal night
#

yea

mortal hare
#

collisions on hashtables are inevitable unless you have perfect hashing

quiet ice
#

or your input data is less (or equal to) the output data

#

And there is this neat little thing called entity id ...

#

So really one should use an Int2ObjectMap

mortal hare
#

yea but is not persistent afaik it depends on the players render distance, no?

#

EID is used for packets so it should be only for client syncing

quiet ice
#

I thought it would persist throughout the session, but don't quote me on that

mortal hare
#

im not sure tho

quiet ice
#

Since the server says the EID of the player on login

#

Or at least used to, no idea if it still does that

eternal night
#

entityId is not guaranteed to persist throughout a session

#

while spigot right now "ensures" it

#

vanilla re-creates the player when they change dimensions

#

issuing a new entityId

quiet ice
#

smh

rough drift
#

Me on my way to absolutely torture my pc with 2 servers/mcs, a proxy, multiple intellijs, vscode & edge:

rough drift
#

15.2/15.7GB used

#

not bad

#

I can still run ultrakill

quaint mantle
#
 Player player = (Player) sender;
         ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
         BookMeta meta = (BookMeta) book.getItemMeta();
         String bookTitle = ChatColor.AQUA + "" + ChatColor.BOLD + "Guide Book";
         meta.setDisplayName(bookTitle);
         meta.setTitle(bookTitle);
         ConfigurationSection bookPages = this.getConfig().getConfigurationSection("book.pages");
         if (bookPages != null) {
           for (String page : bookPages.getKeys(false)) {
             List<String> lines = this.getConfig().getStringList("book.pages." + page);
             for (int i = 0; i < lines.size(); i++) {
               meta.setPage(i, lines.get(i));
             }
           }
         }
#

idk why for some reason It doesn't work

#

I noticed that bookPages is read as null

#

but I can't figure out why

tawdry echo
#

getConfig return correctly config?

humble tulip
#

book:
pages:
radompage:
- 'stuff in page'

Config looks like this?

#

Send ur config

quaint mantle
#

I didn't check that honestly

#

book:
pages:
- "page1":
- "line1"
- "line2"
- "page2":
- "line1"
- "line2"

#

my config

#

it's created on enable, by the saveDefaultConfig method ...

sharp gorge
#

Feel like this is a dumb question but i cant figure it out.
When i try to do this


                    String world = data.get(buttonworld, PersistentDataType.STRING);

I get an error in console

The found tag instance cannot store String as it is a NBTTagInt```
#

Its 100% saved as a string not an int.

humble tulip
#

It's not config sections

#

Wait no

#

That's not losts of lists

#

I'd advise you use a for loop and get string lists like book.pages.page + i

#

i starts frm 1 not 0

quaint mantle
#

thats what My code does actually

humble tulip
#

No it doesn't

#

Those aren't configuration sections

quaint mantle
#

for (String page : bookPages.getKeys(false)) {
List<String> lines = this.getConfig().getStringList("book.pages." + page);
for (int i = 0; i < lines.size(); i++) {
meta.setPage(i, lines.get(i));
}

#

I don't treat them as config sections

#

pages is a section

#

but it seems like the code is not entering the foorloop because bookPages gets assigned as null

humble tulip
#

-"page1" is not a key

#

A key has : after it

quaint mantle
#

can't it be a string key?

remote swallow
#

idk why you even have it setup like that

#

just add a string, it auto formats it per line

humble tulip
#

Just use sections that are a number

quaint mantle
#
book:
  pages:
    - 1:
      - "line1"
      - "line2"
    - 2:
      - "line1"
      - "line2"
#

like that?

#

so numbers are treated as inetgers or sections?

quaint mantle
dim bluff
#

from https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/#:~:text=Custom PersistentDataTypes and,found here.

Custom PersistentDataTypes and how to use them ?
If you have bigger objects you want to store on your PersistentDataContainer, like UUIDs. For this you can simply create an class that implements the PersistentDataType and use an instance of that class as your PersistentDataType. Note that the returned primitive type has to be of one of the originally provided types in the PersistentDataType interface.

Why can't I just use a String?

#

to store the UUID in this case

regal scaffold
dim bluff
regal scaffold
#

You can if you convert UUID to a string but storing UUID is not the same as storing a string

quaint mantle
regal scaffold
#

You have a bunch of choices, convert UUID to a string and store that, convert UUID to json object string and store that, store the UUID like it shows you in that guide you posted, or use the library I sent

#

It's not

regal scaffold
hazy parrot
#

And may also be representated with 2 longs

dim bluff
#

I was reading about that

hazy parrot
#

As its 128 bits

dim bluff
#

so I could convert

regal scaffold
dim bluff
#

do you know which one of these the library you sent use?

dim bluff
#

since the last one is just an abstraction

hazy parrot
regal scaffold
#

yes

#

Byte array

#

Ty goksi

humble tulip
#

Uuid is also 2 longs

dim bluff
#

so I can just convert UUID to a byte array than just go new String(byteArray, StandardCharsets.UTF_8) to convert it back to string when needed?

humble tulip
#

Yes

#

Or u can store 2 longs

dim bluff
#

To you more experienced friends: do you think this is overcomplicated or it's ok?

humble tulip
#

But if you wanna store in 1 key, go the byte[] metjod

#

No it's ok

dim bluff
#

you usually use it for what?

#

comparison? maths?

#

smth else

#

what's the good uses for the UUID, that's what I mean

vagrant stratus
#

HashMap<UUID, PlayerData> instead of HashMap<Player, PlayerData> is one use case, but you can use it for comparison in general e.g.

player.getUniqueID() == UNIQUE_ID instead of checking the name or display name

winged anvil
#

?paste

undone axleBOT
quaint mantle
#

@humble tulipit still returns null hmmmmmm

dim bluff
hazy parrot
#

it will still be linked to same key, yes

dim bluff
#

I'm particularly traumatized by this because I lost a 50 dolar VIP once because I changed nicks...

vagrant stratus
#

Correct, UUID is constant regardless of player name changes or display name changes

hazy parrot
dim bluff
#

I'll start to aways use it instead of display name, when possible

winged anvil
#

didnt paste cause the bodies wouldnt have been collapsed

dim bluff
#

Thanks tomi, minion, goksi and optic 😄

sterile token
hazy parrot
#

works for me

sterile token
winged anvil
sterile token
#

So what is the issue?

hazy parrot
#

well i personally dont see why would it break srp

winged anvil
#

just seeing if it breaks srp

sterile token
#

srp?

winged anvil
#

ok sweet

sterile token
#

What thats

hazy parrot
#

as every method looks like its doing only one thing

winged anvil
#

single responsibility principle

hazy parrot
winged anvil
#

more of the class

sterile token
#

oh ok

winged anvil
#

not each method

haughty granite
#

does anyone have a price format function?

#

like that ex

dim bluff
#

IIRC

lost matrix
#

I also remember some NumberFormat for currency

lost matrix
# haughty granite like that ex
NumberFormat format = NumberFormat.getCurrencyInstance(); // Should probably a constant
double value = 120.50;
String formatted = format.format(value);
haughty granite
#

awesome I had almost the same thing, thank you very much

#

the fuck???

#

what is this currency symbol??

lost matrix
#

For a dollar sign you probably want the US locale.
"English" does not have country specific data. For that you would need UK or US

#
Locale locale = new Locale("en", "UK");

Should have a pound symbol

haughty granite
lost matrix
#

Yes because ENGLISH is not country specific. Its just a language.

#

And languages have nothing to do with currencies. Countries do.

compact haven
#

^ they speak English in many countries

#

There’s plenty of stack overflow posts going off of the difference between Locale.ITALY vs Locale.ITALIAN

haughty granite
#

I must admit that I hadn't thought about it at all

#

I could have written one of these posts lol

idle loom
#

I am attempting to remove 1 of player's held item when they right click
for some reason this doesn't work

player.getInventory().remove(player.getInventory().getItemInMainHand());```
The event is being fired just fine, everything else works but this
lost matrix
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

haughty granite
#

nothing happens or you get an error message?

idle loom
#

ok hold on, I need to make sure it's not erroring

buoyant viper
#

why wouldnt u check for errors before asking?

#

smh

shut field
#

how do you spawn an entity that you can make shift

#

Ohhh you do setSneaking, my bad

#

I was searching for "crouching" or "shifting" or smth

#

my bad

idle loom
#

ok
player.getInventory().remove(player.getInventory().getItemInMainHand());
Does definitely work, but I'm only trying to remove 1 from the player's hand

#

not the entire stack

#
ItemStack itemInMainHand = player.getInventory().getItemInMainHand();
itemInMainHand.setAmount(1);
player.getInventory().remove(itemInMainHand);```
Also removes the entire stack, instead of 1
buoyant viper
idle loom
#

Thanks, I'll try it

shut field
#

I don't know of any other entity that can shift other than players?

sterile token
shut field
sterile token
#

What are u tyring to do?

shut field
#

I want to spawn an entity that can shift

buoyant viper
#

or use Citizens to make npcs

shut field
sterile token
dim bluff
#

how can I make p.setFlying(true); persist through death with pcd?

#

pdc?

sterile token
#

my bad, i forgot about them

dim bluff
#

so, any idea?

remote swallow
#

make a method that sets it setFlying true and a pdc key to true then on join/world stuff get the value of it and set it

dim bluff
#

gezz that's ugly

#

k

#

thanks

#

thought it had a better option like inbuilt player permissions or smth

sterile token
dim bluff
#

permission to fly

sterile token
remote swallow
#

verano have you smoked today

#

spigot has permissions

sterile token
#

yes i know that

#

But why will be a flying permisison in an api 🤔

dim bluff
#

I mean, it's a game api

#

wouldn't be surprising

sterile token
dim bluff
#

it has a flying permission on the api actually

sterile token
dim bluff
#

sorry

sterile token
#

I mean the property is okay, i dont understand ur point - sorry tho

dim bluff
#

nvm

#

hey, what else can trigger property deactivation besides death and relog?

remote swallow
#

world change iirc

winged anvil
#

?paste

undone axleBOT
winged anvil
sterile token
#

I would make a custom event and trigger it on every block stolen

vale cradle
#

does bukkit pickup interact events on air? Like right clicking air

dim bluff
#

Any idea on why this code isn't working? It's reaching friend.setAllowFlight() correctly, it's just not working, on the same code I wrote p.setAllowFlight() and it worked, so it's not a setup problem

}catch(NumberFormatException e){
    String friend_name = args[0];
    if(Bukkit.getPlayerExact(friend_name) != null){
        Player friend = Bukkit.getPlayerExact(friend_name).getPlayer();
        if(args.length == 1){
            if(!friend.getAllowFlight()){friend.setAllowFlight(false);}
            else{friend.setAllowFlight(true);}
            return true;
        }
winged anvil
#

you should invert your conditions to do an early return for your if-statements lol

hazy parrot
#

which makes no sense

winged anvil
#

example if (Bukkit.getPlayerExact(friend_name) == null) return blah;

#

code readability things

dim bluff
torn shuttle
#

rookie numbers

hazy parrot
dim bluff
winged anvil
dim bluff
hazy parrot
winged anvil
#
    public void onBellRing(PlayerInteractEvent event) {

        Player player = event.getPlayer();

        if (!playerIsInGame(player)) return;
        if (event.getClickedBlock() == null) return;
        if (!interactedWithBell(event.getClickedBlock())) return;

        onPlayerScore(player);
    }``` another example maybe?
torn shuttle
#

always stop the code from executing as soon as possible and never indent code if it's not absolutely necessary

dim bluff
#

nice tip @winged anvil

winged anvil
# dim bluff nice tip <@162698382450753545>

yes, this is what it would like like inverted ``` @EventHandler
public void onBellRing(PlayerInteractEvent event) {

    Player player = event.getPlayer();

    if (playerIsInGame(player)) {
        if (event.getClickedBlock() != null) {
            if (interactedWithBell(event.getClickedBlock())) {
                onPlayerScore(player);
            }

        }
    }
}```
torn shuttle
#

aka the hadouken school of programming

winged anvil
#

yes

hazy parrot
#

->

dim bluff
#
String friend_name = args[0];
if(Bukkit.getPlayerExact(friend_name) == null){ p.sendMessage(ChatColor.RED + "Player not found"); return true;}
Player friend = Bukkit.getPlayerExact(friend_name).getPlayer();
if(friend.getAllowFlight()){friend.setAllowFlight(false);return true;}
else{friend.setAllowFlight(true);return true;}

looking better?

winged anvil
#

yes!

dim bluff
#

haha, thanks again!

torn shuttle
#

you don't need that else statement

dim bluff
#

now i'll do this to the rest of the code... tomorrow... 23 PM now

dim bluff
winged anvil
#

im hoping the braces n stuff is just cause discord lol

torn shuttle
#

the formatting sucks

dim bluff
#

oh yes it sucks

winged anvil
#

yeahh i assumed so

torn shuttle
#

if you are using intellij you can download the sonarlint addon

#

which will yell at you until you either stop caring or become a better programmer

dim bluff
winged anvil
#

yes

dim bluff
winged anvil
#

yes

torn shuttle
#

yes

dim bluff
#

thank god lol

winged anvil
#

nothing major just small bits that'll make code much more manageable

#

will be helpful in the long run

torn shuttle
dim bluff
dim bluff
winged anvil
torn shuttle
dim bluff
winged anvil
torn shuttle
winged anvil
#

basically says the same thing we just had you do but might be more understandable

remote swallow
#

1 nest is acceptable

dim bluff
#

I understood very well

winged anvil
#

0 nesting

dim bluff
#

actually i knew that but i'm kinda rusty

winged anvil
#

i write everything on one line separated by ;

remote swallow
#

You dont null check for loops on an inventory?

winged anvil
#

huh

dim bluff
#

I'd really like to get more tips and talk all night, but I really need to sleep, i'll only sleep 6 hours tonight, please feel free to dm me for tips, i'll really appreciate

torn shuttle
#

I forgot there was even a part of youtube dedicated to learning programming

#

I always thought that was objectively the worst place to learn anything concrete

winged anvil
torn shuttle
#

and he made a video called don't write comments, he's looking to start a war

winged anvil
#

prolly the realest video

torn shuttle
#

I write very few comments, but when I do it's because there's a something someone should really be aware of that is not at all obvious

wet breach
#

I would say, you need to ensure comments are stripped when compiling as in some languages it can add to the size

#

but in regards to working in a team or group setting regardless if its open source or not, comments are really important

#

maybe you don't necessarily need them, but for others to understand it is

torn shuttle
#

imagine the api docs but with no comments

#

that would be fun

river oracle
#

I never comment my code, but I almost always document it

gleaming grove
wet breach
#

if not, then sure working by yourself its completely fine although recommended

river oracle
#

and the documentation was sufficent enough to ensure the team knew what the code did

#

no need to go and comment up everything

wet breach
#

I don't advocate to comment everything

#

but documentation comments and comments are virtually the same thing

#

I can read javadoc comments in source just as easily as a normal comment

#

however sometimes a normal comment is needed for things that are more internal

river oracle
#

only thing I usually comment internally are // TODO: [insert todo here]

torn shuttle
#

any annoying enough issue caused by a third party bug usually gets documented on my end

#

like the existence of fake players

#

for some of the checks or behaviors

wet breach
#

got to love them fake players

#

maybe I shouldn't have told people that such things were possible so long ago 🤔

winged anvil
torn shuttle
#

I also have consistently regretted not doing more exhaustive documentation of my scripting solution

wet breach
torn shuttle
#

mind you it hasn't lead to me actually documenting it, but i do regret it every time

winged anvil
wet breach
#

that isn't always possible or sufficient

winged anvil
#

yes true

#

then comment

wet breach
#

maybe you have duplicate methods, but the reason for it is because there is a catch somewhere

winged anvil
#

yeah if its not obvious then comment

torn shuttle
#

like my script targets system

#

that thing can run at least 5 layers deep from what I currently assume

wet breach
#

where I really would like to see more comments when looking at code

torn shuttle
#

but there's probably more ways to hack it together

wet breach
#

isn't so much on methods, but rather when people decide to create static variables

#

since it isn't obvious sometimes why it is even there

#

commenting on such things like that for example also helps you determine if what you are doing is even really necessary too 😛

torn shuttle
#

the singleton system for game engines makes me want to cry blood

ancient plank
#

My comments are typically just
// TODO: this sucks, pls fix tomorrow
To remind me what I was doing the day before

#

And then there's the javadoc comments

torn shuttle
#

godot has a hilarious singleton system too

wet breach
#

unless you mean everything is a singleton

river oracle
wet breach
#

in which case that would get annoying

torn shuttle
#

no, not everything is a singleton, the implementation of singletons is just downright whacky

wet breach
#

ah ok

torn shuttle
#

basically in godot everything is a node, and so are singletons, you have to manually tell the program to load them on startup but they are just game objects like any other

#

they can run behavior on every frame, they can even delete themselves

wet breach
torn shuttle
#

they are present in the game hierarchy too

wet breach
torn shuttle
#

and if you want to access them you just make a static field of the type the class is and assign it to itself on startup

#

then you access the static field to interface with non-static data

river oracle
wet breach
#

just setup profiles

river oracle
#

I use spigot api for personal projects uwu

torn shuttle
#

so yeah, whacky

#

also not sure I'm a fan of how godot does node scripts in the first place

#

it's not ECS, it's straight up inheritance where the script is the node, and therefore there can only be one script per node

#

dunno, still trying to determine if that's cool or just limiting

wet breach
#

Well interesting that objects can delete themselves

#

or that it is actually normal

#

I mean in C++ you can do this, but it isn't really a design principle you should use and only used in certain situations where the object is only needed for a very short time and then is tossed away

#

in which case an object deleting itself would be advised to just keep resources under control

torn shuttle
#

we're talking about a scenario where realistically a single bullet projectile is a game object

#

you have to be able to get rid of these quickly and easily

#

but then again this scales very poorly in a lot of scenarios as you might imagine

wet breach
#

well sure, but typically you have management systems that would be responsible for such things, also it depends which side we are talking about

#

client side yes you would remove it from screen when its not needed anymore, that doesn't mean that at the same time the server stopped tracking it though lol

torn shuttle
#

I'm talking about game engines here, not client side vs server side programming

wet breach
#

game engines are for both client and server typically if we are not specifying which kind of engine

torn shuttle
#

I mean sure but I am just talking about games in general, not the specific instance where a computer across the ocean is dictating the game logic on your game

wet breach
#

if we are strictly talking about game engines server side, I can see some instances where an object deleting itself is necessary but your example above fits what I stated though

#

typically where you would want an object deleting itself is for those short lived ones that are only created for a very specific purpose and then are tossed away almost immediately lol

torn shuttle
#

I don't think I've ever made a script delete anything other than itself in godot

#

since it's all based on scenes

#

which are prefabs in unity

wet breach
#

well I am not all that familiar with godot so I can't really say on that

torn shuttle
#

even in a basic scene where you are stabbing an enemy there is an appeal in making it so the enemy handles whether it should still be alive after getting stabbed or not

#

ymmv but at a very basic level it should usually work out quite nicely

wet breach
#

one day I might look at it

torn shuttle
#

well it's free and it's the easiest install for game engines out there, considering it comes with a built-in code editor and is a fully portable installation

gleaming grove
#

I guess armorstand.remove() is example of self deleting object

wet breach
#

No, that method tells the world object to remove an entity. The world object has final say

gleaming grove
#

So unity and Godot works in that way

torn shuttle
#

unity isn't exactly the same

#

sort of

#

there's some nuance

wet breach
#

the only way the entity object could decouple from the world object is if the entity object had direct access to the map that the world was maintaining or if the entity object removed its own pointer/reference

#

the latter is basically what is being referred to as a self deleting object

#

where it removes its own pointer/reference in memory

torn shuttle
#

tbf we're getting into semantics here over whether the armorstand is not removing itself if it's deferring map access but has a method to do so inside of the object vs it holding a reference to the map and removing it itself

wet breach
#

lol

torn shuttle
#

who knows, maybe somewhere in the source code the free method for godot also defers access

wet breach
#

well at the very least you understand though 😛

torn shuttle
#

actually it probably does because some of the safer variants of it wait until a frame is done and it would just be silly to leave that up to the object all on its lonesome

wet breach
#

that would make more sense

#

but then again, I don't know godot or what exactly its purpose of creation was for. For all I know maybe someone liked the idea of self deleting objects that they made that it a normality of the language lol

torn shuttle
#

I can tell you they are losing sight of what made them rise to popularity imo

wet breach
#

that sometimes happens as languages mature

torn shuttle
#

I could be wrong because I just got to the party but it seems to be full of people new to game dev and mostly focusing on creating simple 2d experiences, but 100% of the focus for godot 4 thus far seems to be placed entirely on 3d capabilities

#

I guess they can't be known for being a good 3d engine until they develop those capabilities but man they are just not on the same playing field as something like unreal or even unity

#

and it would be weird if they were, considering unreal basically has infinite money at this point and isn't shy about dumping it into making the best engine they can

wet breach
#

don't see anything wrong with that except maybe how they might be going about 3d capabilities. Example being Minecraft. Minecraft doesn't have 3d models, it uses 2d models to then create 3d ones.

#

if that is how they are going about in regards to the engine stuff I could totally see me using such a thing

torn shuttle
#

well the focus on 3d came at a cost, you can't focus on everything at the same time

#

they used to support 5ish different programming languages, they dropped 3

#

including their homegrown visual scripting language which some of the art-focused devs were relying on

wet breach
#

well obviously not, but there is a gap in regards to 3d engines that use 2d models though because like some of the games if I were to make them really wouldn't require a heavy 3d engine and wouldn't really need to have 3d models. And just because you have 2d models doesn't mean you still can't make them look good 3d albeit you have some limitations of course. But the advantage of such an engine like this is you get more performance.

#

but these days though its all about them 3d heavy engines

#

sure they could support 2d models, but like now you have this entire bulky engine for such things that doesn't require all the bulk XD

#

but then again I come from a different era in regards to programming too

#

where optimizing for performance and size was a necessity and I believe it should still be so lol

torn shuttle
#

I mean it's still a necessity, people go for the heavy engines because a lot of the optimization work is deferred to the engines themselves

#

I've played around with some prototypes in unity and implementing LOD was as easy as following the naming conventions for the level of detail of my models

#

and it seems like in unreal you don't even need to do that anymore, they automatically handle LOD for you on a single base high quality model

#

that's a huge time saver, you can even go much higher detail without really having to worry too much about performance if the automated systems work

#

which by the way minecraft really should look into implementing LOD for far away chunks, there is no reason not to do it

#

there's even mods that do it for minecraft and they get stupid high view distances

wet breach
#

since LOD is something that shaders typically support

#

part of the problem with view distance in minecraft is that it is multiplayer and the fact that the server now has to accommodate these large chunk areas for each player. In most games they typically have pre-defined boundaries as well as pre-defined things going on in said boundaries

torn shuttle
#

I don't care if far away chunks have lazy loading that isn't instantly representative of changes, i'd take 200 view distance where things far away might've changed over 8 view distance of 1:1 representation

wet breach
#

I agree, but have to remember these modders have more time then the developers do in regards to any one specific thing

torn shuttle
#

if only this multi billion dollar franchise could hire the modders huh

wet breach
#

if I were to implement it, I would do lazy loading of chunks where entities don't spawn in until like view distance of 10 or something

#

but everything else could be visible

torn shuttle
#

I'm thinking of starting a kickstarter so mojang can afford to add more than five features a year

wet breach
#

Mojang offered them a great deal on purchasing said project, but the developers ultimately declined

#

Mojang wanted to include optifine automatically into the client

torn shuttle
#

they don't need to buy the rights to modded code, they can hire developers to make their own in-house alternative to said code

wet breach
torn shuttle
#

optifine wasn't created by expending the one ring, you can apply the same kinds of optimizations optifine has without ever even looking at it

wet breach
#

so to ensure lawsuits don't happen it is actually typical to purchase the rights and possibly hire the one or ones that created it

wet breach
torn shuttle
#

because it was solved for a single platform and only for people who mod the game in a specific way, which affects <.1% of your userbase

wet breach
#

but simply hiring the modders doesn't really solve the problem either, they could have budget requirements that may not allow for such things

#

and its a gamble in bringing in a modder. Just because the modder created something decent, doesn't necessarily mean they know how to work in a more professional setting or environment

torn shuttle
#

they are a multibillion game studio owned by a trillion dollar business

#

I think they can find some change in the sofa of their lobby

wet breach
#

doesn't mean they have multi-billion dollars to spend

#

remember, most of that billions went to mark/notch

#

doesn't mean minecraft re-made those billions since then

#

and yes, its owned by a trillion dollar valued company, doesn't mean microsoft has a trillion dollars, but regardless it has a lot of money it doesn't mean within the board they approve tossing a few billion at a game lol

#

or should say another few billion, technically the game didn't cost Microsoft that much

#

all Microsoft allowed was for Notch to take what Mojang had in its account really

#

which still counts as purchasing

#

so reality is the Mojang entity probably only has a few million in its accounts to actually really do anything, not factoring in payroll and other bills etc

torn shuttle
#

estimates put the revenue of minecraft at about half a billion yearly, not accounting for merchandising nor other games released under the minecraft banner

#

just game sales

#

and I can guarantee they make more from merch than from the game

#

I think they can spare some change and hire a few more developers

#

I wouldn't be surprised to find out all in all mc made > 1.5bil last year, minecraft merchandise sells really well

wet breach
#

Mojang falls under that branch, and if it was pulling half a bil or anywhere close I would expect it to be reflected in their annual report

#

instead total revenue before factoring anything else in was 198,270mil

#

that is the entire gaming division

#

anyways, I don't disagree with you though in regards that Mojang should implement some stuff, but at the same time when you don't have the funds to spend time on it because priorities lie elsewhere in Mojang, then not much the devs can do. Hiring some modders doesn't really fix the funds part

#

however what is easier to do is buy things though as those are single cost and not perpetual

#

so it makes more sense to buy optifine then to hire the developers of optifine to implement something like optifine. Since the code is already licensed the optifine devs wouldn't be allowed to use the same code from optifine in the MC code base and doing so introduces some legality issues. Like does that mean the developers don't retain the rights of their project anymore because they used code from it in another project they were hired to work on? This is why you buy the rights for a project so that if that does happen its a non-issue anyways as you own it 🙂

#

Anyways, enough of the technical talk in how game businesses get ran especially the larger ones as there is a lot of nuances to it. If anything, you are better off creating a custom MC client then you are hoping that Mojang fixes everything wrong lmao

#

who knows maybe they might make an offer to buy your custom client from you and start using that instead 🙂

tender shard
#

anybody got any idea why this regex doesnt match the empty line?

#

^\s*$ also doesnt match

kind hatch
#

It's valid regex, but I guess IntelliJ doesn't have any way to show it.

tender shard
#

then it marks the whole 283 lines as selected and I expected the search feature to do that too

kind hatch
#

I was also expecting it to highlight things and was confused when I didn't see anything. Then I started clicking the arrows to go through the results and realized.

wet breach
#

fortunately it doesn't appear intelliJ is using those

echo basalt
wet breach
#

typical tab character is \09 however that is if you go by OEM codes. ANSI however has tab listed as \0160

#

regex typically doesn't catch tab as 160

#

fortunately however you can add character codes to your regex

#

^\t\o{0160}*$
^\t\160*$
^\t\x160*$ (sometimes doesn't work)
the preferred way is using \o{} as you can define multiple character points in the curly braces

#

due note if you use a character point code, it is case sensitive too, so like if you think it is a smart way to detect f well the character point for f isn't the same for F lol

wet breach
#

if you want to see the real numbers

#

one of the handy things of corporations that have public stock is the fact they have to disclose earnings

#

downside is they don't have to make it easy nor do they have to separate the revenue of the divisions anymore then what is necessary

#

so you have to use some estimating

torn shuttle
echo basalt
#

Ah man I want a minecraft hoodie now

#

I got all types of mugs, lamps

#

Pajama set

torn shuttle
#

pacifier

echo basalt
#

With the comfiest tshirt ever that I wear to the gym

tender shard
torn shuttle
#

hey illusion I did a 300kg leg press last week

#

by throwing you over that cliff I'll actually be inaugurating the portuguese space program

echo basalt
#

I did those when I turned 15

torn shuttle
#

my legs were busy carrying my league of legends team when I was 15

echo basalt
#

We are not the same

torn shuttle
#

thank god

echo basalt
torn shuttle
#

but yeah the slow path to 400kg continues

echo basalt
#

On the scale?

torn shuttle
#

yeah, pure muscle

echo basalt
#

Ah okay

torn shuttle
#

people say I won't be able to get into elevators, I tell them I'll be pulling the elevator up myself

echo basalt
#

Knockback lifts you up vertically

#

So if you just punch yourself a lot, you should be able to fly

#

Try it out

torn shuttle
#

people pay good money to have the kind of mental trips you find yourself living inside of

echo basalt
#

You forgot the word "avoid"

tender shard
#

this is going to be a huge commit lol

torn shuttle
#

truly there is no length I won't go to to avoid writing four extra lines of code

#

I've been procrastinating writing these lines for 30 minutes trying to think of a way to write fewer lines

wet breach
echo basalt
#

Do I see defeat?

torn shuttle
#

I write long lines, not numerous lines

#

get it right

echo basalt
#

Sounds like copium

torn shuttle
#

I have a grid of 20 by 20 points and I want to draw a line between each

#

there's so many ways of doing it and I hate them all

#

I was thinking about using a modulus and an offset on the y axis to get full coverage without doing any connection twice

echo basalt
#

What about a for loop that connects each index with all indexes ahead of it?

torn shuttle
#

yeah also thought about potentially connecting them all left to right and up to down

echo basalt
#

In a matrix it gets a bit complicated

#

Because diagonals

torn shuttle
#

mostly I'm just annoyed that godot doesn't seem to have 2d circles

#

I think I need some coffee, I'm feeling very lethargic

echo basalt
#

Convert that 2d into 1d

#

By laying all lines side to side so it becomes a big line

#

Then just do the index -> ahead method

halcyon hemlock
echo basalt
#

Love your ign

torn shuttle
#

man godot has a line node but I can't imagine that's any good for performance

#

that's so many lines

#

it allows multiple points so I guess I could just make a vertical column and a horizontal column

#

hmm

#

let's try that

halcyon hemlock
#

what are you guys working on?

torn shuttle
#

I'm procrastinating on the work I should actually be doing of implementing an item upgrade system to my plugin and instead making an abstract wallpaper in godot

halcyon hemlock
torn shuttle
#

you think I play that minecraft nerd shit? never seen it

halcyon hemlock
#

I can help if you need any

echo basalt
torn shuttle
#

I'm a real chad, I steal my design documents from black desert online and very distorted takes on some aspects of runescape

halcyon hemlock
#

lmao

torn shuttle
#

in my item system there is a 1/50 chance that you get teleported to a boss arena and if you die you lose your enchant because you suck

#

also the level of your item gets lowered

halcyon hemlock
#

ah nice

#

im bored af, any ideas on what to make? im currently making tic tac toe, which is basically done

torn shuttle
#

fortnite

halcyon hemlock
#

i have played that game for like 5000 hours man, no more

torn shuttle
#

means you know the reference material

halcyon hemlock
#

lmfao

echo basalt
#

Make bad code that brings you hatred to the world

#

Make friendships

halcyon hemlock
#

already do the bad code part

#

my code has around 3 months gap, one side is really bad and one side is ok

echo basalt
#

Plot twist: both sides are bad

halcyon hemlock
echo basalt
#

Idk

halcyon hemlock
#

literally none of my friend codes plugins

torn shuttle
#

you know, instead of emulating a pseudo-3d space I could've just done this with a normal mesh like a normal human being

echo basalt
#

But you aren't

echo basalt
#

You're special

torn shuttle
#

someone has to have the strength the lift the whole of humanity into its next evolutionary stage

#

truly groundbreaking stuff

#

lines will never be the same

#

where were you when the line was reinvented

gleaming grove
#

em, why does this happens? ``` var block = location.clone().add(0,1,0).getBlock();
if(block.getType().equals(Material.FURNACE))
{
var furnace = (Furnace)block;
furnace.setCookTimeTotal(100);

                }```  ```class org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock cannot be cast to class org.bukkit.block.Furnace (org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock and org.bukkit.block.Furnace are in unnamed module of loader java.net.URLClassLoader @7506e922)

[09:38:43] [Server thread/INFO]: [Exception type] ClassCastException```

#

ok nvm, there should be (Furnace)block.getState();

lost matrix
wet breach
# torn shuttle truly groundbreaking stuff
// C++ Implementation for drawing line
#include <graphics.h>
  
// driver code
int main()
{
    // gm is Graphics mode which is a computer display
    // mode that generates image using pixels.
    // DETECT is a macro defined in "graphics.h" header file
    int gd = DETECT, gm;
  
    // initgraph initializes the graphics system
    // by loading a graphics driver from disk
    initgraph(&gd, &gm, "");
  
    // line for x1, y1, x2, y2
    line(150, 150, 450, 150);
  
    // line for x1, y1, x2, y2
    line(150, 200, 450, 200);
  
    // line for x1, y1, x2, y2
    line(150, 250, 450, 250);
  
    getch();
  
    // closegraph function closes the graphics
    // mode and deallocates all memory allocated
    // by graphics system .
    closegraph();
}

how to easily do it in C++

lost matrix
#

Yeah but in engines like unity and godot there is no component for primitives. So you would
probably need to manually draw vertices there

#

Also Rust > C++
My newest cognizance

torn shuttle
#

it's 9:40 am, I was up all night and for some reason I am trying to figure out how to programmatically generate 3d meshes now

#

I should've just gone to bed hours ago

lost matrix
#

oof

#

3D only works if you have a proper scene setup with a position, direction and FOV. From then on its just
some maths and defining objects in space. But a "3D Mesh" sounds weird

torn shuttle
#

just a plane

#

with several vertices

lost matrix
#

Sounds pretty 2D to me

torn shuttle
#

it sure is, until I start animating the plane in 3d because that's the whole reason I need the vertices

wide coyote
#

why beetroots dont trigger the BlockGrowEvent? which event should I listen to

earnest forum
#

dont you need like a projection matrix

#

this thing

torn shuttle
#

no? in theory all you need is three points

#

at least for the most basic form of it

drowsy helm
#

if you are doing 3d you 100% need a projection matrix

lost matrix
drowsy helm
#

*unless its raytracing

lost matrix
#

Did you register the listener?

drowsy helm
#

keep in mind EventPriority.HIGHEST goes last

#

not first

wide coyote
#

yeah ik

lost matrix
#

Also check all your if statements. The code could stop at any of them

drowsy helm
#

so does the method not call at all?

#

do a quick println

wide coyote
#

it works

#

thanks anyway

lost matrix
#

Also i would recommend:

    @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
    public void onGrow(BlockGrowEvent event) {
      this.autoHarvestManager.handleBlockGrowth(event);
    }

For single responsibility

#

Your listener does more than listen

#

Maybe some checks are fine but the bulk should be propagated

wide coyote
#

okay thanks ill keep this in mind

torn shuttle
#

triangle boi

#

what a beaut

dim bluff
#

@winged anvil @torn shuttle you guys triggered a part in my brain that now is fixated to write clean and readable code

#

as soon as possible i'll post a before and after

lost matrix
# dim bluff as soon as possible i'll post a before and after

Give those a look. Found them a few days ago and i agree 95% with them
https://www.youtube.com/watch?v=CFRhGnuXG-4
https://www.youtube.com/watch?v=-J3wNP6u5YU

I'm a Never Nester and you should too.

Access to code examples, discord, song names and more at https://www.patreon.com/codeaesthetic

Correction: At 2:20 the inversion should be "less than or equal", not "less than"

▶ Play video

It's hard to come up with good names in code, but its also easy to get wrong. By looking at some examples, we can get 80% of the way there. Access to code examples, discord, song names and more at https://www.patreon.com/codeaesthetic

0:00 Introduction
0:31 Variables with a single letter
1:08 Never Abbreviate
2:06 Types in your names
2:36 Units...

▶ Play video
dim bluff
lost matrix
#

former but without abbreviating the player

tender shard
#

TIL I learnt how CraftLegacy & Commodore works

tender shard
#

kinda interesting and so simple at the same time

lost matrix
#

Whats CraftLegacy? Never heard of that

tawdry echo
lost matrix
#

Ah yes. Another fork. Haven't enough of those already.

tender shard
#

or that lets old plugins that use WOOL instead of GREEN_WOOL continue to work

lost matrix
#

Always dreamed of that

tender shard
#

it's been in bukkit since 1.13

#

it's what prints this "Enabling Legacy Material support..." on startup when using old plugins or when forgetting to define an api version

lost matrix
#

"I whish i could write all my plugins using the 1.8 API because its simply superior" <- Me every day

#

Ah i see what you mean now

tender shard
#

basically it reads the whole class file's bytecode (e.g. EntityType or Biome, the bukkit that the plugin accesses), then translates certain constants, and then when a plugin gets loaded without an api version set, the bukkit classloader will throw the modifier version at the plugin's classloader

lost matrix
#

Yes i remember skimming that code.

tender shard
#

it's so simple but also so genius

#

is this proper english? lol

lost matrix
#

Makes sense to me

#

But im also from schländ

sullen marlin
#

Yes

glossy venture
austere cove
#

md do u know how the magic data values work for potions in ancient versions? 👀

winged anvil
dry yacht
#

I had no idea that the NMS class MaterialMapColor existed, which basically stores all base colors from which you can generate the shades yourself. This is probably the most version-independent way of approximating map colors without the use of a deprecated, magic-numbers utility, xD.

tender shard
#

thx

twilit roost
#

I'm using this to hide player from tablist for some players
but this vanishes them completely

how can I make them still render to client?

mortal hare
#

i believe you can hide players from tablist by manipulating scoreboard teams

#

but im not sure, since i havent touched anything minecraft related for a long time

#

that's my bet

halcyon hemlock
mortal hare
#

but if you hide it from tablist using teams of scoreboard api, you hide the physical nametag too

#

so you need to make some kind of nametag alternative, aka rideable armor stands to simulate nametags

tender shard
#

first, use spigot's hidePlayer to hide the player for everyone, then do showEntity (or hideEntity(..., false)) to all players again

#

that MIGHT work

rough drift
tender shard
#

then they would also see them in tab again

dry yacht
# lost matrix Give those a look. Found them a few days ago and i agree 95% with them https://w...

Regarding the section of "putting types in your names" (I know it was about identifiers, not class names, but still): Would you say that prefixing only a few select types with a single letter in order to instantly be able to know their type without having to go to their definition is bad practise? I usually do the following: E<name> for enums, I<name> for interfaces and F<name> for functional interfaces.

I'm kind of really having a hard time on deciding whether I should drop that habit or continue it, as I personally really like it.

dry yacht
tender shard
#

i find it pretty useless. why would you care if something is an interface or a "normal" class, as long you can call the method on it that you need to call?

#

I mean you'd also need to call records RMyRecord

#

SFIMyStaticFinalInnerClass

#

I remember when spigot changed certain classes from interfaces to abstract classes, or other way around. yoU'd have to rename them everywhere in this case

hazy parrot
#

only reason i see for using hungarian notation is when making api to differ api classes (interfaces) and SomethingImpl

rough drift
#

Can I run Bukkit.getPlayer async?

eternal oxide
#

generally yes

rotund ravine
#

maybe, but not a good idea

rough drift
#

Dealing with some blocking operations, and I need to check because if the player disconnects I want to stop the task

#
var plr = getServer().getPlayer(uuid);
if(plr == null) {
    cancel();
    return;
}
```Basically this
rotund ravine
#

Can just hold a WeakReference to that player and if that is null they left.

#

Unless some other plugin holds a strong reference obv.

rough drift
#

Don't know, I just figured checking by UUID is best

ivory sleet
#

Since you’re just querying the map

lost matrix
# rough drift Dealing with some blocking operations, and I need to check because if the player...

In >90% of the cases you dont want to constantly start and stop tasks.
Have one task for all your players and if the UUID isnt in your primary data structure (eg if a player leaves)
then the task doesnt include the player in its iteration. This makes it easier for your initialisation and termination
of players. Usually a manager has onSessionStart(T element) onSessionEnd(T element) which simply
adds or removes the UUID from a data structure and propagates the element to all needed init/cleanup methods.
And you wont have to worry about managing tasks at all. Start once, let it roll.

mortal hare
#

any gradle users here

#

isnt using implementation dependency mode would be more reasonable when building spigot plugin instead of compileOnly one?

#

if so why not

remote swallow
#

implementation is the same as maven compile scope

#

so you would be shading spigot in is the simple answer

tawdry echo
#

can i send infinite title packet or i need to create task because i heare somewhere i can that

tender shard
#

however if another plugin sends a title, yours is gone

#

so you'd want to use a runnable

#

like once per second with fadeIn and fadeOut of 0, and duration of like 2 seconds = 40 ticks

tawdry echo
#

k

icy monolith
#
   public void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        player.teleport(new Location(Bukkit.getWorld("world"), -65, 75, 33));
    }```
Why would this not tp players to th spot when they join?
remote swallow
#

is the even registered and is it annotated

tawdry echo
#

better way to send actionbar is Player#spigot or packet?

mortal hare
#

both are doing the same thing internally (sending the title packet)

#

i would suggest player.spigot version since its cross-version compatible

#

less code to update after each minecraft version = better plugin

icy monolith
#

Wdym registered?

mortal hare
#

you need to register listeners

icy monolith
#

i must register each event?

mortal hare
#

no

#

you need to annotate each method with @EventHandler tag

remote swallow
#

you register each class

#

that has listeners in

icy monolith
#

ah ok

mortal hare
#

and register the listener class using PluginManager class

remote swallow
#

you can just register in onEnable

icy monolith
#

Bukkit.getPluginManager().registerEvents(this, this);
Something like this?

mortal hare
#

yes

icy monolith
#

what does "this" mean btw?

mortal hare
#

there are other ways to do that, but this is one of the easiest

tawdry echo
#

class when you do code

mortal hare
#

this keyword gets the instance of the class

#

you're writing your code

remote swallow
icy monolith
#

In main class

mortal hare
#

it could be implemented inside the main class

#

so this is legal

remote swallow
icy monolith
#

Ok thx

#

what would happen if i change "this" to something else?

#

or a way to use it

#

is it like an argument to a function?

ivory sleet
#

this is a reserved variable within the scope of a class

remote swallow
#

its an instance of that class, if i have a listener in a class called MyListenerClass i would register the event like #registerEvents(new MyListenerClass(), this)

ivory sleet
#

and it points to objects constructed by that class

icy monolith
#

ok

ivory sleet
#

Welp, lets say that

remote swallow
#

thats exactly what i was thinking

ivory sleet
#

basically rousty

#

class A{
void method(A this, Object o){

}
}

remote swallow
ivory sleet
#

The A this part is inferred or implied

#

Therefore we usually don’t write it out

icy monolith
#

ok

ivory sleet
#

But its a reserved variable that contains the value as an object of the class

mortal hare
#

this keyword is very roughly just a private final field of the particular class, that has that class instance its currently executing it

ivory sleet
#

Ye

mortal hare
#

its internal implementation is different from fields

#

but it does the same thing

ivory sleet
#

I had to pick between some other ones, and they all were far worse

icy monolith
#

Ok thx

#

i think i understand it. Mostly its just there bc it has to be there

mortal hare
#

this literally holds this class object, its currently written in

tardy delta
#

Theyshoulve called it deez

mortal hare
#
private int num = 69420;

public void foo() {
  this.num = 0;
  // is the same as
  num = 0;
}
#

but with this keyword you avoid naming collisions

ivory sleet
#

anyway roursty its hard to fully understand what this means if you cant grasp the concept of objects and classes

mortal hare
#

for example if you have a method or constructor args which have the same names as the fields, this keyword helps you by specifying what field you're accessing

mortal hare
icy monolith
#

Class is like a file where you put the code and then inside of it your do the code which is functions and events and by adding events you must add a listener to thoes events and then register them using that line.

#

How i understand it

mortal hare
#

that's half way correct

#

events are not part of class spec

icy monolith
#

well you use a class to define it ig

ivory sleet
#

Yeah in object oriented programming yes

mortal hare
#

its just a way for bukkit api developers to allow you to add specific functionality when something happens

ivory sleet
#

But it doesn’t have to be a class

mortal hare
#

also in OOP we name functions as methods and variables as fields

#

but both names are really accepted because nobody gives a f

icy monolith
#

ok

mortal hare
#

is specific class runtime classpath used whenever you load the class at runtime from different java application?

#

lets say i use custom classloader

ivory sleet
#

A class is more or less also a template for creating a bunch of objects, moreover it can also be seen as a category of things, the class Dog is a category of individual dogs, and is the template to create new dogs.
Then for all variables, a variable also conforms to a type, or well category.
Dog dog; here dog is a variable, or some sort of container, that must contain an object/sample/thing from our class/category Dog. (There are some edge cases like, dog could point to null. But yeah)

icy monolith
#

i started learning 3 days ago so idk a lot of stuff but with help of chatgpt i think i know enough to do some on my own. Allready made an ore regen and force texture pack code just by that. Its just trial and error ig. I was using skript before this, prob dont know what that is.

ivory sleet
#

Nice

ivory sleet
#

As in BlockBreakEvent from bukkit?

tender shard
#

imagine a cupcake is an instance/object and the cupcake form is the class

tawdry echo
#

how can i block item modifing in for example anvil by check nbt custom value

mortal hare
#

i gradually transitioned to java tho

icy monolith
#

So its basicly just a blueprint.

ivory sleet
#

Thats one way to look at it

mortal hare
#

i started with skript, then flavoured it with some skript addons like skript-mirror, and eventually ended up ditching it for java

#

since skript-mirror literally exposes java stuff

tender shard
tender shard
ivory sleet
#

Thing is, its not only just a blueprint

icy monolith
#

is it a blueprint of the code inside of the class or .....

mortal hare
icy monolith
#

or just general actions

pseudo hazel
#

an instance is an actor and the class is its script

icy monolith
#

Instance is the code inside of the class right?

ivory sleet
mortal hare
#

?learnjava

undone axleBOT
tawdry echo
tender shard
tawdry echo
ivory sleet
pseudo hazel
#

there are no events

tender shard
#

however PDC tags stay intact when using anvils

#

oh you just wanna prohibit to use an item in the anvil when it has your data?

#

yeah then just prohibit it from being put into the anvil

pseudo hazel
#

oh so it like copies the data from the first item and adds the stuff from the second item to it?

tender shard
river oracle
#

Do it lol

#

Id love to send that to people

hasty prawn
#

Please do it

icy monolith
river oracle
#

Uhhh I mean you could make a dispatcher than make a function to call within that dispatcher

#

But you need to have a listener somewhere

#

Java is inherently oop so I don't understand howd you do much of anything without objects

icy monolith
#

Well me too

#

idk

#

its wierd but it works

#

so i dont tuch what allready works

river oracle
#

Just stick to oop principles

#

When you code

icy monolith
#

Is it like classes in python?

#

Wait nvm

icy monolith
#

that wouldnt make sense

#

Is it possible to put all of my code under one class? It wouldnt look good, but just asking so ik if that is possible

river oracle
#

I mean sure but like no one would ever use your code and it'd be impossible to maintain

opal juniper
#

whats the best way for saving resources without the annoying:

river oracle
remote swallow
#

saveResource("somethinginresource.yml", false)

hasty prawn
#

Or y'know just check File#exists first

remote swallow
#

that too

opal juniper
#

could do that Ig

opal juniper
#

wait thonk

river oracle
#

I've never seen that before this is my save method no clue tbh

public static void saveConfig(final Plugin plugin, final FileConfiguration config, final String name) {
        try {
            config.save(new File(plugin.getDataFolder(), name));
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
knotty meteor
#

Is it possible to add a enchantment on a player skull itemstack to make it "glow"

remote swallow
#

yeah

pseudo hazel
#

sure

remote swallow
#

just add it like normal

river oracle
#

Add like sharpness 500 to it or something to make it fun too

pseudo hazel
#

lmao

remote swallow
#

doesnt work in 1.17 or higher

#

they capped it to 255

pseudo hazel
#

i usually just add unbreaking 1 lol

remote swallow
#

its very sad that we lost 32k enchants

fluid river
#

anybody has snakeYaml experience?

knotty meteor
#

Its weird because it is not glowing the skull itself, i use EpicRename with /glow but it dont give the skull glow but it gives kind of the effect because the name is blue

fluid river
#

how can i basically make this work

knotty meteor
#

I also tried another glow plugin, but same iddue

fluid river
#

now it's just meh

echo basalt
#

it's client-sided behavior

knotty meteor
#

Ooofff

echo basalt
#

I discovered that like

#

on my first ever commission

#

YEARS ago

#

sad that mojang hasn't fixed it yet

knotty meteor
#

I never tought of it until i wanted to make a armor set wit hthis skull non enchanted and enchanted, but the skull wont glow

#

So oof it is not possible then :(

icy monolith
#

Objective objective = scoreboard.registerNewObjective("1", "2", "3");
Cannot resolve method "registerNewObjective"

pseudo hazel
#

is that the correct way to use it?

icy monolith
#

registerNewObjective​(@NotNull String name, @NotNull String criteria)

#

when i do quick fix

#

it makes an objective

#

idk what now after it makes it

#
    }```
pseudo hazel
#

wdym?

calm falcon
sacred prairie
#

Hi, im trying to spawn a sleeping npc but somehow, when i execute the code, nothing happens. I use version 1.19.3 remapped. This is my code:```java
private ServerPlayer spawnNPC() {
ServerPlayer PP = ((CraftPlayer) player).getHandle();

    String[] skin = fetchSkin();
    String texture = skin[0];
    String signature = skin[1];
    GameProfile gameProfile = new GameProfile(UUID.randomUUID(), player.getName());
    gameProfile.getProperties().put("textures", new Property("textures", texture, signature));
    MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
    net.minecraft.server.level.ServerLevel world = ((CraftWorld) player.getLocation().getWorld()).getHandle();
    ServerPlayer entityPlayer = new ServerPlayer(server, world, gameProfile);
    entityPlayer.setPos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());
    PlayerTeam team = new PlayerTeam(
            ((CraftScoreboard)Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(),
            player.getName()
    );
    team.setNameTagVisibility(Team.Visibility.NEVER);
    List<Packet<?>> packets = List.of(ClientboundSetPlayerTeamPacket.createRemovePacket(team), ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true), ClientboundSetPlayerTeamPacket.createPlayerPacket(team,
            player.getName(), ClientboundSetPlayerTeamPacket.Action.ADD));
    entityPlayer.setPose(Pose.SLEEPING);
    for (Player on : Bukkit.getOnlinePlayers()) {
        ServerPlayer eP = ((CraftPlayer) on).getHandle();
        ServerGamePacketListenerImpl p = eP.connection;
        p.send(new ClientboundAddEntityPacket(entityPlayer));
        p.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, entityPlayer));
    }
    return entityPlayer;

}```