#help-development

1 messages ยท Page 2023 of 1

lavish hemlock
#

Two things:

  • Keep it simple, stupid.
  • "Premature optimization is the root of all evil." -Donald Knuth
hasty prawn
#

Could make an item builder method

#

Or class

#

Whatever floats ya boat

quaint mantle
lavish hemlock
hybrid spoke
#

BasicCrateMaker BasicKey

#

why is the B uppercase

lavish hemlock
#

Basically, JD

#

Optimize when you can tell there's a problem with performance

hasty prawn
#

^

quaint mantle
#

alr

#

ill leave it be then lol

hybrid spoke
#

never

#

don't do that

smoky oak
#

guys?

hybrid spoke
#

optimize where you can when it works

#

dont try to optimize while making it work

lavish hemlock
#

That's what I meant

hasty prawn
#

I mean the quote does say that given an opportunity, you should optimize the 3%

#

But it's not the most important thing

lavish hemlock
#

Although actually

hybrid spoke
#

optimization can already be the simplest refactoring what has in the most cases nothing to do with the performance

lavish hemlock
#

It is kind of a good idea to fix some performance issues when they arise, since they can affect testing

#

Like

#

If it takes 5 minutes to test something when it should only take 30 seconds...

#

Yeah

hasty prawn
#

I suppose that depends on a case by case basis though

viral crag
#

you mean the remapped -mojang ?

fallen agate
#

. (no ping)

smoky oak
#

can someone answer my question now...

viral crag
opal juniper
#

he does

hasty prawn
#

Probably the releases page

viral crag
#

do you have another one? ๐Ÿ˜†

hybrid spoke
smoky oak
#

if releasing on spigotmc, use github releases or github download link as resource link?

viral crag
hybrid spoke
viral crag
#

releases would be the better choice

smoky oak
#

thank you

viral crag
#

do you have github setup for it though?

smoky oak
#

yes

viral crag
#

there you go, then it should handle updates for you - or atleast that is the purpose of github releases

fallen agate
#

Is there any api where I can check the latest version of spigot and build it when it releases?

ivory sleet
#

GitHub actions ๐Ÿ˜Œ๐Ÿ˜Œ๐Ÿ˜Œ

fallen agate
#

Oh yeah

ivory sleet
#

Oh yeah that wasnโ€™t to you specifically

fallen agate
#

lol

ivory sleet
#

But just needed to shout GitHub workflow out

visual tide
#
public static 
        void main(String agrs [])
hasty prawn
#

agrs... How dare you.

fallen agate
#

also... strange question but can I not use NMS? I'm trying to spawn a village

#

It's annoying

visual tide
#

oh wow

smoky oak
#

unless you use libraries

visual tide
smoky oak
#

oh on that topic

lavish hemlock
#

Funnily enough, the stdlib uses This shittyStyle[] pretty commonly.

smoky oak
#

anyone knows why datapacks suddenly broke from 1.18.1 to 1.18.2?

viral crag
#

forward or backwards?

smoky oak
#

I can't start my perfectly fine 1.18.1 server in 1.18.2 unless i remove the datapacks

#

one sec imma dig up the logs

viral crag
#

I mean were they built against 1.18.2 or an earlier version?

smoky oak
#

1.18 i believe

#

?paste

undone axleBOT
lavish hemlock
smoky oak
#

wait

#

is spigot GPL 2 or GPL 3

viral crag
#

thats just a warning btw

smoky oak
#

no it literally doesnt start

viral crag
#

thats not the cause

smoky oak
#

the only thing i changed was removing the datapacks

hasty prawn
#

Maybe one of the tags got changed? Maybe check the 1.18.2 change logs and see if there were any changes

smoky oak
#

that's literally the last message in the log

viral crag
#

java.util.concurrent.ExecutionException: com.google.gson.JsonParseException: Error loading registry data: Not a tag id a missing tag id itself is not enough to stop from loading

smoky oak
#

server crashes after that

#

no further messages or warns

viral crag
#

and,.... that doesnt mean thats where it crashed

smoky oak
#

dude

#

there's literally two messages in the log

hasty prawn
smoky oak
#

[08:40:24] [ServerMain/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
this and the other

#

after that

#

ded server

hasty prawn
#

LOL

#

How many datapacks do you have Moterius

tardy delta
smoky oak
#

also is it normal to get 1 download per 3 minutes on your first plugin

tardy delta
hasty prawn
#

1 file?

smoky oak
#

yep

#

wel

#

one zip file

hasty prawn
#

?paste it

undone axleBOT
hasty prawn
#

The Json files

#

Or mcfunction whatever it's called idek

smoky oak
#

it's amplifed nether

hasty prawn
#

Oh

smoky oak
#

but again

#

start message

#

error message

#

dead server

#

and removing the datapack 'fixes' it

viral crag
#

and the system log says java process is being killed

hasty prawn
#

Well, check the change logs then and see if something was modified.

smoky oak
#

it says something about changing from datapack v8 to v9

#

and about allowing the use of tags instead of id

dire salmon
#

Ah nonitro

hasty prawn
#

And you need to update the version

smoky oak
#

thats not my datapack

hasty prawn
#

You can still change it

#

Either you have to update it yourself or wait for the developer to do it and release it

crimson terrace
rich inlet
#

How do I show a subtitle to a player? This doesn't show anything:
player.sendTitle("", "ยง6Subtitle!", 5, 12, 3);

smoky oak
#

i expected exactly one download

#

from the person that wanted it

crimson terrace
viral crag
#

lots of people collect bugs and exploits

smoky oak
#

intentionally made bugs?

viral crag
#

yup

smoky oak
#

well then

rich inlet
crimson terrace
rich inlet
#

Everything else around this line works just fine, there is also no console error

viral crag
#

where are you sending it?

crimson terrace
#

what did you assign player to yeah

rich inlet
#

public void onRightClick(PlayerInteractEvent event) { Player player = event.getPlayer(); //.... }

crimson terrace
#

any if statements?

#

send the entire method if possible

rich inlet
#

Yes, but every other line of code within the if statement gets executed perfectly

viral crag
#
Sends a title and a subtitle message to the player. If either of these values are null, they will not be sent and the display will remain unchanged. If they are empty strings, the display will be updated as such. If the strings contain a new line, only the first line will be sent. All timings values may take a value of -1 to indicate that they will use the last value sent (or the defaults if no title has been displayed).
#

might want to put a space or non display char for title

rich inlet
#

I can try that

crimson terrace
#

well its not a null value but an empty string

#

so it should still work

rich inlet
#

I thought so too

viral crag
#

should, i do not trust java in that respect though

rich inlet
#

Works with " " :)

#

Thank you all! :)

