#help-development
1 messages Β· Page 1405 of 1
it would yes, but seems like a pretty fragile approach
ideally you would call the server saving the data and ask it to tell you when it's done saving
what else could I do?
yeah
but
I don't want it to depend on the other server that is saving the data
or use the transaction support of your database to make sure that the data is complete before you try reading it
it all depends on how you're networking between the servers
I'll try some things out and I'll see what happens
if all else fails, have a little value in your playerdata as stored in the db indicating whether the player is on any server currently
when the other server is done saving the data, it will set that bit to false
Have you looked at the source for compareTo()?
that would work too
and the other server would not try loading it before the bit is set to false, and then immediately set it to true
atomically, ideally
ok I'll figure it out
idk how to word this but how do you make a "webpage" like dynmap although im doing a stat api
String.compareTo doesn't actually compute the distance
it just checks whether each element is > or == or < and fast returns
iirc anyway
Serious Spigot and BungeeCord Programming/Development Help | Ask Questions Here
why does this sound so ironic?
srs bsns
:'D
https://ghostbin.com/paste/rAL6n this gives me this error: https://ghostbin.com/paste/embHN
we don't have line numbers
we can't tell where the exception happened
paste the entire class
or tell us which line is line 178
contents.put(player, player.getInventory().getContents());
contents is null or player is null
hm
I rewrote all of the classes
testing it now
@wraith rapids problem
the Thread.sleep thing doesnt work haha
it still calls PlayerJoinEvent
not until async prelogin returns
[20:00:13 INFO]: {}
[20:00:13 WARN]: java.lang.NullPointerException
[20:00:13 WARN]: at nl.blackminetopia.minetopia.modules.player.events.player.PlayerJoin.onJoin(PlayerJoin.java:73)
[20:00:13 WARN]: at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor433.execute(Unknown Source)
[20:00:13 WARN]: at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70)
[20:00:13 WARN]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78)
[20:00:13 WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
[20:00:13 WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:513)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.PlayerList.onPlayerJoin(PlayerList.java:370)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:183)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:178)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:68)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:273)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:150)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:948)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:774)
[20:00:13 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:666)
[20:00:13 WARN]: at java.lang.Thread.run(Thread.java:748)
The {} is output of an HashMap that 100% has an item in AsyncPreLogin
i don't know about 1.12
but in any modern versions player join 100% can not fire until the async prelogin event returns
it has a pre in the event name for a reason
I understand that
I'll try and put my Thread.sleep from 3 to 1
seconds*
lmao
I already found my mistake
I have like warp signs but for bungee
in the same event above it checks if you have to be teleported if not it returns
so that's why my hashmap doesnt get filled
i have an egg that creates an explosion using world.createExplosion() listening to projectile hit event, if a player dies from that explosion how do i give credit to the killer?
so actually the shooter of the egg
@wraith rapids It all works, I just want to say thank you π This made it so much faster.
ππΏ
use the correct method to pass an Entity source https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#createExplosion(org.bukkit.Location,float,boolean,boolean,org.bukkit.entity.Entity)
you know what grinds my gears
that there's no short circuit assign-or or assign-and
half a kingdom for a ||=
im trying to make a json api with player and server stats
and then what?
well see that's something im not sure of
and output it through outputstream
i don't even understand what you're trying to achieve
download the internet
ever seen hypixel's api?
and save it to disk
no
egg is a projectile which you can use getShooter() and pass that as the entity in the explosion
i'm sure he has seen the spigot api
considering how this is the spigot api development channel
are you sure you know what api means
so itβs an explosive and projectile at the same time?
is it code smell if i parse static json without the json library via hardcoded parsing code?
i mean i shoud probs switch to gson
No, you are passing the source of the explosion as the shooter of the egg
probably yes
What would be a good way to let my challenge class listen to specified events, without having a bunch of onEventName methods to override
i wanna make something just with player stats
but its not hypixel
and that way the killer will be set as the shooter if i do player.getKiller?
you need a webserver
to host the service
first
hypickle hypickle
it should be yes
ok iβll try it thanks
well i can't show you theirs because you need an api key and u are supposed to use ur own or else you can get api banned
why would hypixel provide an api in the first place
to scrape username accounts lol? π
but they're internal
games and stuff doesn't require an api
people have made amazing stat website and stuff
a public api, anyway
yeah
someone made it on a fabric mod
but im switching to spigot
and pull the data from there, store it inside json and display it
and one more question.. supposing that the egg will also apply poison to the target and if he dies from the poison how do i give credit to the killer?
90% of the code is unrelated to fabric or spigot
ik
just cuntpaste the code
im not copy and pasting
Can anyone help me? I have a bungeecord server, premiumvanish plugin is installed on it, it is not detected by bungeecord. does anyone know what the problem could be?
and change the few bits and pieces to interace the spigot api
that wouldn't work
no
create your own api of your server
or look at how they did it
infinitely more helpful than asking everything 1 by 1 here
all i need to know is how people make those pages hosted on a mc server
no idea
like dynmap
by running a webserver
webserver
and backend language
css for design
yeah but then how do i link it to mc
via database?
a webserver is a webserver
or redis?
ik how to make webstes and stuff
it's just spinning code
but an api doesn't do that
it doesn't matter whether it's standalone
use databases or redis
or packaged in a plugin
to speak with your server on webserver
if you store your data in a database which is not dynamic in runtime
just access the database
of the server
via programming language
of your choice from backend
you can even use java i think
but i prefer php
or node js
its the same process as hooking your plugin to the sql database
https://paste.md-5.net/ojosasadod.cs was my first idea, but it doesn't work
I still struggle to wrap my head around generics
damn i cant get rid of this error ever since i got a god damn server crasher creeper from wrust
hmm i deleted the playerdata from the world
playerdata is stored inside playerdata folder
what am i even looking at
nowadays i think
yes i know
That error comes from your kitplugin?
that isn't even playerdata
Hello! Today I am showing you an API I made, which allows you to host websites without any external libraries, simply by running the server.
Cons...
that comes from some shit tier kit plugin trying to parse a yaml config
see something like this
this
that's literally a fucking webserver
yes, and like I keep telling you, a webserver is a webserver
it doesn't matter where it runs
it doesn't matter whether it's standalone or fired by a plugin
the shit under the hood is the same
just the entry point is different
wait its from a plugin called kits?
at me.sg.kit.KitPlugin.onCommand(KitPlugin.java:158) ~[?:?]
oh i see
how did i not see that line
if you're trying to make dynmap like plugin
use this
but for an api
this is not what its used for
but it also have line other at blah blah blahs
eg: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[server.jar:git-Paper-463]
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
all it does
it wraps JDK's dedicated webserver
oh
or more specifically, the plugin code asked snakeyaml to parse a config file
which asked the server to deserialize an itemstack
which is slow compared to webserver like litespeed
and that blew up
or nginx
in particular it blew up while trying to deserialize the item meta of a spawn egg
You do not want to import com.sun.* packages
and in particular it exploded because the serialized entity type of that spawn egg is minecraft:Creeper
and not minecraft:creeper
delete or clean the associated config file
as for which config file it is, nobody knows
yea these are proprietary
iirc
not recorded in the stack trace
that is not the thing
The thing is that they no longer work in modern versions of java due to modules being a lot stricter
okay thanks i fixed the issue by deleting a segment of a yml file that i did not tell the plugin to read
but its old
weirdddd
the entire yaml file is read at once
the sun unsafe class still exists
it doesn't go to the disk to grab the specific path you want when you call get
it loads the entire file into memory at once
and parses it all at once
the only thing i found there interesting is volatile arrays (not reference to the array)
what are those?
they kinda do exist
they're arrays whose elements are volatile
java volatile or something else volatile?
same principles apply to the array elements as would apply to a field declared as volatile
yeah, java volatile
volatile array would you be able to read items from primitive arrays without synchronisation from multiple threads, since it would flush LM cache everytime it access
having to synchronize on an entire array or some shit just for memory visibility in a specific index is cancer
is there are manual way to flush LM cache apart from using synchronised codeblock
i've even occasionally gone fuck it and just created a class with like 20 volatile fields or however big of an array I needed
you only need one to update whole class fields while accessing that volatile field
but of course that's fucking cancer too and only works for that exact array size and accessing it is even more cancer
well i mean synchronized code block doesn't flush anything either
that's a misconception from people dumbing down how memory barriers and shit work
the actual underlying mechanism under the hood is fucking eldritch black magic and unknown and varies from mpl to impl
yesterday
if the machine had to flush the related cache every time you refer to a volatile field or enter a synchronized block you would literally never get anything done
it's more fine tuned than that
Maybe i'll just stick with an abstract method for each event, even though that is ugly
The Java volatile keyword can be applied to Java variable declarations to force the Java VM to always read the variable value directly from main memory, and always write changes to the variable directly back to main memory immediately.
Chapters
0:00 Java volatile introduction
0:41 Non-volatile variable visibility problems
2:27 Java volatile vis...
well this video
says that if one volatile field is accessed or written inside that thread
whole fields from thread are gonna be flushed after volatile field is written or read
i just can't find the right timestamp for it
ofc it its
f.e an uncontended volatile is almost as fast as a regular field
while a contended volatile is much slower
in a language as abstract as java you are kind of fucked when you step into the territory of "how do I make the machine flush this particular cache"
because there is basically never any guarantee that the machine does what you want
yea
it might just not flush it in all silence because it deems it unnecessary
i would love to have an optional ability to destroy objects
like in c
since those are on heap
i mean it could run garbage collector, but it should give an ability to destroy them manually instead of waiting garbage collector
touching anything related to the gc is kind of eeh as well since that is its whole own sector of black magic
I'm looking forward to the rust
some dude just showed me couple days
how awesome that compiled language is
and i should give it a try sometime in a future soon
you look like you're getting an aneurysm
wat
how many days did he show you
how can i reorganize the numbers in the config yml?
i currently have this config yml https://paste.md-5.net/olojiqamon.bash
i want to delete any number and be able to rename the rest to the next number if its not null
or rename the current one to the number in a foor
so far i have this
System.out.println("test1 " + Main.get().getConfig().get("beds." + player.getUniqueId() + ".bedsLocation." + beds));
System.out.println("test2 " + Main.get().getConfig().get("beds." + player.getUniqueId() + ".bedsLocation." + (beds+1)));
try{
if((Main.get().getConfig().get("beds." + player.getUniqueId() + ".bedsLocation." + (beds+1))) != null){
System.out.println("test3 " + beds);
Main.get().getConfig().set("beds." + player.getUniqueId() + ".bedsLocation", beds);
}
}catch (Exception e){
player.sendMessage(getErrorMessage());
}
}```
but it doesnt work
it does this https://paste.md-5.net/qafifapiyu.bash i deleted that bed it just didnt rename the next one
getInt / getDouble
don't forget to include default value with that provided, if value doesn't exist or is invalid it will always return 0 by default, and that could cause issues since it returns primitive
@worldly ingot Regarding piglin trade event would it be beter to return an offlineplayer as a trade can still happen if a piglin picks up a trade item dropped by a now offline player
swallowing exceptions
Ah okay those are locaations
how about you don't just catch and swallow an Exception
I believe there is a getLocation
what are you going to do when your player says they got an error message from the plugin?
the error message won't contain any useful information on where the exception happened or why
I'd just say an online Player instance. If they're offline, don't bother.
you are literally incapable of debugging this command and figuring out what went wrong
wdym
return an UUID
its not done..
don't swallow exceptions
if the config file doesn't contain that particular value you're asking it would return primitive int with default value 0 in it
throw a e.printstacktrace in there even if you're not done
yes ik i will add some kind of id, its clearly not done since the main purpose of the plugin is not working
strangely it doesnt return Integer object instead for that
ah
returning an object would force our aspiring and brilliant newcomer developers to nullcheck their values
and is there some kind of next? like Main.get().getConfig().set("beds." + player.getUniqueId() + ".bedsLocation." + NxtValue, beds);
If the int does not exist then the specified default value will returned regardless of if a default has been identified in the root Configuration.
Can someone tell me why this is not working:
@EventHandler
public void onEnchant(EnchantItemEvent e) {
System.out.println("ran!");
Player p = e.getEnchanter();
int randomMultiplier = new Random().nextInt(254) + 1;
ItemStack item = e.getItem();
Map<Enchantment, Integer> enchantments = item.getEnchantments();
for (Enchantment ench : enchantments.keySet()) {
System.out.println(enchantments.keySet());
int oldValue = enchantments.get(ench);
System.out.println(oldValue);
enchantments.replace(ench, oldValue * randomMultiplier);
System.out.println(randomMultiplier);
System.out.println(enchantments.get(ench));
}
item.addUnsafeEnchantments(enchantments);
System.out.println(enchantments);
}
everytime an item is enchanted it should multiply the enchantment level with 1 - 255 value
better to crash than to get a bug
but its not doing it, its just giving the item the normal enchantment
like my code does not even exist
ThreadLocalGenerator
enchanting events are pretty fucked up
use instead
you might need to use prepare enchant event, if that exists
your code thread include random number generator internally
but
Any of my debug messages
is not even running
only the first one
and the last one
nothing inside the for loop
what about the last one
that means map is empty
System.out.println(enchantments);
Excuse me what were did you learn that... Its the sole reason we got try catch
if its not iterating
its printing out []
so maybe i should use
preparenchant event
or whatever it was
cuz i rly dont understand what im doing wrong in my code
returning an object would force our aspiring and brilliant newcomer developers to nullcheck their values
that was a response for this particular answer
Ugh the bot again. As i was saying, Always nullcheck if the method is nullable or not specified because lord knows most MC devs dont bother using nullable annotations
In IntelliJ it infers that and contract
yeah, we were discussing why MemorySection doesnt have a method for returning boxed integer instead of primitive one, but eh
Just autobox?
MemorySection in bukkit?
if it's printing out [] that means there are no enchants
are normal maps immutable?
and the for loop obviously won't run
like you cant replace stuff in them?
primitive int isnβt nullable
i were thinking how it be possible to spawn spefic custom mob with model and texture using spigot?
it would way better if it used boxed return types
If you want a boxed integer then just autobox or what? Am I misunderstanding
Yeah dovidas
What type of map is it
Or smtng like OptionalInt ig
Hashmap is mutable
dovidas, are normal maps immutable? I tried PrepareItemEnchantEvent, that just threw an error after enchanting, cuz its telling me that im doing unsupported operation, the error points to the line where im replacing something in the map
Coll
let me send you my code
I swear can this bot get off my back
no they're not
@EventHandler
public void onEnchant(EnchantItemEvent e) {
System.out.println("ran!");
Player p = e.getEnchanter();
int randomMultiplier = new Random().nextInt(254) + 1;
ItemStack item = e.getItem();
Map<Enchantment, Integer> enchantments = item.getEnchantments();
for (Enchantment ench : enchantments.keySet()) {
System.out.println(enchantments.keySet());
int oldValue = enchantments.get(ench);
System.out.println(oldValue);
enchantments.replace(ench, oldValue * randomMultiplier);
System.out.println(randomMultiplier);
System.out.println(enchantments.get(ench));
}
item.addUnsafeEnchantments(enchantments);
System.out.println(enchantments);
}
i got an error at enchantments.replace
Nuxoria if you get UOE then itβs probably immutable
by default maps cant have null keys inside it
so check if object is not null before adding it to the map as a key
Nuxoria did you read the JDocs
?
negative
How about you do that before asking questions most of the times JDocs answer all questions
Thereβs no by default there, it depends on implementation
@mortal hare Well yes but no in java everything can technically be null π
thonk..
primitives can't
^^
?
True
Objects can be null, but not primitives and that's the point of this discussion. Bukkit configuration api when getting value from memory return primitive int instead of boxed integer, that way it needs to fallback to its default values of primitive, instead it could be checked as null
Well as much as i understood from the jdocs
I mean isSet exists
my map is immutable
aka i cannot modify it
aka im fucked
aka i got to think a new method
oh well the reason for that is mojang the more complex explanation is in hub.spigotmc.org/stash
maps are not immutable, unless you use some kind of implementation of it
What unless you defined some kind of write lock implementation thats just not true
Map<Enchantment, Integer> enchantments = item.getEnchantments();
It does say on the javadocs it returns an immutable map of the enchants
this is my map
Correct, this is what add and removeEnchant are for
there's specific methods for adding enchantments
What event are you using
Get map of enchantment (levels, keyed by type) to be added to item (modify map returned to change values).
are you using prepare?
Iam now since EnchantItemEvent basically didnt even run my code
Im trying to multiply item enchantment levels everytime they are enchanted
so if you enchant and get sharp 2
Is this a bug? its supposed to work easily
@mortal hare where did you find that code
its immutable since it uses custom extended class which is extended treemap
intellij magic
I get that but what class
Why you trying to edit the enchantments on a itemstack use the event method
most developers have sources
@wraith rapids I got the full source i dev for the main branch
Well last time i wanted to try this but i ditched it:
e.getItem().addUnsafeEnchantment((Enchantment) e.getItem().getEnchantments(), randomMultiplier * e.getItem().getEnchantmentLevel((Enchantment) e.getItem().getEnchantments()));
What i do is use some kind of method to get and object which i want to peek at,
then i do CTRL + left click to peek inside and then if its interface i right click, press go to, and click go to implementations
Yeah but your doing it wrong you need to modify the map that the event gives you
its very useful and saves time
Im well aware i used intellji the past 4 years now xD
you can also use middle mouse button instead of ctrl-lmb
Dont ask questions when it comes to NMS please
π
We hate touching that dump tbh but we cant avoid it
i guess the tree map is slightly smaller for most items
memory footprint wise, anyway
but like, I doubt that's the driving force behind that decision
so anybody has any ideas
mojang and performance or efficiency don't go hand in hand
@vital ridge EDIT the map the event gives you
but its slower
YES!
Aight
EnchantItemEvent:getEnchantsToAdd
idk why I am so lost to this: I want to make a variable int hashitmanytimes in EntityDamageByentity event and every timeplayer hits a entity the value goes up by 1 like hashitmanytimes = hashitmanytimes++; but hashitmanytimes needs to have a value of 0, but I just dont know where to put it so if I hit an entity the value will not be set to 0.
What
what
so basically when player hits entity then hashitmanyitems goes up by 1
hash it many times
HasItManyItems
has hit many times
yes variable called has hit many times
Hash it many times lol
EventHandler?
Yes
@EventHandler
public void onEnchant(EnchantItemEvent e) {
Player p = e.getEnchanter();
int randomMultiplier = new Random().nextInt(254) + 1;
ItemStack item = e.getItem();
for (Enchantment ench : item.getEnchantments().keySet()) {
int oldValue = item.getEnchantments().get(ench);
item.getEnchantments().replace(ench, oldValue * randomMultiplier);
}
}
hello
.
can you hear me
no
No No No @vital ridge modify the event map not the item
alr going bac to learn what hash is
-------------- >>>>> EnchantItemEvent:getEnchantsToAdd <<<<<--------------
this
Theres no EnchantItemEvent.getEnchantsToAdd
There is do you need glasses jesus christ
Omg he is trying to statically access it
inb4 he's trying to autocomplete it on the itemstack
Nope static access attempt
numbnut
@vital ridge access it thru your instance jesus
Not to be rude, but you should probably learn basics of java first.
^^^^ this so much
any1 know a good rank shop that u can sell luckperm ranks on
#help-server, @tender aspen
is hash just pretty much checking if 1 value is equal to another
hash my browns
no potato
stupid potato
anyway
describe what it is that you want to achieve
and what I mean by achieve is not "i want a variable that does this", I mean what do you need that variable for
hashing is like roughly putting a data through hydraulic compressor. you can decompress it, if its backward decodable.
your question is nonsensical and nobody has any idea how to answer you
Has anyone of you had to look thru the spigot source NMS classes
yes
im doing it rn
Im crying RN have to access some very old nms
i've had to fuck with nms plenty as well
this shit looks like it was writen by a monkey on a typewriter
one of the more irritating cases is the lobotomizer timings integration
aikar just had to go and fuck it up
It may look worse cuz its decompiled but yeah some nms back then wasnt just good
fuck aikar, I will shit on his grave
@ivory sleet Got original access to the mojang github
ah
in paper 1.16.4 or .3, aikar changed the way how entities hold onto their timigns handlers
it used to be that every entity had their own handler reference
basically if player hits entity 10 times then they will get strength, all is done expect the checking if player has hit 10 times
that just referred to the common handler instance of that entity type
Still hurts even if its not method a b c d x
and why does it bother you?
that is to say, I could change the handler of any specific entity, and then that entity would count towards a different timings section
however, he changed it
now, the reference is on the entity type
bruh
which means that to change the timings entry an entity counts towards
I need to create a new fake entity type for it
assign it to that type
then reflectively hack into the final entity type of that entity
and hammer the new fake type in it
is that a struggle for you because you register custom mobs via nms?
it's a struggle because I want lobotomized villagers to show up separately on timings
which means that some villagers need to use a different timings handler than others
^^ perfectionist
why does it bother you to have that timings tab
ok its better to debug
but its not like important or anything
it's really useful because it lets you know how much of an effect the plugin has on the server performance
it lets you keep track of whether your players are keeping villagers in a lobotomizing compatible way
well he probably changed it to have better performance
I think you shouldve told me to just to e.getEnchantsToAdd since i dont know those keywords
doesn't affect performance really
I now understood what i need to do
or have less memory footprint
it's just an extra field access per entity per tick and an extra 32 bits of memory per entity
literally insignificant
eulers constant
Yea okay gotchu, i just dont know those keywords lmao
keyword?
Thanks anyways
:: and # refer to instance methods usually
Keywords?
. usually refers to static methods
did he just call an instance a keyword
javadocs inconvenience uses # for both static and instance methods π₯²
Just pay attention to the access types
I swear to god im gonna have a mod pin Read the documentation before asking a question or something along those lines
!jdocs
darn
the # in javadocs is just a html anchor for the specific line on the page
Static method (initialised only once and only when called first time) - ClassName.staticMethod();
Instance method (initialised once per instance) - Object.instanceMethod()
Same rules are valid for fields too
i might be wrong about static intialisation time, but that's valid for fields idk
how tf I have read so many articles of Hash and all I have gotten is "key"
Yeah there is no instantiation in statics i believe
hash has nothing to do with what you're trying to do
Hash is a blob of encoded data which can be used to secure data or be compressed and then decompressed with special programs, and its used in blockchain like cryptocurrencies
What are you mentioning is the HashMap. Its a map with key value structure, which uses Hashes to access the data fast by using key as an object
no i just said that your variable looks like hash it many times
hash it many times
has hit many times
anyway, what you want is not a variable
you want a map that keys Player -> number of times hit
which incidentally is going to be a Hash Map
but you can just forget about the hash part, that is coincidence
and now he is even more confused
I kinda dont want u to giveme answer but just what do I need to do
do you know what a map is
hashmap ?
no, a map
Map is literally a map
a map is a thing that associates things with other things
but stored inside computer
for example, a map could associate a player's name with the number of times that player has punched
then you could give that map a player's name
and it would return you the number of times they've punched
so basically map just stores values
Yes
so what is the diffrence between int ....; and map
lemme gimme an example
map is a String ?
actually 10,000 or like u meant infinity
indefinitely many yes
have you ever used a phone book?
you know, a book with peoples' names and phone numbers in it?
Player player = e.getPlayer();
Map<Player, Integer> playerData = new HashMap<Player, Integer>();
kills.put(player, 5) // Sets data for that player to 5
Integer kills = kills.get(player); // Gets the data of the player
if it has names of people, yes
its values are the persons' phone numbers
I read exactly that
if you want to know someone's phone number, you open up the book
you find the name of the person
and then you look at the phone number written next to it
doing this is the same as calling map.get(person's name)
map.get(person's name) will return person's phone number
hmm is it possible for a plugin to make mobs fight other mobs
Map<String, Integer> numbers = new HashMap<>();
numbers.put("John", 440547865);
Integer number = numbers.get("John"); // Gets number of john from phone book map
put
yes I got that
kek
well, now, you want to track how many times each player has punched
you create a map
with the players as keys
and the # of times punched as values
and then just call .get and .put accordingly
so I make map put like Playerkills, 10
and then I get Playerkills and it is 10
Hello π Have a question... I am now working on custom virtual inventory, that player access with command and I want to allow player to take items from that inventory out to their, but not from their inventory to the virtual one. Can someone help me with this out?
I am here no idea what next
Map<String, Integer> PlayerKills = new HashMap<>();
PlayerKills.put("hashitmanytimes", 0);
you want to use the player's name as the key
I am glad I am even here lol
that way every player will have a record in the phone book
when your plugin starts, your phone book will be empty
because nobody has punched yet
click event, drag event
PlayerKills.put("My name", 0);
you don't have any phone numbers to record
but when someone punches
you want to listen to that event
open up the phone book
and then increment the value in the phone book
if they aren't on the phone book yet, you add their name and write 1 next to it
well yes, tried some things, but it only register the initial click, not the placing one...
if they are, you replace the number next to their name with a bigger number
check if clicked slot id is lower then top containers lowest id
if (map.contains(player.getName()))
check whether the player is on the phone book
if they are, get their current number
or the opposite
int number = map.get(player.getName())
and then increase it by 1, as they just punched
number = number + 1
then write it back in the phone book
so this
Map<String, Integer> PlayerKills = new HashMap<>();
PlayerKills.put("MrCooxie", 0);
Should not be in EntityDamageByEntityEvent
and store it somewhere
map.put(player.getName(), number)
no, what you are doing there is hard-coding the name
you want to get the player's name
if clicked slot is higher than bottom inventory's highest slot, then cancel event
otherwise dont
if you want to place items inside
but not outside
well i create the inventory from mysql data, player votes, with votifier i store the number of votes in db, then when creating inventory i take the number from db and make it as same number of specific item. and i need to allow user to only take this items out, like as atm, not allowing to put anything back... when they take items out, it triggers event that count items that is left in inventory and save that number back to mysql...
Sai Nnya...
you don't have any phone numbers to record
but when someone punches
you want to listen to that event
open up the phone book
and then increment the value in the phone book
if they aren't on the phone book yet, you add their name and write 1 next to it
How the hell should I know how to do that.
didn't you have a code snippet earlier where you were listening to like player interact event or something
literally do what i said
but opposite
if clicked slot is lower than top inventory's highest slot - cancel event
How you guys get so good at java like bruh
we started with a guide on how to deal with java
wait till you see C
and then we did java until we got comfortable with it
then, and only then, did we move to the bukkit api
C is more archaic than java
but it disable moving items around player inventory as well?
also really hating yourself helps if you want to sink days or months of work into java
Hello! I finished setting up a spigot local server earlier and i'm trying to make my first plugin ! I'm following the gradle tutorial on the wiki, and i'm wondering, which sdk is better? Are they all just as good or is there an advantage to going with version 11?
I have 0 experience with Java or making plugins/servers
it disables whole bottom inventory clicking
what you can do actually
is to check
isa snippet another java thing
if clicked slot is inside the top inventory range
snippet just means like
excerpt
part of something
not programming or java related
it's just an english word
and in this example if i check if click is on top inventory, it will prevent user from taking the items to their inventory
I have
@EventHandler
public void onhit(EntityDamageByEntityEvent event){
event
If anyone could help me it would be great :)
we're not going to be your interactive "how to learn java and bukkit" tutorial
? what
if you have 0 experience with anything, go read some guide
if (e.getSlot() <= e.getInventory().getType().getSize()) {
e.setCancelled(true);
}
try this
then come back with at least a little bit of experience
this would not let click inside top container inventory
learn java first; look up some guide and then try doing some simple excercises with it
Listen man chill out, I was just asking about the jdk because I couldn't find anything online, I apologize if it's making you angry.
I wasn't going to ask anything else
but I understand now
bye
they're nerds
i'm not angry and I am chill
AdoptOpenJDK 11 or 15
what about this?
if (event.getClickedInventory() == inv && event.getCursor() != null) {
event.setCancelled(true);
}
real men go with 8
that should work too actually
you'll want to prevent shift clicking from the other inventory
if you're preventing people from placing stuff
and if you're preventing people from picking stuff, you'll want to prevent COLLECT_TO_CURSOR in the other inventory
@eternal oxide Thanks alot !
Now i'll come back when I have a master's degree
literally told you to learn the basics of java before asking for help here
if you already know the basics of java, then that's fine
Why not 16?
when you say "i have 0 experience with anything" i'm going to assume you don't know a single bit about java
1.16 uses java 16 yes?
no
kek
java 11+
yes
Yes, if you make it
it uses JRE 3.0 at 3 AM
Java 1.8
omg why it cant have initiation click event and destination click event... π
because mojang is too dumb
to include it in their packets
when you shift click
it doesnt tell you where the destination
is
in sent packets
kinda dumb since client calculates destination and then server recalculated that destination
that's no excuse for bukkit not to include it though
doing twice the job
the server computes it anyway
InventoryMoveItemEvent like this will be the best one, but it does not work for player interaction...
might as well expose it in the api
now it needs to be done once by the client, once by the server
Bukkit is not implementing this
and once by every fucking plugin individually
how a plugin to make ranks apear on ur head ?/:
it would break backwards compatiblity
oh yeah those poor fucking 1.8 plugins
its an internal NMS implementation
still should be exposed in the bukkit event
which i cant find lol
i overriden that
to calculate proper shift clicking
only in bottom containers as i provided
is that the thing you've been fucking with for the past few days
it doesnt
but it computes it wrong according to the rules of GUI
looks like i leave the idea of inventory, and just give them the items with commands...
is there a difference
do you want to have shift clicked items in to the GUI elements itself?
what's a gui element
what
Inventory GUI's ffs
you have completely lost me
Have you heard of concept - Inventory GUI's
yes
try to shift click
while open
it will end up in the inventory gui itself
that's why i overriden it
ah so you mean you want to reimplement shift clicking so that you can blacklist certain slots from being shift clicked to in such guis
kinda
i looked into that at one point as well
and then decided it wasn't worth the effort
i already did it
it works pretty well
but its not blacklisting
it disallowing it for all the types
idk
I mean*
some guis could have slots that you can use as if it was a container
is your thing flexible enough to let me shift click shit into those
yes
so it goes on a slot by slot basis
do yall remember my enchantment issue?
Did you just correct me
Basically , nothing wrong under the event
goddamit
But i was wondering
On a message from February
that bot
how could i do it under a normal runnable (runtasktimer)
why is it necessary for this to happen on like the packet layer though
because my implementation is packet based
since inventories in bukkit are synced
and having GUI synced for no reason is kinda useless
is it not possible via events
the thing is my GUI api prevents dupes
since my items are packet based
even if they would get the item out of the container
ok why are your items packet based
because they're decorations
is your entire server on the packet layer
which shouldnt be picked up
you could do that with events just as well though, right
I cant say I've had any duping issues using standard events
Except when I realized open inventories for sleeping players is jank
it could lead to bad consequences
also you don't need to send bunch of packets
to the client
while with inventories you need to since they're just inventories
meanwhile fucking ImageOnMap dev team refuses to patch a gui dupe issue that spawns in barrier blocks
because "it's a minor bug and kind of rare"
fucking
that's why i was inspired to do this kind of shit lol
had to fork that piece of shit and change the barrier icon in the gui to like red glass pane
to prevent this shitty dupes
That usually translates to "we've no clue how to fix it"
it's happening in the depths of some shit tier library they're using
i wouldn't be bothered to fix it either
Anyone with more than half a braincell when it comes to generics know if I can make something like this work?
have I showed you my train
is there an event for when someone changes dimensions
ok thanks
what even is this?
Searchup RedLib
they have some kind of implementation
what you're looking for
with function lambdas
Ahh yeah registering an event inline would be decent
What is plugin to make ranks apear on ur head ?/:
I assume registering a bunch of listeners isn't too much different to registering one listener that calls a bunch of methods performance wise
i use RedLib, pretty nice to do new EventListener<>(Event.class, evt -> {})
Yeah that's basically what I wanted to do with my Map<Event, List<Consumer>>
So it should work well
nametags
generics are funky
i made me a train
it's kind of like a linked list but every element can be of a different type
and it's type safe π
isn't that like a node
dunno, wouldn't node imply that there's more than 1 neighbor
this is a singly linked list so every element only points at the next element
i don't think it's possible to make it type safe if it's doubly linked
well, actually, I guess it might be possible
lemme give a try
Hi, does ProtocolLib have a method that I can access to the dimension manager.
I need to send the player the PacketPlayOutRespawn packet and I need the dimension manager because of I am using ProtocolLib.
i think you get it from the NMS world
every Entity has its own UUID.
Is anyone familiar with splitting a large schematic into something smaller that a server can manage without panicking? I've heard FAWE is highly unstable in 1.13+ though I can't confirm but, if this is true, I would like to steer away from it. Furthermore, I'm willing to trade time for stability
Any help would be appreciated
how many 5 star reviews are you willing to pay
8
wtf
i tagged you??
lol
i haven't noticed that i've tried to reply to u previously
i use lightcord
that's electron based though right
yeah, i can't really afford to run random extra browsers for every application I have open
limited resources and whatnot
true
if only discord like UI existed on ripcord i would gladly switch
now it looks like Visual Studio 2019 lol
i like things bare and simple
eyecandy is useless
plus being able to switch between accounts with a click is nice
and I don't need to deal with discord's "logged in from another location" fucknuggetry every time I use a different machine or change my ip range
since it uses bare auth tokens
no captchas or anything fucking excessive
you just slam the key in and you're in
just like god intended
I mean you can create your own, but that would be tedious lol
Hi, is there a way to remove the death particles of mobs ?
The little "poof"
It should be "Particles#EXPLOSION_NORMAL"
But cancelling this packet doesn't seems to work :/
have you tried debugging it
if it fires
?
what you can do instead then, if client is fucking around - just set mobs health to 1 heart before its dying
then play death animation
and after 0.5 sec send entity destroy packet
then kill the entity in the server
idk if it would fire up the entity packets
probs it would
or remove it somehow from world