#help-archived
1 messages · Page 98 of 1
you don't use spigot?
not really
then why are you here
there is many things that can be fixed
this is getting fun again
synchronized is not thread safe.
it is
no, its not
okay.
sychronized is a tool to write thread safe code, but yes code can still be unsafe that uses synchronized if logic is not designed correctly
sync and threadsafe are 2 different things
still requires understanding concurrent access, happens before/after concepts
they are really not 2 different things
CPU caches
No, they are 2 different things.
You can be sync and threadsafe, not sync and threadsafe, or neither.
or sync and non-threadsafe as well 😉
Map<String, String> foo = Collections.synchronizedMap(new HashMap<String, String>());
if (!foo.containsKey("bar")) {
foo.put("bar", someCriticalValue);
}
This uses synchronized. This is not thread safe.
yup, 4 combos, missed it
Use project reactor and try and tell me sync = threadsafe. I dare you.
lol
However, I will say Aikar knows more then me and does more complicated stuff usually then I do XD
However, what you should probably do is run some tests @brisk mango and the provide the results as well as the code used to conduct your tests
Yee, he's pretty nuts. And me and my girlfriend both work within the reactive standard so I know pretty well how sync and threadsafe are not the same
i've added the
Consumer<BukkitTask>in the scheduler
@brisk mango are you sure about that? https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/a35fa83843daa00df508e88a5def5a01d6199e1f
I sincerely hope you are not scheduling so many bukkit runnables that you need to worry about synchronization. holy crap that would be a lot of tasks
🤦♂️
Yeah, that would be... not good
im not using BukkitRunnable coz its an shit class
why is it shit
And yet so many plugins use it just fine without performance problems
^
ignore him avro hes trolling
yeah, big troll at this point
i mean i am learning a lot reading this but even i run stuff async with bukkit runnable and it works fine
because of the synchronized methods and exception throws
it just uses BukkitTask's methods
synchronized methods do not cause performance problems on their own
he knows a bit of java and now thinks he is a know it all 😂
"gasp it throws an exception if i do something stupid, its bad!"
lol
pro tip, synchronized is hit about a billion times a second in running a server, just an FYI. 1 every second from a Bukkit runnable with 0 contention where BiasedLocks is default on.... yeah
@timid valley once every few clock cycle? 🤔
they can
Who are you guys helping?
@obtuse rose lol ok i prob exaggerated a bit there
yes they can, but then you might as well say that every API method in the JDK has that ability @brisk mango
imagine letting user errors go thru an api, sounds like the people who designed it knew what they were doing
that legit confused me 😆
More or less just trying to deal with a troll than helping @naive goblet
@keen compass but then there is a question why use BukkitRunnable when there is BukkitScheduler
when BukkitRunnable is fairly useless
thats not a good example
Because sometimes you don't need a scheduler
It is a good example tho
and thats when?
Hello i have problem with Player Count with my bungeecoord server
why run minecraft when we have cube world, minecraft is useless
lol
@daring crane yeah... no, lambdas are way more useful than you can possibly imagine.
the schelduer is this new BukkitSchelduer() {}?
@brisk mango that is for you to decide. But if its just like a once off task, why have a scheduler for that?
screw you guys im going back to FFXI!
whatever, for me its an useless class
whats the problem ricky
when you could just do
you didnt state what the problem was
Bukkit.getScheduler().runTaskLater(task -> task.cancel());
another known user gave up on discord for today, gg temedy
isn't most of scheduler deprecated though
@opaque swan what subchannel are you using to get player count?
Ok that is a lot better statement. It is useless to you, but not necessarily useless to others
no avro
no its not
@worn temple that was just an example, i use lambdas all the time
I may dip out of this server tbh, seems like it just brings in the worst of the forums.
i see only the lobby players
@opaque swan what subchannel are you using to get player count?
@fallen garden nothing i think
Wouldn’t say temedy is a troll but you guys seem to have different views of it
@daring crane ah, okay, just making sure, because its hard to tell trolls from ironic people at this point.
true
BukkitScheduler is an interface
The point of BukkitRunnable is that it gives us a way to declare and use instance variables without having to implement BukkitTask (or without having to depend on its implementation, CraftTask)
@naive goblet There's a line between an opinion, and just something factually completely wrong. That's the issue, is they have an opinion on a fact and are trying to disagree with it.
no, temedy is a great comedian
Nova fair enough
when should you be using runnable over scheulder then? i always use runnable - is this bad or
Is there a way to force a player's enderchest they are in to close
Now work thank you! @timid valley ❤️
yeah not every day I get accused of not knowing about concurrency haha
lmao
I mean it can be bad but let people use whatever they want, for me its an totally useless class and i'd prefer BukkitScheduler instead of BukkitRunnable, because you can even write an easy lambda and cancel the task inside of the scheduler if needed
that was quite a hit
you can't use lambdas if you use the runnable, which means some unnecessary boilerplate code @dusty topaz
@empty salmon yeah, just get the inventory they are in and close it. You can just check if its an ender chest before that
is there a reason to use one over the other though
no
sometimes
they achieve the same thing
just dont do stupid things in them, the framework doesnt matter
well except for spigot and async tasks, async does cause lag on spigot ._.
dont spam them
so why this a vs b thingy
replaces new Runnable()
@worn temple I have the inventory variable, what do I do to close it?
they both exist for a reason
BukkitRunnable is fairly useless IMO
@empty salmon Inventory#close() iirc
@empty salmon player.closeInventory()
or that
i think thats a shortcut to iterate all viewers and close their inventory
it gets the job done it's in no way useless
17:49:12 [WARNING] Exception encountered when loading plugin: NuVotifier
while scanning for the next token
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
in 'reader', line 3, column 8:
does anyone knows what this means?
Async is fine for sending messages and doing things like that @timid valley
BukkitRunnable just implements runnable and adds some methods of its own
I use java executors whenever i can
literally not what I said
I believe so, assuming there's only one viewer then its fine, but could become an issue if you have those plugins that allow "spying" on inventories
its not what you said you're right
it should work 🤔
That's what I thought!
closeInventory() only works on the player inventory I thought o.O
Doesn't work can mean many things? Are you sure the code is executing? Are there errors? etc?
and not for other inventory types
Should work with whatever inventory the player is viewing
Yes I am sure the code is running. I want the code to close the enderchest inventory they have open. I have a message run before to check that the conditions of my if statements are met, and that runs but the inventory won't close
use hastebin or at least code blocks, that is impossible to read
Sorry
use 3 back ticks `
```
that works too
lambdas are useless
@daring crane i mean go to school
Any idea?
@minor flint he was kidding, already figured that out awhile ago
why not just use InventoryOpenEvent
and close the opened inventory
also don't worlds have an UUID
I will try that now
Oh that's a shout, thanks
Yeah, should be using inventory open event, pretty sure this event happens before then, so therefore there is no inventory to close
it gives you an InventoryView in that event @worn temple
which you can get the inventory in question from it
@keen compass Ah, my b.
Haven't worked with the bukkit/spigot API in like 2 years, bit rusty.
lol
How should I check it is an inventory? @EventHandler public void onEnderChest(InventoryOpenEvent event) { Player player = (Player) event.getPlayer(); if (player.getWorld().getName().equalsIgnoreCase("test_world")) if (player.getInventory().getType() == InventoryType.ENDER_CHEST) { //DO SOMETHING } }
I've got that!
well that event doesn't run unless it is an inventory
do you mean you want to check if its an enderchest inventory?
Yep
I have ```(player.getInventory().getType() == InventoryType.ENDER_CHEST)````
That should work
Oh right!
Got it
Okay, just checking, to close the inventory, do I use event.inventory or player.inventory ?
@EventHandler
public void onEnderChest(InventoryOpenEvent event) {
Player player = event.getPlayer();
if (!player.getWorld().getName().equalsIgnoreCase("test_world")) return;
if(event.getInventory().getType() != InventoryType.ENDER_CHEST) return;
// DO SOMETHING
}
please don't nested it 😄
you should do event.inventory instead of player.inventory
Okay
player.inventory gives you the players inventory
Thank you
Yeh, so how do I close it because event.closeInventory() isnt a thing
player.closeInventory()
I think there is some confusion in some of the methods in player object lol
player.closeInventory() should close whatever inventory is opened by them, player.getInventory() gives you the players inventory and not an inventory they are viewing.
hmmm, isn't that event implemented cancellable?
nope
tragic
that wouldnt even work
closeInventory() will close the current viewed inventory no matter what type it is
It doesn't work! Like, it doesn't even run my message to the user!
public void onEnderChest(InventoryOpenEvent event) {
Player player = (Player) event.getPlayer();
if (player.getWorld().getName().equalsIgnoreCase("test_world"))
if (event.getInventory().getType() == InventoryType.ENDER_CHEST) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cDon't try and exploit enderchests!"));
player.closeInventory();
}
}```
so the event isnt registered.
Exactly
???????
did you register the listener
wow, still nested >:(
why did you say exactly
Will change it!
whatever
but why is opening enderchests an exploit for you
if your trying to close it as soon as they try, then why not setCancelled?
So, with the code I've got, it sends the message but doesn't close the eventory
Okay, will try @cloud crater
So I'm assuming do event.setCancelled(true);
that event is called before the inventory is actually opened so closeInventory doesnt do anything
yes it will cancel everyone doing so
So I'm assuming do event.setCancelled(true);
yep
Well if its an exploit for them @brisk mango there actually might be a better way in handling this then using the inventory stuff lol
ender chests are shared across worlds, so it doesnt make sense to target one single world
then just set permissions if otherwise, if needed.
@timid valley are you missing common sense?
@subtle blade we need you
he wants players to not be able open enderchests in a certain world
np
You are amazing!
@timid valley Lets say you have 2 worlds, and you want players to not be able to open enderchest in 1 world, what would you do
if you don't want them opening ender chests, why even allow ender chests to begin with o.O
could just solve all that if you can't build them
@empty salmon you are aware ender chests arent duplicated on a world backup right
It is only for one world because they have access to creative there and I don't them being able to spawn items into their enderchest to sell for money in another world. As, yes @timid valley, it is just a name someone else gave it, I haven't got round to changing it
do you clear their inventory on leaving the world
alright then, i guess that makes sense
as much as I dont like how wiz deals with some ppl, I sure sometimes wish he was a mod in more discords, lol
could just not allow placing ender chests @empty salmon
No, it is decorative
its creative, its an exploit world already 😛
I want people to be able to decorate just not use
it's done what he needed @keen compass
fair enough
Well, cheers for your help everyone
but your gonna have to worry about every dang possibility of items moving worlds
^
like donkeys through portals, teleporting entities, plugins that allow trading items etc
@obtuse rose no that doesnt work lol and why when he already has a fucking solution
Haha, I've sorted every way apart from enderchests which have been sorted
@timid valley Can I ask you a question?
sure
Are you working for spigotmc?
haha
@brisk mango yes it does but okay
I use to many years ago. I work on the larger fork of spigot 😛
what fork is that? 😂
Paper
Paper, what else?
I hope it isn't Paper
lmao
craftbukkit is what modern servers use Kappa
ok this guy is on drugs, no way
paper is literally the only reason servers survive on 1.15
Im fine with CraftBukkit
@timid valley Thanks, from this day I know why Paper sucks
probably should go check out async chunk loading 😉
cool story
its your personal fault aikar!
is kyngs temedy's partner in trolling?
yes
Lmao
I have a question aikar
I think it was meant as sarcasm? or were they serious?
why is my paper server lagging when there is alot of people?
like such weird lagspikes
normal spigot doesnt
thought you didnt use paper
XD
😂
i did, very best spigot
ah beat me to it
the timings were fine
and ping wiz
Anyone know if I can use a library licensed with GPL-3.0-or-later for closed sourced purposes?
there was 100 ppl and 19.5 tps
but weird lag-spikes
every time there is more than 100 people
temedy, how many threads your schelduer api is using/making?
only one other thread?
@tidal pulsar if you don't release the jar
im using ScheduledExecutorService
then yes you can use gpl stuff
Thanks!
you still didnt send timings
😂
yeah it totally is
Hello
why do i need to send timings
if you want paper support, join paper discord
nah i dont want paper support
so you can get banned in under 30 second for being an asshole
im not using that shit anymore
im just curious
explains alot if this guy is it's main dev
that uber synchronized-free custom server he runs
🤔
Hello people
btw temedy never user Player#sendMessage, it calls code which contains a synchronized block
synchronized keyword can cause lag spikes btw
from where
so we got akkarin and the like that adds synchronized everywhere, and now temedy-spigot that removes it
its not in that method though
the best of both worlds!
he also removed the Thread.sleep in the main tick loop
which i had removed
since that cuases lag
mini you should make MiniJDK single threaded so you cant run into concurrency issues
aikar, at least we now know how mcm fork ppl think
How come the topic always moves onto forks whenever I’m gone? I mean really
choco save us
oh choco is here
If you want to glorify another fork, do it there. I’m sick of seeing it here
can you pls remove the trolls?
Also, temedy, I’m getting real sick of your shit. I’ve seen far too much of your attitude lately
well we were trying to get you to deal with temedy, it only recently changed to fork talk >_>
I’m giving you your last warning and you’re gone
does a ban here means ban on the forums?
last warning 👀
Typically yes but I honestly don’t think it’s much too worth it
He’s not active on the forums
Yay Choco is back, we missed you 😄
Still at work. Last thing I want to be doing is this lol
oh, so you are semi-quasi back then
that is alright then, we still missed you anyways 😛
😉
What are you working on 😮
hes in retail iirc
So customer service or cleaning/organizing
Yep
The most joyous time right now in retail
I WANT TO DIE
Not customer service though
Can’t possibly do that
I can't imagine it being fun in retail with no customers or hardly any customers
There are more than the limit of people that our government requests
cant i write a Hashmap<UUID, ItemStack> to a file with a FileOutputstream?
17:49:12 [WARNING] Exception encountered when loading plugin: NuVotifier
while scanning for the next token
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
in 'reader', line 3, column 8:
does anyone knows what this means?
you can just deserialize a map manually @tardy lance
Ive done this:
File bountyNameData = new File(getDataFolder() + "/userdata/bountyNameData");
fos = new FileOutputStream(bountyNameData);
oos = new ObjectOutputStream(fos);
oos.writeObject(fileManager.getBountyNameMap());
And the error:
Caused by: java.io.NotSerializableException: org.bukkit.inventory.ItemStack
at: oos.writeObject(...)
Does anyone know if there is a packet/other event for when the server modifies a player's potion effects?
Entity status packet or something
ty will look that up
indeed it was, it was hidden under another section ty for pointing that out
https://wiki.vg
@torn robin
Any help? https://paste.md-5.net/ehitayirib.java Island generation not creating a void world, ie has terrain outside of the worldborder.
it dosnt make sense... there ist no\t ...
A tab is represented by \t
well ItemStack is not serializable @tardy lance
oh ok thx 🤦♂️
thank you for that information
itemstack is serialized tho by the yml configuration
You can serialize it with JSON
yeah like any other object
^
^
huh?
Because serialize uses bukkits ConfigurationSerializeable
as opposed to Java's serialize function
^
^
https://paste.md-5.net/ehitayirib.java Island generation not creating a void world, ie has terrain outside of the worldborder.
EZ
YES
^
oh
Well you don't do anything with the stuff outside of said border
did you start the world that way? o.O
that would be why. Generator won't remove what is already created
ok...
but i made the world with a generator...
OH
i see what you mean
let me delete the world
and try and create again
setupworld.type(WorldType.FLAT);
setupworld.generatorSettings("2;0;1;");
setupworld.generateStructures(false);
setupworld.createWorld();```
^^ my void method
that void method handles making a new world for you too
Im having trouble with the SQL result set type... is there a way to make a specific type the default for all resultsets? instead of having to define the type for each prepared statement?
@wanton delta what do you mean?
Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY
I could define the result set type for every single prepared statement i already have
but i dont want to do that
you do know you can easily make a function for your prepared statements
so that you can feed it what you want it to query
declare it somewhere with a small name?
or a small utility method to easily generate them for you
^^^^
i suppose
Generally isn't common that you need to go backwards for results though
also that
well im using beforeFirst and i believe that is what is triggering it
there is no need to ever go backwards
well there is, just isn't common is all lol
it puts the cursor before the First result
is that what it is by default? if so i can just remove it
(this isnt my code if you could tell)
By default, it reads the result from forward to back
so in most cases you really don't need to do that
well i mean
if you want context
all thats happening is rs = stmt.executeQuery();
rs = stmt.executeQuery();
rs.beforeFirst();
while (rs.next())
{```
if you don't have a specific reason to set the cursor back to the beginning then remove it
could i just remove beforefirst?
that's what he said
i sent that message very close to when he sent his lol
the only thing you want to make sure is that your result set didn't come back empty
before trying to iterate over it
@idle zodiac are you teleporting the player after generation is complete?
i was gonna say that but i did not know if i was gonna be right
@cloud crater no, they are t spawn
be good to do so.
ok
most sb plugin you get teleported after created island.
ye ik
nice feature just saying.
i'm just trying to get the generation working again ol
any errors?
ok
if anything goes wrong it will print.
🤦♂️
Ceezy like what?
try {
ClipboardFormat.SCHEMATIC.load(file).paste(world, loc, true, true, (Transform) null);
} catch (IOException e) {
e.printStackTrace();
}
if anyone gets a big brain moment dm me ima go afk
theres nothing else that can go wrong
or that needs to be surronded with try/catch
it will get printed if something goes wrong itself
how do I delete a patch? I made one as a test and I've unstaged and removed it (I think) but when I do ./rebuildPatches.sh it reappears
that's what i just said
that's to see if it loads the schematic.
why wrap it again
yeah, the only thing that can go wrong in the code
and it is in a try/catch
so whats the reason to put the method call in a try/catch?
world creation?
that will get printed though
if it goes wrong
actually wait
Nope, it doesnt throw any exceptions
so it doesnt need to be try/catched
anyone know why this !(event.getInventory().equals(Main.openGUI.get(player.getName()))) seems to be true in all my guis? (it should only be true in the open gui) Here is some more code: public void openInventory(final Player player) { Inventory inv = worldsAddedToGUI(player); player.openInventory(inv); Main.openGUI.put(player.getName(), inv); }
why are you comparing the inventory with .equals
should I use ==
does openGui.get(player.getName()))) return the same inventory object
if so, use ==
also this static stuff
it should, thats what I have to check
remove static
it shouldnt but its better
what would fix it?
try ==
k
map.put(player.getName(), inventory)
static HashMap<String, Inventory> openGUI = new HashMap<String, Inventory>();
final Inventory inventory = Bukkit.createInventory(null, 54, "Inventory");
okay done watching this static collections
then I have Inventory inv = worldsAddedToGUI(player); player.openInventory(inv); Main.openGUI.put(player.getName(), inv);
fine but do you have to use static everywhere
just a habbit
"habbit" LOL
okay dude
its not gonna be me who's code is gonna have bad performance
is static slower?
I've never checked that
oh it might be
because I have to create a class instance
which uses up memory
you know that everything that is static gets loaded into memory and never get GC'd
better than doing static
yeah
static breaks the rule of the language lol, OOP
time to remove static
don't use it till you mastered it's proper uses :p
the proper uses are not hard to learn
sorry it's just my java teacher always had us write static
very bad teacher
anyone here know any good free queue plugins with donator priority support?
do it for him temedy :d
@pastel condor statics cause your objects or variables to not get garbage collected if you are done using them. Also, statics can prevent you from getting the appropriate instances of objects. IE you want a new instance, and not an instance from before.
@wind dock just google a "spigot queuesystem plugin", or google bungee methods
I googled it but everything is paid :/
thinking of using thishttps://www.spigotmc.org/resources/queuesystem-1-12-support.44013/
oh I see thanks @keen compass
this plugin isnt a virus right lmaohttps://www.spigotmc.org/resources/queuesystem-1-12-support.44013/
maybe
maybe as in probably or probably not @brisk mango
ofc it is virus
it looks like this (event.getInventory() != Main.openGUI.get(player.getName())) didn't work
idk man
same here
just an code issue somewhere
😦
it's an issue with all my gui classes
should I just send you the code of one of the classes?
@brisk mango is that sarcasm
just read reviews.
anyone know a plugin for adding new objects to minecraft 1.15 with custom recipes for the objects?
it is
ofc there is no viruses on spigotMC
You cant with plugin @little lava
you cant add new items
mods do that
textures
Spigot does not review free resources, so it is very possible for someone to upload a virus or "force op". Take caution with what you download.
unless you decompile
obfuscators
Any good decompiler allows you to show syntetic members
Spigots section is full of viruses, but they get found rather quickly
9/10 server owners with no coding experience isn't going to think about decompiling to see.
yeah but if you download a plugin with quiet a few of reviews/downloads you'll be fine
What is network-compression-threshold?
What's the effect that has in the server?
Someone told me that slows the amount of players if they join at the same time or something like that but I didn't understood
No, that would be connection throttling
Network compression threshold means how big a packet has to be for it to be compressed iirc
it is how hard the server works to compress the data sent between the server and the client to reduce lag
You lower it, you get less bandwidth but more cpu usage or smth
you are correct @hoary parcel Default value is generally sufficient
if a packet is 64bytes or smaller, you won't gain much from compression
the lower the better but lowest you should go is 64 no lower
I still can't seem to solve my gui issue
Hey! Do you know how I can "import" head from https://freshcoal.com/maincollection ?
I mean
If a player types /skull Bread, it gonna take the linked skull
they should have an API you can hook into. Otherwise, you're gonna need to learn how to do webscraping
Yeah I guess
Help me plz
CraftMetaSkull @lament wolf
why arent mobs spawning from spawners on my server? im using silkspawners
That’s my issue
@tulip pendant ffs stop spamming servers! If you want help with a complex issue, open a thread on the forums. This is not a clearlagg support server. Talk to the devs of the plugin and/or stop using it in the first place.
opened a thread for clearlagg
just ignore him guys please
there is another kid that got book banned on his own server and doesnt know what view bobbing is and posted on the forum lol
CraftMetaSkull @lament wolf
@brisk mango What is that
Yeah an object
But,
I mean
well I mean something like adding an object with the same ID of a minecraft object but a different recipe and texture, for example I add the Netherite Armor by replacing it by the leather texture and editing the armor it has but what i search is a way for doing it without the needing of eliminating the other object @brisk mango
anyone know why when a player click in one of my guis, it seems to call all the guis? (like if they click in slot one in one gui it calls slot one in all the guis) here is the code of one of my guis (it's mostly the same between all of them) https://pastebin.com/gTB3wNV1
@little lava just use a mod platform for mods. dont hack mods into a non mod platform.
whats a good mob spawner plugin
well I mean something like adding an object with the same ID of a minecraft object but a different recipe and texture, for example I add the Netherite Armor by replacing it by the leather texture and editing the armor it has but what i search is a way for doing it without the needing of eliminating the other object @brisk mango
@little lava item textures can be modified depending in the durability, theres a lot of texture or item appareance changer in youtube, without using mods etc
Lé Spam
?
A bit more code?
@timid valley I know its posibble without mods because im trying to copy it from a serie of YouTube but i dont know how
can u check dm @barren abyss ?
@frigid ember the IDE error is clear
Can only iterate over an array
or over anything thats Iterable
show some more code
anyone know why this isn't working? ```public class BasicSettingsGUI implements Listener {
@EventHandler
public void gui (InventoryClickEvent event) {
final Player player = (Player) event.getWhoClicked();
if (event.getInventory() != Main.openGUI.get(player.getName())) return;
event.setCancelled(true);
}```
still using static?
don't use != to compare objects
at least use .equals() but i dont believe even equals works reliably for inventories
why not use != LOL
I was using that but then people told me to use !=
they told you wrong
check if the object is not identitical
nope they didnt
!= checks if the oject isnt identical
if its not it will return true
!= is not safe in java except for enums unless you know for sure you have object identity
but for inventories, you do not have object identity
@subtle blade hes still trolling
@timid valley idk if im explaining myself well what I mean is like in this photos to have different objects with different functions with the same ID without replacing them. Link of the photos: https://cdn.discordapp.com/attachments/463319070637555754/714182811116109844/unknown.png and https://cdn.discordapp.com/attachments/463319070637555754/714182621101293578/unknown.png
if(!world.equals(null)) { }
just because why fucking not
its safer isnt it?
totally wont throw an exception
noone said anything about a null check
!= is an null check though
I'm talking to @pastel condor who is not doing a null check
we were talking about != werent we?
why is it wrong
teach me
and how come even java code uses it
Inventory a = map.get(uuid);
if (player.getOpenInventory() == a) {
A = Inventory1
player.getOpenInventory = inventory2
But, a.equals(b) might be true. not the same
you're really wanting to get banned aren't you.
@pastel condor ignore this guy
not really I though .equals was for objects
nope
it is, use it.
Yes, and inventories are not always the same instance.
if the map returns an identical object
they are
if he saved the same instance
into the map
dummy
for some reason the thing from the map is broken
Remember kids, don't compare non primitive types with ==
like other guis think they are equal to it
I'll compile my edits and test it again
If you open a custom inventory, the object is wrapped. It is not identical.
but if you use .equals it would be the same?
yes, should if not its a bug 🙂
thats odd then
always use equals except for enums, it's java standard practice (outside of null checks to make temedy hush)
is it a custom inventory?
I belive so
I do believe there is a bug on those actually, which is why people use Inventory Holders
I used to use that, but I was told not to
but spigot has a vendetta against them
i suggest continue to use them
spigot is being silly with trying to get people off them
xD
Hi, NBTags needed when modifying armor properties with ItemStack?, just tried and it seems like but im not sure.
but would be good if the damn equals bug was fixed
I think he is correct
do you want to know what's the very first line of code in nearly every equals method?
if (a == b) return true;
no need to tell me that, there is a thing though
you shouldnt say never use != because there are cases when you want to use it
i.e if u want to check if an object isnt instance of another object u use !=
or on a nullcheck
You use .equals though if the class itself has an overriden equals method that has more checks than just checking if the object isnt identical
so dont mislead people, thanks
you should not rely on identity checks unless you explicitly know identity is the right type of comparison
I said it depends on the use case. Definetly should not be never
u use it most likely all the time
i.e if u want to check if an object isnt instance of another object u use !=
wat
sender != instanceof Player
no
new hidden syntax
thats checking if they arent the same reference
Object object = new Object();
Object object2 = new Object();
if(object == object) // returns true
if(object == object2) // returns false
no
it's literally called a reference comparison
okay cool and?
but it it's not checking if they are the same reference?
it is checking if the objects are identical
no it isn't
best anti cheat in your opinion?
it checks if they hold the same reference 🤦
😦
actually no, saying "is identical to another" is misleading. It checks that the object the variable points to is literally the exact same object.
but 2 objects with the absolute same data such as class foo { int bar = 42; } if ((new foo()) == (new foo()) { is false
you should never ever ever use == to compare objects. Always use object1.equals(object2)
why should you never use ==
or Objects.equals() for null safe
i'll note that
Because it doesn't actually compare the objects
it does?
temedy you should go read some tutorials/books on java, or go to school for it.
😂
== is more for numbers and enums.
When we work with inv menus using == wouldn’t be totally useless
but you should use it whenever u want to check if the object is identical
@worn temple why you say such bullshit
temedy yeah indeed
you use .equals if the class has overriden method .equals
and you use == to check if the object is identical to another object
if it is it will return true
No, .equals() should be used, == does not work for comparing two objects.
there is nothing like " you should never use =="
they are different
they are not
new Foo() == new Foo() is different
because its 2 instances so its not the same
== is reference equality check. equals is value equality check
yes and this is called identity
wait hold your horses
literally System.identityHashCode
so youre saying if i would be comparing 2 objects if == they would be different or what?
you dont make much sense tbh
== compares memory locations where they are stored. It returns true if they are the exact same object, not equal values
why you keep sending this? rather read it urself
before saying bullshit
@little crater exactly
I am reading it tho
I highly recommend you take an actual class on java
fine
someone help
i dont think i need it though
PlayerJoinListener.java:28
dat 1.8
What you mean @brisk mango
exactly
I was correcting you. You aren't saying what I am saying :p
Im saying what you were saying
your saying it with misleading words
actually it deosnt check if its the same value so you werent right
If a class does not override the equals method, then it defaults to the equals(Object o) method of the closest parent class that has overridden this method.
which is litterly what ive said and you've tried to correct me @worn temple
the default .equals(Object o) method just uses if(object == object2)
which is the same as using it directly, though u wouldnt be able to use if(object.equals(null))
have to use the equality operator for that
what is the error?
you probably want INSERT INTO ... ON DUPLICATE KEY UPATE instead of that code
Yeah, you're just saying it weird. Very misleading. Easiest way to say it is == is a reference check and equals() is a value check. Any object worth using already overrides the equals() method (like ItemStack from your example) so talking about overrides and defaults just muddles the convo even more, imho
how is .equals an value check
no?
yes?
It depends on what .equals is
because sometimes it can be overriden
and if its not overriden
then it is just wrapper for
if(a == b)
yeah
but usually tht's why you would look for equal instead of ==
if it has inside checks
Black Spigot user 🤨🤨
Hey
your message got deleted tho
Is it possible to center a MOTD?
@naive goblet I admit that I have used it, but only when im desperate. i dont use it anymore tho
why you circumvented the system?
That fucking beef tho
Because I wanted to know :/
they just screaming at each other fighting for who have the reason
how do they even get your ip??
Don’t take it as they wouldn’t do it
just mute each other if you think you have the right idea
When browse their site ?
oh
dev true
welp
Nitpicking arguments is just a bamboozling view
Is it not possible to do it so you can change motd to anything in config?
should i probably change my ip :///
Calculate spaces
and word sizes
there was a lib some time ago
until its in the center
Geo there is probably tons of other organizations that picked up ur ip
lool not even close
wouldnt they be like
Trust me, there are worse places for your IP to get
like?
black spigot is literally just where shitheads go to post a plugin they have bought so others get it free. Not even close to the blackmarket.
Is it not possible to make it so the MOTD stays in center and you can chsnge the MOTD to anything from config
well
isnt that hard i guess... just check how many characters a motd allows per lane
like... if its 20 chars and the word is HELLO the word have to start at char 7
It's probably easy to make
I think its part client side? doesn't it line wrap for smaller screens?
anyone know why this doesn't work? `if (!(event.getInventory() instanceof AdvancedSettingsGUI)) return;
event.setCancelled(true);` I create my inventory with``` public Inventory advancedSettingsGUI(Player player) {
AdvancedSettingsGUI gui = new AdvancedSettingsGUI();
Inventory inv = Bukkit.createInventory(gui, 36, "Advanced Settings");
Worker work = new Worker();
inv.setItem(11, work.createGuiItem(Material.BLUE_ICE, "§fFreeze Day Night Cycle at current time", "§f(Default on)"));
inv.setItem(13, work.createGuiItem(Material.DEAD_BUSH, "§fToggle plant growth", "§f(Default on)"));
inv.setItem(15, work.createGuiItem(Material.PIG_SPAWN_EGG, "§fToggle Mob Spawning", "§f(Default on)"));
inv.setItem(31, work.createGuiItem(Material.BARRIER, "§fGo Back"));
return inv;
}```
(!(event.getInventory() instanceof AdvancedSettingsGUI is probably why
but the owner is gui: Bukkit.createInventory(gui, 36, "Advanced Settings");
AdvancedSettingsGUI gui = new AdvancedSettingsGUI();
thats the inventory holder
yes
and you shouldn't be checking like that anyway
yes, you're setting the holder. you're checking if the inventory is the instanceof, not the holder
and you shouldn't be doing that anyway
Yh encapsulate inventories instead and compare
Who told u 😳
i mean, personally i don't use them because they're not intended for that purpose
ik
there is no actual issue with using them, you're just not supposed to
They will probably go deprecated anyways
class InventoryWrapper {
private final Inventory inv;
public InventoryWrapper(String title, int size) {
this.inv = Bukkit.createInventory(null, title, size);
}
public Inventory compareTo(Inventory inv) {
return this.inv == inv ? this.inv : null;
}
}```
the method is just an example and you would do a null check then
But I mean a bool method would work as wel
I've kinda given up, is there a super simple way?
This is the super simple way lol
Don’t use holders
but I want to check if the inventory is equal to the one given
I can write an example code
that would be great
here is my old code btw: https://pastebin.com/iXqdEpSR
before I did the inventory holder junk
AdvancedSetingsGUI isnt an inventory itself
you need to ocmpare the inventory holder
either compare the inventory object or the holder
i.e
if(event.getInventory().getHolder() instanceof Holder) {
}
In order to have it; InventoryHolders are random bukkit interfaces and you shouldnt implement it in your plugin; youre not supposed to (md_5)
okay 🙂
I'm reverting my git repo
to remove the inventory holder
I'm going back to an hour ago
abstract class InventoryBase {
protected final Inventory inv;
public InventoryBase(String title, int size) {
this.inv = Bukkit.createInventory(null, size, title);
}
public final Inventory compareTo(Inventory inv) {
return inv == this.inv ? inv : null;
}
}
class ExampleGui extends InventoryBase {
public ExampleGui() {
super(9, “Example);
inv.addItem(new ItemStack(Material.DIRT);
}
}
class InventoryListener implements Listener {
private final InventoryBase inv;
public InventoryListener(Main instance) {
instance.getServer().getPluginManage().registerEvents(this, instance);
inv = new ExampleGui();
}
@EventHandler public void onClick(InventoryClickEvent e) {
Inventory inv = e.getInventory();
if (this.inv.compareTo(inv) != null) {
//inv is ExampleGui
}
}```
}
Something probably went wrong when typing
But this something like this
why are those package-private
not bad code, i just dont like those methods in the constructors.
how could I edit my code to make it work?
What’s ur current code
Feels like I’m unprepared