viral crag
#

your tick times are also awfully short

rich inlet
#

I know but thats intentional

viral crag
#

okay, 1/2 a second might not show on some clients

crimson terrace
#

its a full second

rich inlet
#

20 ticks = 1 second

crimson terrace
#

including fade in and out

viral crag
#

ah yeah

#

i was only looking at the stay

rich inlet
#

Thanks @crimson terrace and @viral crag :)

crimson terrace
#

np, couldnt expect an empty string to be equal to null in that method

viral crag
#

well ...

In Java programming, null can be assigned to any variable of a reference type (that is, a non-primitive type) to indicate that the variable does not refer to any object or array.

A String in Java is actually a non-primitive data type, because it refers to an object. The String object has methods that are used to perform certain operations on strings.
#

so based on that you can assign a null to a string

crimson terrace
#

you can assign null to a string

lavish hemlock
#

Strings are just โœจ special types

crimson terrace
#

but "" is not null

lavish hemlock
#

Yeah

crimson terrace
#

"" is an empty String

viral crag
lavish hemlock
#

Well

crimson terrace
#

its an object of the type String

#

which is not null

lavish hemlock
#

Any string literal should never return a null value

crimson terrace
#

unless im returning to monke

lavish hemlock
#

That would likely be a fault of the compiler

#

(I don't even know how the compiler would mix up ldnull and ldc)

#

So, even if it's not bound by the JLS/JVMS, it is still practical that "" is not null

crimson terrace
#

String string = null; //a null object, string == null returns true
String string = "" // an empty String, string == null returns false

lavish hemlock
#

If "Hello, World!" can't return null, neither should "" as "" is no more special than "Hello, World!"

viral crag
#

"We consider a string to be empty if it's either null or a string without any length." is from Baeldung

lavish hemlock
#

Yeah but that's empty, not null.

#

It's not "String is null if without length"

crimson terrace
lavish hemlock
#

^

#

Also a lot of shit would break if "" returned null

#

It is typical to use an empty string when one wants to avoid nullability issues but also pass an empty value

viral crag
#

From Java 7 onward, the recommended approach is to use the String.isEmpty() method to check for an empty string in Java. To avoid NullPointerException

lavish hemlock
#

isEmpty() does not avoid NPEs

viral crag
#

i am aware

lavish hemlock
#

Neat fact though

#

Kotlin's type system allows isNullOrEmpty() to exist

crimson terrace
#

i think that String.isEmpty() method is just there so that its neat XD

lavish hemlock
#

Yeah, I'm pretty sure it's the equivalent of s.length() == 0

#

Later versions of Java have isBlank() as well iirc

crimson terrace
#

s.equals("")

lavish hemlock
#

which also applies to situations like " "

viral crag
#

it is likely there because I cant find a rule in java that actually states what it is supposed to be

ancient plank
#

null is my love life

crimson terrace
#

in one sentence you described perfectly what I couldnt in like 5

crimson terrace
smoky oak
#

to the guy who invented null

#

thanks for nothing

viral crag
#

all I really know is that empty may or may not be null, but it will never be false

smoky oak
#

in true programmer fashion

#

i stole it

#

nah most of that is original at this point

#

oh scrape

viral crag
#

true programmers concurrently develop

smoky oak
#

im getting creative

crimson terrace
#

๐Ÿ˜‚

smoky oak
crimson terrace
#

I saved that crap, its pure gold

smoky oak
#

which answers the question not

raw ibex
#

what's the event for when someone right clicks a bock

viral crag
#

that was book and not block ?

raw ibex
#

lmao

ancient plank
#

doesn't matter if its a book or a block

#

either way it still uses the interact event

viral crag
smoky oak
#

there's a lotta stupid things in CS

#

ASCII everyone

crimson terrace
#

wait is that true?

#

I think someone is laughing their ass off every day for having done that

smoky oak
#

probablz

#

on a more serious note

#

how do i initialiye an emptz emum set

crimson terrace
#

damn you slipped over a letter didnt you

smoky oak
#

_

#

wait

#

someone changed mz kezboard language

#

better

viral crag
#

the bock broke em

crimson terrace
#

nice

smoky oak
#

anyways

#

empty enum set?

crimson terrace
#

the power of bock compells you

smoky oak
#

yep

#

i think that's the first time i used SomeClass.class in code

viral crag
#

@smoky oak is that your clone in help-server?

smoky oak
#

im unsure what you mean so probably no

viral crag
#

same tag-id error from datapack

smoky oak
#

could be

#

dont remember

kindred valley
#

how can i take the dropped item in dropevent

smoky oak
#

event.getItemStack or something like that

undone axleBOT
kindred valley
#

this does not work with isSimilar method

viral crag
#

you should link us to the 1.7 api so we know what exists

crimson terrace
#

masochists

viral crag
#

aha!

tardy delta
#

is there some class that wraps a number and a timeunit?

kindred valley
crimson terrace
viral crag
smoky oak
#

can you escape an if?

crimson terrace
#

break;

#

I believe

tardy delta
#

escape?

#

return?

smoky oak
#

that ends the function

crimson terrace
#

I think break; might work

kindred valley
tardy delta
#

if else is something

smoky oak
#

nope

tardy delta
#

you can only use break in a loop

#

if else lol

kindred valley
#

dont use while ๐Ÿฅด

crimson terrace
#

continue;?

tardy delta
#

thats loop thing too

undone axleBOT
quiet ice
#

continue is perfectly valid

#

though I am new to the convo so idk

kindred valley
#

๐Ÿฅด

quiet ice
#

If there is any context to this disregard my statement

viral crag
kindred valley
tardy delta
#

lol while(false) is an unreachable statement but if (false) is not

crimson terrace
#

thanks but no thanks, just never had to use continue, so never knew it only worked on loops

kindred valley
#

but limited

crimson terrace
#

i know

#

anyway, an attemptto answer it

tardy delta
#

๐Ÿ˜ณ

crimson terrace
#

int?
thats a powerplay

quiet ice
#

at that case you could just go with a while(true) loop

tardy delta
kindred valley
quiet ice
#

"" is a blank string and null is a null object

#

You cannot invoke any methods on the latter

#

But I think you know that already

kindred valley
#

yes, actual minecraft arenapvp on 1.18.2

#

cool

viral crag
#

well, i belive at least spigot 1.8.8 is patched against log4j

quiet ice
#

If 1.8 wasn't to crash that often I would recommend it - but right now I cannot

#

And custom clients make the crashing even worse. Like seriously, how can one fuck up that hard

#

You have like an entire decade to develop a stable application on a stale codebase and yet they fail doing that

#

like not crash minecraft but crash ALSA

kindred valley
#

or do i can?

quiet ice
#

(I have no idea how mc manages to crash ALSA however)

#

Should report it to the maintainers but eh, too lazy

quiet ice
#

PDC or other metadata (NBT?) comes to mind here

viral crag
crimson terrace
quiet ice
#

On spigot that is

crimson terrace
#

lore comes to mind, so does the ScoreboardTags

quiet ice
#

Some forks probably have backported that api

#

lore isn't a good idea, even if it can be used for that thanks to legacy strings

tardy flame
quiet ice
#

Probably not as that looks like a C-style enum constant

tardy delta
#

writing a discord bot kekw

#

stopped using the api for months and now i have to relearn everything ๐Ÿ’€

crimson terrace
#

just remember to .queue() the messages you send via the bot๐Ÿ˜›

glossy venture
#

is there a way to include a folder following

+ libraries // root, i want everything in this folder to be included
  +- com
    +- example
      +- foo
        +- foo-6.9.1.jar

as a repository in gradle?

ivory sleet
#

jda yikes

glossy venture
#

the problem is that there are no poms

#

so i dont think a maven repo is possible

ivory sleet
#

yep

tardy delta
ivory sleet
#

you can declare a flat directory repository

viral crag
crimson terrace
glossy venture
quiet ice
glossy venture
#

oh

ivory sleet
#

uh well

quiet ice
#

Poms are totally optional depending on your resolver

#

Of course it is better to have them however

tardy delta
glossy venture
#

ok thanks ill look into it

ivory sleet
#
this.dependencies {
  this.flatDir {
    this.dirs('com')
  }
}

this.dependencies {
  this.compileOnly name: 'FileWithoutDotJar'
}```
#

unsure if it works for nested dirs

viral crag
#

why dont you pull the maven into gradle the normal way?

ivory sleet
#

but else just walk the directory down and add each as a flat directory

glossy venture
#

ok thanks

#

wait is there a way to create a custom repository

#

with a custom resolver

quiet ice
#

gl, don't try that

glossy venture
#

ok i will try

quiet ice
#

Either you are writing tons of groovy or create a gradle plugin

viral crag
#

seems like a lot of extra monkeying to pull/put a project locally and then access it directly

ivory sleet
#

kotlin dsl x)

glossy venture
#

i want to include the libraries folder from the minecraf tserver directly

#

i have a 1.18.1 dev server

#

so i can just get it from there

ivory sleet
#

I mean gradle doesnt have a java dsl

#

and the groovy dsl just straight out is ass

quiet ice
#

compileOnly files("build/obftools/intermediary.jar")
^ but calls such as this one allows to include any arbitrary file

ivory sleet
quiet ice
ivory sleet
glossy venture
#

i can just make a function that maps a string like com.example.foo:foo:6.9.1 to <dir>/com/example/foo/foo-6.9.1.jar

quiet ice
#

Sadly eclipse does not support kotlin gradle (WHYYYY)

glossy venture
#

and then use that

ivory sleet
#

yeah orby

ivory sleet
tardy delta
#

i forgot but is HashMap#put overriding older pairs with the same key or not?

glossy venture
#

how hard can creating a custom repo be tho

#

:)

ivory sleet
#

like kotlin got some god ascend features as well as some questionable things, its like yatopia basically

quiet ice
#

there is apparently a plugin that adds support for it, but last time I installed it everything has gone south.
Nowadays I am starting to maintain my own build tool anyways so now it's only an issue with 3rd party repos at which point using intelliJ can't be that bad

tardy delta
#

owh right it is

quiet ice
#

if you want one that doesn't you are looking for putIfAbsent

simple anvil
#

how do i read the contents in a txt file and put them in a book?

crimson terrace
#

BufferedReader I believe

river oracle
#

Buffered Reader would be a good option for reading from a text file

worldly ingot
#

Eclipse does have a Kotlin plugin which should allow you to write gradle files in Kotlin

#

Though really if you're writing in Kotlin, you're better off using IJ anyways

#

and that's coming from an Eclipse user

simple anvil
crimson terrace
#

standard java

river oracle
simple anvil
#

kk

river oracle
#

Look it up google is your bestie

crimson terrace
#

StackOverflow is great

simple anvil
river oracle
#

Hmhm

quiet ice
#

java.io.BufferReader or something like that

#

If you want to use nio, there is Files.newBufferedReader(Path)

rich inlet
#

Hi, my PlayerInteractEvent (when stepping on a pressureplate) is called way too often, I want it to call only once when you step on it. If you leave the pressure plate and step on it again it should be called again. But right now it spam-fires the event when you're standing on it. Is there a simple solution?

quiet ice
#

player move event perhaps

rich inlet
#

`
private final HashSet<UUID> activated = new HashSet<>();

@EventHandler
public void OnPressurePlateStep(PlayerInteractEvent event) {
if(event.getAction().equals(Action.PHYSICAL)) {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
if(event.getClickedBlock().getType() == Material.LIGHT_WEIGHTED_PRESSURE_PLATE) {
if(!activated.contains(uuid)) {
activated.add(uuid);
//code
}
}
}
}`
Thats my code so far

rich inlet
vivid parcel
#

Hello, I'm starting with spigot and a little with java and I don't understand where this error comes from, could you help me pls

#
public CommandMap getCommandMap() {
        try {
            if (Bukkit.getPluginCommand() instanceof SimplePluginManager) {
                Field field = SimplePluginManager.class.getDeclaredField("commandMap");
                field.setAccessible(true);

                return (CommandMap) field.get(Bukkit.getPluginManager());
            }
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }```
crimson terrace
#

what is the error

tiny wolf
#

if I send a packet of setting an item in an inventory, I assume that none of the events of bukkit would work with it right ?

quiet ice
#

It's only called at most once a tick per player

#

And the event handling overhead it minimal

vague swallow
rich inlet
#

As you see, I have a hashset where I add the UUID of a player when he steps on the pressure plate, and if he calls the event again and he is in the activated set, it doesn't execute the rest. now how do I remove him again, when he steps away from the pressure plate?

crimson terrace
vivid parcel
crimson terrace
#

well

#

because it is

#

inconvertible types I assume

quiet ice
vivid parcel
#

So what i have to do XD

crimson terrace
#

and it always depends on how many players it runs for

quiet ice
#

You are underestimating the speed for a CPU

crimson terrace
#

youre underestimating the amount of plugins people have on their servers

quiet ice
#

With minimal amounts of allocations and carefully chosen data types everything is really fast

ancient jackal
#

I know it says you should not access Bukkit API when async but... is calling an event from another thread bad?

quiet ice
#

It depends

#

Also, in this case checking whether a player moved from a pressure plate is going to be a call that takes a few nanoseconds at most

glossy venture
#

why is it complaining

#

about the variable

quiet ice
glossy venture
#

it says no candidates found for method call 'minecraftLibraries'

smoky oak
glossy venture
#

groovy

#

in build.gradle

quiet ice
#

there is probably no FolderArtifacts#find method

glossy venture
#

there is

#

i made it

#

ok it works now

#

i love gradle :)

rich inlet
viral crag
#

are you not only affecting the objectives you set?

#

so you would only get the objectives you want on/for each

ivory sleet
#

^

#

ugh

#

from what I know you use one scoreboard instance

#

but you create more than one objective

#

and then change display slots for each one of them

glossy venture
#

it worksl

ivory sleet
vivid cave
#

hey guys, i'm using an interpreter called beanshell to debug java code interactively
But why do all the spigot/bukkit/paper methods are inherited from craftbukkit/nms kinda classes?
They do implement the same fields (more or less) in general, but still sometimes it's different

#

I'm assuming that this is made possible thanks to reflection right

#

So is there a way to reflect the actual classes (and not the underlying ones)?

#

maybe setting the classpath for beanshell or sth would do the trick? I really don't know

#

as you can see it returns a CraftPlayer, instead of an org.bukkit.entity.Player

tardy delta
#

org.bukkit.entity.Player is an interface

quiet ice
#

CraftPlayer implements Player so no issue there

vivid cave
#

yeah, this was just an example

quiet ice
#

You can act as if it is a regular bukkit class

vivid cave
#

sometime it's annoying though cuz it misses fields

sacred mountain
#

currently i have a problem with dealing customized damage to all entities hit by a fireball.
my code works for the functionality part but i dont know how to cancel/remove the damage taken from the original explosion and then set the damage to my custom amount.

quiet ice
#

Why would it ever miss any fields?

sacred mountain
#

the event im using is the EntityExplode as i need to get total values for one explosion.

quiet ice
#

Bukkit is mostly built around interfaces so there are going to be few of them. And the few fields that you do have are private

sacred mountain
#

i tried using entitydamagebyentityevent but i couldntget it to work properly

vivid cave
#

I don't know, okay here is another example
When i use nms on beanshell, its fields are obfuscated, but as you know with mojang mappings, obfuscation is almost removed, just like when i code the plugin

quiet ice
#

cancel the event?

sacred mountain
#

could i just get the entities last damage cause and remove that from the total damage dealt? idk

quiet ice
#

You can cancel the damage event

sacred mountain
vivid cave
quiet ice
#

Which kind of fireball are you talking about?

sacred mountain
#

livingEntity.damage(truncatedRandomDamage - livingEntity.getLastDamageCause().getDamage());
prolly wrong but just an idea

sacred mountain
quiet ice
#

Also why not rethrow the explosion event?

sacred mountain
#

i dont get what u mean

quiet ice
#

?jd-s

undone axleBOT
sacred mountain
#

rethrow the event? why would i

sacred mountain
quiet ice
#

Actually, I thought that there is a entity damage boolean there

#

Turns out there is only a fire boolean

sacred mountain
quiet ice
sacred mountain
#

yeah the isincendiary

vivid cave
sacred mountain
quiet ice
#

Oh, you are complaining about fields being obfuscated?

sacred mountain
#

im already using something like that for my event but

quiet ice
#

Do you want to damage entities or not damage entities?

sacred mountain
#

damage them

#

with my own damage amount

quiet ice
#

?jd-s

undone axleBOT
sacred mountain
#

but i want the original damage from the fireball to be cancelled

#

but when im using the entityexplode event it has nothing to do with damage so im wondering if theres a way to get the damage dealt from the entities idk

quiet ice
runic gyro
#

how can i install datapacks for spigot to work on aternos?

sacred mountain
#

damageEvent.setDamage(truncatedRandomDamage);
this

sacred mountain
#

so that would damage the entity>?

#

bruh ok im dumb

runic gyro
#

how can i install datapacks for spigot to work on aternos??

runic gyro
#

so sadddd

sacred mountain
#
  1. aternos brh
  2. datapacks arent spigot
  3. plugnis are managed by aternos iirc
#

i dont think you can add custom ones

runic gyro
#

what server like not aternos are u recommending>

sacred mountain
#

i might be wrong its been years since ive used aternos idk

sacred mountain
#

is better than aternos

runic gyro
#

what?

sacred mountain
#

100%

runic gyro
#

hiw

#

how

sacred mountain
#

aternos gives you 2gb bro

ancient plank
quiet ice
#

But really unless you deobfuscate the jar (TinyRemapper) or obfuscate your reflection calls (probably not tiny remapper, but the same idea still applies) you aren't going to solve your issue @vivid cave

sacred mountain
#

i highly doubt you have less than 2 gb of ran

quiet ice
#

2 gb is quite a lot actually

sacred mountain
#

not for newer versions

ancient plank
#

my dev server runs on 2GB

vivid cave
sacred mountain
#

yeah dev but i think they arent making stuff

runic gyro
#

๐Ÿคจ

sacred mountain
#

port forwaring

#

ding

quiet ice
sacred mountain
#

theres like 600 thousand tutorials on youtube just search it

runic gyro
#

ok then

ancient plank
#

used it as an smp with 40 ppl on 1.16 and used it as an smp with 10 ppl on 1.18 02_shrug I'm just magic

vivid cave
# quiet ice What exactly do you mean there?

as i told you, using beanshell doesn't output me the same object types that i would code them in; example Player is returning CraftPlayer
And the nms classes i'm using seem to be one abstraction higher in the sense that they are obfuscated, as the nms classes in my code work very fine with their new mapping

lost matrix
vivid cave
#

so i'm wondering whats causig that

woeful crescent
#

will setting the meta of an item in a player's inventory update that item?

river oracle
#

Fr

lost matrix
ancient plank
#

hamachi is one

#

that's what I used most

lost matrix
#

Yes. That piece of invading garbage

quiet ice
vivid cave
#

understanding this may help me understand my nms issue

quiet ice
#

Player is the interface, CraftPlayer is the implementation

vivid cave
#

in my code i deal with Player, not CraftPlayer

quiet ice
#

Basically any CraftPlayer instance is a Player instance. YOu cannot have raw Player instances due to how java behaves

#

It is safe to either just checkcast all craftplayer instances to player instances or to just not cast them in the first place since the JVM does not really care about such details

#

Example for this would be

public interface Itf {

}
public class Impl implements Itf {

}

In this case all Impl instances would be an instance of Itf. It is fully valid to do

Impl var10001 = new Impl();
AnotherClass.itfConsumer(var10001);

if AnotherClass.itfConsumer is

public static void itfConsumer(Itf variable) {}
silent stratus
#

How can I disable the hit-cooldown? I dont want to do it with another plugin i want to implement this in my own plugin.

quiet ice
#

On a java bytecode layer the same applies:

NEW Impl
DUP
INVOKESPECIAL Impl.<init> ()V
INVOKESTATIC AnotherClass.itfConsumer (LItf;)V

is also valid

ivory sleet
#

geol, this almost deserves a pin

#

very good explanation

vivid cave
grim ice
#

u can user server pro

#

1gb is more than enough

quiet ice
#

Were you the one to use the celeron or am I mixing up people?

grim ice
#

me?

quiet ice
#

yeah

grim ice
#

u r mixing up

#

isnt a celeron some cpu thing

#

idek exactly what it is

#

wasnt it some cheap cpu thing or smth

young knoll
#

Yes

quiet ice
#

The Intel Celeron is just old

grim ice
#

oh

#

i dont use celeron

#

but i use windows 8.1

#

:)

#

personal preference

tardy delta
#

are there even people coding like this?

quiet ice
#

I personally avoid such constructs at all times, but there are def. some people out there that do this

tardy delta
#

๐Ÿ’€

golden turret
vale cradle
#

man, I miss 1.8

north cipher
#

Hello, I am trying to use a MySQL database for my spigot plugin, and I am trying to select many things but I would have to use a while loop, which would freeze everything. how could I avoid using a while loop? the guide on spigot (https://www.spigotmc.org/wiki/connecting-to-databases-mysql/) only selects one thing, but I am trying to select multiple things. my current code: ```java
try (Connection conn = FFDatabase.getConnection(); PreparedStatement stmt = conn.prepareStatement(
"SELECT coords FROM ff_claim_blocks"
)) {
ResultSet rs = stmt.executeQuery();
// can't do while loop here

vale cradle
golden turret
#

bro

#

you need to do a big shit to freeze a server with a single while loop

north cipher
#

alr ive just been told to never use while loops

vale cradle
#

actually I didn't see the Statement, don't you use WHERE statements on your query?

#

or are you filtering whatever you want to look for on the loop? ๐Ÿ’€

north cipher
#

i dont need to filter anything

#

its just a list of coords

north cipher
#

ive used basic sql for a while

vale cradle
#

well the efficiency of your query is other topic but if you want to not freeze your server, as I said, do it on another thread

viral crag
#

no, make mysql do the work

#

there is no reason to parse what the database server can do for you

vale cradle
#

whatever he's doing he needs to learn how to do it on another thread first

#

if he says it's freezing his server, he needs to do it on another thread

north cipher
#

okay il do it on another thread

vale cradle
#

and learn how to use WHERE statements perhaps?

north cipher
#

i know how to use where statements, I just dont need to right now

golden turret
#
while (true) {
  for(;;) {
    new Thread() {
      @Override
      public void run() {
        System.gc();
      }
    }.start();
  }
}```
viral crag
#

poor programming is not going to be fixed by moving it to another thread

golden turret
#

the only while loop that can freeze or server

viral crag
#

that just burns your threads, there are lots of other ways to write blocking code

golden turret
#

Thread.sleep(Long.MAX_VALUE);

vale cradle
viral crag
#

and he only needs 2 coordinates

vale cradle
north cipher
#

might go with a better approach

#

if i cant get it working il explain with more detail

north cipher
#

thanks

vale cradle
golden turret
#

for new people

viral crag
#

all you need are the two diagonal coordinates and you know the rest

#

if you need multiple connected rectangles you ask for the diagonals of each rectangle

golden turret
#

i tried to run the code 1 tick after that

#

i want to get the killer inside the PlayerDeathEvent

vale cradle
#

I'd recommend just using the EntityDamageEvent

#

and checking if the entity's health is equal or lower than the final damage

#

PlayerDeathEvent is usually not as useful as the EntityDamageEvent

#

depending what are you trying to do

golden turret
#

i just need to get the killer

vale cradle
#

EntityDamageByEntityEvent then?

golden turret
#

actually

#

i just need generic player death

vale cradle
#

then try to get the killer a tick after the event is called?

golden turret
#

i just need the killer for a special damage

vale cradle
#

cancelling the damage

#

and turning the player into spec

#

other solutions are just hacky workarounds

#

like the player.spigot().respawn()

vale cradle
#

which now I think about It might be because of that

#

try getting the killer before respawn?

viral crag
#

unless you are using an old version

golden turret
#

bro

#

it was

#

because of the respawn

#

thanks

#

the .respawn() was setting the killer to null

#

_ _

#

i had no words

sacred mountain
#

me neither

strange elk
sacred mountain
#

mine is literally just my name

sacred mountain
#

imagine not centering ur name

#

idk mine breaks on phone

strange elk
#

I replaced it with a pastebin

viral crag
#

why oh why ..

#

if you are using 1.18 player.getName() isnt a thing

#

its getDisplayName() or getListName()

#

looking and no see

lost matrix
#

HumanEntity#getName()

viral crag
#

yup humanEntity has it

#

why use player instead of humanEntity? despite most people want the DisplayName anyway

golden turret
#

ยง supremacy

viral crag
#

put another comemnt in the no match

strange elk
#

this was the only thing in the code that i pasted that doesn't work for some reason:

player.sendPluginMessage(CoreProtect.getInstance(), CoreProtect.COREPROTECT_PLUGIN_CHANNEL_REGISTERED, sendRegistered());
viral crag
#

or are you still getting it in the log/console?

round finch
#

@simple anvil do broadcast p.getDisplayName()

#

to see what it says

viral crag
#

returns teh default mojang one

round finch
#

do equalsIgnoreCase()

#

:d

#

then if you got a lowercase error it will be ignored

viral crag
#

supposedly, yup

simple anvil
#

im gonna leave the server

round finch
#

i knew it

#

basic rule of programming human error

simple anvil
#

well now forget it

#

it was never there

#

nothing happend

round finch
#

Lmao better

simple anvil
#

why

#

oh ok

#

uuid dont change

viral crag
#

btw, you could use the prejoin event as well ...

round finch
#

Bukkit.getPlayer(UUID).getDisplayname()

simple anvil
#

what does that do

round finch
#

plus you don't need to update name for every time you changed your name

viral crag
#

runs on the initial handshake, would put the message slightly earlier

viral crag
#

so you would get the message and spawn in at the same time

simple anvil
#

i think its deprecated

#

OMG

#

I SPELT IT RIGHT

round finch
#

if p == bukkit.getPlayer(UUID)

#

i recommend

viral crag
lost matrix
simple anvil
#

yea

#

AsyncPlayerPreLoginEvent(String name, InetAddress ipAddress)
Deprecated.

round finch
#

Lmao

simple anvil
#

821b7c98-9069-4ef4-b3a4-5665d2d01fda

821b7c9890694ef4b3a45665d2d01fda

round finch
#

why not PlayerJoinEvent

simple anvil
#

what UUID do i put in code

simple anvil
viral crag
#

it looks like all those offline servers need a UUID from now on: AsyncPlayerPreLoginEvent(String name, InetAddress ipAddress, UUID uniqueId)

simple anvil
#

it looks like all those offline servers need a UUID from now on:

#

what

round finch
#

e.getPlayer() == bukkit.getPlayer(Your_UUID)

quaint mantle
round finch
#

you can even make a list and loop every UUID

simple anvil
simple anvil
round finch
#

if you've more one uuid

simple anvil
#

no

round finch
#

note there exists a offline uuid ๐Ÿคทโ€โ™‚๏ธ

simple anvil
simple anvil
#

i dont know what to use

round finch
#

use your online uuid

#

if you're server is in online mode

simple anvil
#

its a local server rn

#

im gonna pubish this so if a server has this pl and i join it says that

viral crag
#

sounds good!

simple anvil
viral crag
#

nope

#

it works and does what you want

simple anvil
#

kk thanke

round finch
#

use 821b7c98-9069-4ef4-b3a4-5665d2d01fda

#

i guess

#

thats yours

simple anvil
round finch
#

it is

tardy delta
#

i forgot if the UUID#equals method compares the versions

round finch
#

trimmed and untrimmed

simple anvil
#

what do i use

#

does it matter

tardy delta
#

nothing to worry about

simple anvil
#

kk

round finch
#

so? what needed?

simple anvil
tardy delta
#

uhm

simple anvil
# round finch

how do u know my name, he is a stalker @everyone he stalks

tardy delta
#

starting method names with an uppercase character

round finch
#

sus man i k @round finch

tardy delta
#

not following the eventhandler signature

#

๐ŸŽƒ

simple anvil
tardy delta
#

unused import, shame on you

ivory sleet
#

?event-api

simple anvil
#

what

undone axleBOT
lost matrix
tardy delta
#

lets go take a nap im litteraly falling asleep here lol

ivory sleet
#

read that and rest assured you'll understand

round finch
#

use prelogin for keeping people off your server ๐Ÿ˜‚

simple anvil
#

someone told me to use pre login event

round finch
#

if you want to make a simple join message just use PlayerJoinEvent

viral crag
#

it was an alternate suggestion

simple anvil
#

ok

#

danke

viral crag
#

your onjoin was fine

ivory sleet
#

yeah the join event, login or prelogin doesnt matter

#

I mean only benefit is that the async pre login is alr async in case you do some heavy stuff

glossy venture
#

dude i process dumped intellij and it created a 3 gigabyte file

ivory sleet
#

lol

simple anvil
#

i had a 20 min video on my ipad that was 2.25 gigs

round finch
#

<-- Brain 0 bits

simple anvil
#

then i duped it 5 times

#

it is a school ipad

simple anvil
glossy venture
#

why is intellij not starting bruh

#

its a background task in task manager

#

but its not visible

viral crag
#

because windows task management is stupid

glossy venture
#

because its using 230 mb of memory?

tall dragon
#

its probably still running

#

somehow

glossy venture
#

so it creates a 3 gb file

round finch
#

going back to figure out why my plugin refuses to make folders and makes configs the wrong places
this is only happing on my host not locally ๐Ÿคทโ€โ™‚๏ธ ๐Ÿ˜•

viral crag
#

remember defragmenting? windows only recently learned to count

glossy venture
viral crag
#

It took me a bit to figure out that annotations was putting my plugin.yml one directory up in my jail. so I could only access it programmically

simple anvil
#
 public void OnPLayerJoin(PlayerJoinEvent e){
        Player p = e.getPlayer();
        InetSocketAddress ip = e.getPlayer().getAddress();
        if (p.getUniqueId().equals("821b7c9890694ef4b3a45665d2d01fda")){
            e.setJoinMessage("ยง6ONWARD TO GLORY. ยงrยง5Welcome Cyber" + ip.getAddress());
        }else{

        }
    }
#

does nothing, no error

tall dragon
simple anvil
#

do it need the -

tall dragon
#

yes

ivory sleet
#

that will never be true

#

a UUID will never be equal to a string

#

not the way you're doing it at least

simple anvil
#

then how do i do it

tall dragon
#

either convert the uuid to a string first

ivory sleet
#

^

tall dragon
#

or convert the second one to uuid first

ivory sleet
#

I'd advocate that

tall dragon
#

idk whats faster tbh

sacred mountain
#

is there a difference/preffered between String.valueOf() and .toString()? i know some things cant be converted but should i try to stick to one

ivory sleet
#

String::valueOf is much more powerful

#

as it is in fact null safe

#

altho toString will be slightly slightly faster

#

tho generally, since Java's null is extremely unoptimized (not in terms of speed) you'd prefer valueOf

tall dragon
#

actually i have wondered what is better to do, a null check or use an optional

#

in sense of speed

ivory sleet
#

I use my own optional

#

just to avoid shitty null

tall dragon
#

ahh, i see

#

thats a pretty good idea

ivory sleet
#

I can show you actually if you're interested

#

nothing of particularity

#

but ye

tall dragon
#

yea, why not

#

would love to see how you handled it

tall dragon
#

i see thats interesting. only thing i've never heard of is sealed & non-sealed

ivory sleet
#

yeah j17 thing

#

(or 16 sth like that lol)

tall dragon
#

ah yea, i dont use that much yet

#

what does that actually do

ivory sleet
#

compile time enforcement of subclasses

tall dragon
#

Ah alright. Thanks for showing me. I might implement a similar system. This looks really nice

ivory sleet
#

๐Ÿ˜… yeah nw, well Im still just trying it out, like code that uses sth like this/optional gets verbose extremely quick

ivory sleet
#

lol

#

in principle

#

I did plan to add a lot more higher order functions

#

but just dont wanna sit there and guess code

lost matrix
ivory sleet
#

myeah true

#

not a dumb idea

lost matrix
#

Then you can apply mappings and what not

ivory sleet
#

yuh

lost matrix
#

interesting use of sealed. First time ive seen this used in a justifiable way

ivory sleet
#

I mainly made my own to make it polymorphistic towards differentiability for absence and presence

simple anvil
#

does the join message goto everyone?

sacred mountain
ivory sleet
pliant oyster
#

?jd

sacred mountain
#

I know optionals are in java8

ivory sleet
#

j17+

#

sadly

lost matrix
#

'sealed'

ivory sleet
#

but like, j17 is lts

sacred mountain
ivory sleet
#

so pretty pog

lost matrix
sacred mountain
#

i might update to j17 anyway tbh

ivory sleet
#

awwesome!!

simple anvil
sacred mountain
#

none of my stuff needs j8 so i could probably just change it without too much hassle

#

because it was originally a latest java project anyway

#

hopefully this works

simple anvil
#
for (int i = 0; i>54; i++){
            p.getInventory().setItem(i, glass);
        }
#

is this for loop right?
is the alligator going the right way?

#

glass is a item stack btw

lost matrix
simple anvil
#

InteliJ

#

how do i change my nick name?

lost matrix
simple anvil
lost matrix
simple anvil
#

oh ok

#
for (int i = 0; i > 54; i++) {
            p.getInventory().setItem(i, glass);
        }
#

what now

#

no error no glass

lost matrix
simple anvil
lost matrix
simple anvil
#
package HotBarInventory.me.cyberwolfie.Me;

import HotBarInventory.me.cyberwolfie.Me.Events.JoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class CyberWolfie extends JavaPlugin {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new JoinEvent(), this);

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }
}

#

this is main class

simple anvil
#

yes

lost matrix
#

Write a debug message

simple anvil
#

i always forget

main dew
#

How I can update libraries in spigot use BuildTools?

lost matrix
simple anvil
#

i hate < and >

#

it was the wrong way

worldly ingot
simple anvil
#

how to i make a player not drop a item when they die?

simple anvil
#

i dont want them to keep inventory

#

i just want 1 item not to drop when they die

round finch
#

get Drops
get Item

Store Item

remove item in drops

replace it back into inventory then respawning

simple anvil
#
List<ItemStack> drops = e.getDrops();
#

first step

#

right?

pliant oyster
#

How can I make a gui someones inventory

#

like I create the inventory with the the type of player

#

but how can I make the players inventory and items show in the inventory

simple anvil
#

like /openinv?

round finch
#

you make a gui like this

Inventory inv = Bukkit.createInventory(null <--- Holder fx Player, 9<--- Size, "Example" <---- Name);

#

player.openInventory(inv);

#

@pliant oyster

#

i dont believe you make a PlayerInventoryGui like e
far as i know

#

but you can get a players inventory and open it as a chest

pliant oyster
#

I just realized I don't need to make it into a gui

sacred mountain
#

quick question, why do you get banned if trying to create a new spigot account

simple anvil
#
Player p = e.getEntity().getPlayer();
        ItemStack glass = new ItemStack(Material.RED_STAINED_GLASS_PANE);
        e.getDrops().remove(glass);
#

it is not removeing the glass apon death

main dew
#

How I can update libraries in spigot use BuildTools?

tall dragon
#

?bt

undone axleBOT
simple anvil
#

that is all the code

#
package HotBarInventory.me.cyberwolfie.Me.Events;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class DeathEvent implements Listener {
    @EventHandler
    public void death(PlayerDeathEvent e ){

        Player p = e.getEntity().getPlayer();
        ItemStack glass = new ItemStack(Material.RED_STAINED_GLASS_PANE);
        e.getDrops().remove(glass);

    }


}

pliant oyster
#

does the item even drop?

simple anvil
#

yes

#

i think its just removing it from the drop list

#

but idk

pliant oyster
#

oh

proper notch
#

You're trying to remove something you just created, so the drops won't contain that item stack.

round finch
#

probably not the same item

simple anvil
#

oh

#

so do i need to make a item public?

proper notch
#

You probably want something more like:

for (ItemStack drop : event.getDrops())
  if (drop.getMaterial() == Material.RED_STAINED_GLASS_PANE)
    event.getDrops().remove(drop);```
#

haven't used spigot in quite a while so that naming might be wrong

proper notch
#

o yh that's a thing

#

do that instead ^^

simple anvil
#

?

tall dragon
round finch
#

it is a Item List

tall dragon
#

so?

round finch
#

wait nvm

#

i thought something else
it was wronng

faint sage
#

๐Ÿฆ

round finch
#

i thought
maybe set Item on Respawn then Die
to test

simple anvil
#
e.getDrops().removeIf(drop -> drop.getType() == Material.RED_STAINED_GLASS_PANE);
#

this works

tall dragon
#

yea i know.

round finch
#

ofc

#

 private static ArrayList<ItemStack> Special_Items = new ArrayList<ItemStack>();

  @EventHandler
  public void OnPlayerRespawn(PlayerRespawnEvent e) {
    
  Player p = e.getPlayer();
  
  if(Special_Items.isEmpty()) {
    
  ItemStack Special_Item = new ItemStack(Material.DIAMOND,1);
          
  Special_Items.add(Special_Item);    
  
  }
  
  for(ItemStack item : Special_Items) {
  p.getInventory().addItem(item);  
  }  
  
  
  }
  
  @EventHandler
  public void OnPlayerDeath(PlayerDeathEvent e) {
   
        
  
  for(ItemStack item : Special_Items) {
      
  if(e.getDrops().contains(item)) {
  Bukkit.broadcastMessage("Dont Drop Your Item" + item);
  e.getDrops().remove(item);   
  }      
  
  }         
hasty prawn
#

oh god why

#

?paste

undone axleBOT
round finch
#

it was just an Exemple

tall dragon
#

ye dont post big code blocks

#

Dessie will become unwell :D

hasty prawn
round finch
#

oof

hasty prawn
#

Code blocks are fine (sorta), but the initial way you formatted it was...

#

It's much better now lol

round finch
#

@simple anvil here if you want it

simple anvil
#

it works now

#

thanks

#

also

#
List<Integer> slot = new ArrayList<>();
        int i;
        for (i = 9; i < 36; i++) {
            slot.add(i);
        }

        if (e.getSlot() == slot) {
            e.setCancelled(true);
        }
#

i wanna make the slots 9-36 all cancel if you click on them

#

i cant use int with list

#

and i dont wann have a or statment for all the numbers

#

imma go eat dinner

#

bye

tall dragon
#

so guys i have a math question.
i have a list of Materials that each have a certain worth. (these materials are spawned into a generating mine)
now im making minions, and they automatically mine those ores (or at least pretent to) now when i a player opens my menu i need to "simulate" how much that minion has made in the time the player was away. and there are a few factors to take into account. such as efficiency, fortune. does anyone know a good way to go about this?.

My first idea was to calculate how many blocks the minion couldve broken, take the total % chance to get a certain ore and that would be the amount of ores from that type. the problem then is fortune as i probably would have to generate a chance for the amount of blocks the minion had broke. this could be a high number like 1.000.000, that probably would not be very performance friendly, sooo anyone any ideas? let me know.

#

probably best way to do this if had some formula that can give me the amount of times a chance would return true. with a changing amount & chance

eternal oxide
#

its only math with no in game actions. it doesn;t matter how many blocks

round finch
tall dragon
eternal oxide
#

plenty fast enough

tall dragon
#

like generating a random 1mil times for example

eternal oxide
#

you can do all teh calculation async so it won;t matter at all

tall dragon
#

dont know about that, when a player opens my menu. it should be updated then and there

round finch
#

amount of fortune drops

speed of efficiency

time

tall dragon
#

or i could handle that differently?

eternal oxide
#

just calculate at regular intervals, like the minion has to bring the rewards home

tall dragon
#

that would require me to keep the "Mine" object in memory though

round finch
#

config to get it

tall dragon
#

which is something im trying to avoid

eternal oxide
#

mine object?

tall dragon
#

or i would have to read straight from my data file

eternal oxide
#

config should not be used to store player data

round finch
#

it could for numbers

tall dragon
#

worded it badly

eternal oxide
#

as it is player specific data, and only related to a few numbers put it in their pdc

tall dragon
#

its not though