#help-development
1 messages Β· Page 2193 of 1
it will keep get NBT from all player , print to console
hmm, i want get NBT by NMS function
getNBTFromEntity(Entity target)
if it is player , it can not work
but if is is not player (cow , sheep ,etc) it can work
Lmao is so strange, MongoDB by default doesnt save documents with objects. But i setted a class as codec and now i can save class object directly into the collections
Is it recommended to use a db or json/yml for massive player storage?
db
any specifics? mongodb, sqlite etc
it depends on what you're storing
say economy and magic stats
whats a good use case for mongoDB then?
so sql is very structured
Mongo not so much
In reality, everything has a use case. For most of this its up to preference on what you use
so, in your opinion, which is easier for a beginner in DB's?
most ppl using spigot start with sql
then ill look into that, ty for the help :D
Y
Pretty sure a player is a CraftPlayer
Could be wrong
ok
if (!plugin.getConfig().getStringList(event.getMessageId() + "-likes").contains(event.getInteraction().getUser().getId().toString())) {
likes += 1;
plugin.getConfig().set(event.getMessageId() + "-likes", plugin.getConfig().getStringList(event.getMessageId() + "-likes").add(event.getInteraction().getUser().getId().toString()));
if(plugin.getConfig().getStringList(event.getMessageId() + "-dislikes").contains(event.getInteraction().getUser().getId().toString())) {
dislikes -= 1;
List<String> likelist = plugin.getConfig().getStringList(event.getMessageId() + "-dislikes");
likelist.remove(event.getInteraction().getUser().getId().toString());
plugin.getConfig().set(event.getMessageId() + "-dislikes", likelist);
}
plugin.saveConfig();
}``` For some reason, it is saving as ``true`` and not a list of Ids.
Whyyyyy
My eyes!!!
Make a config object lol
So you donβt have to constantly do plug-in.getConfig
Anyway lemme look into the other thing you said
does anyone here know how to best serialize/deserialize BlockStates?
No idea why it would be saving as true
what do you need it for?
well bassically creating a very basic version of a schematic
without all the tileentity stuff/entity stuff
just blocks & block states
is getPersistentDataContainer also do get nbt from entity?
split the string by some character, parse world, xyz
slice "[" and "]" off , and split(",") , get [0~2] and put it to a list or vector or array.
well yes and no
orrr dont do all of that and serialize it using an easier patern
hm well you could use the BlockData which implements ConfigurationSerializable, and then for stuff like Container additionally save the inventory
but serializing BlockStates themselves? No, not possible, but also not helpful because there's no thing like block.setState anyway
then how did worldedit do that
they preserve blockstates in schematics
isnt there BlockState#getAsString?
ya but doesnt the data contain the state?
let me clarify i just need a way for, for example stairs to keep their direction
am i gonna need to write a custom serializer/derserializer for each thing?
for example, BLockData can tell you
- is a block waterlogged
- how many candles does this block contain if it's a block of candles
- etc...
but it doesn't include the block's inventory (if there's any)
that's BlockData
i dont want inventories
BlockData implements ConfigurationSerializable
you can use the serialize() method to turn it into a Map<String,Object> or you can get it as string using getAsString()
? Wdym yes and no I use it on entities all the time
i dont suppose this is possible using IBlockData.
"yes" because PDC uses NBT. "no" because you cannot access tags outside of the PDC's scope
?paste
A
EVERYTHING that's PDC is stored inside an NBT tag called "PublicBukkitValues"
Oof.
for example i am using this to set blocks really quickly. it would be amazing if i could imcorporate it into this https://paste.md-5.net/inunotuzeg.java
but i have no idea how to do that since it uses nms. and im not that amazing at nms
Welll, PublicBukkitValues iirc is only for those PDC values that are visible to the client
e.g. item meta
as that is sent to the player
are there any other PDC tags that are not visible to the client though?
basically all others are never shared with the client
oh yeah wait
I think on ItemMeta it's always "PublicBukkitValues" and on entities etc it's simply "BukkitValues"
@somber hull
Anyone else know why this happenin?
is there a way i can return two objects from a method and then store those into two vars thru unpacking?
like: var catch, rarity = generateCatch();
first var gets an ItemStack, second gets an enum value
uhh i think thats not possible
you could just make an object holding them both though
awh
would deconstruction work like: return ItemStack, FishRarity; or would you need to add both values to an empty class instance and pass the instance?
wat is it
variables
what about them?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I mostly just want to learn how to use static variables
like put them from one class to another
then find a java course that covers static
ok
a very indepth topic
@dusk flicker im not wrong by when I call a static global variable, I do '(class).(variable)'
yea. because the event is long processed by then
yeah, but it is more involved than that
i think you're gonna need to clear the drops in the event.
then drop the items yourself
so you can keep track of those
to remove them after 600 ticks
well it worked
Yea Item is the dropped item entity if Iβm not wrong. Whilst itemstack is an item that exists in an inventory
If Iβm not wrong
getLocationFromString
does anyone know how to set a variable to a player, like if I had a plugin that makes one person have a spectral arrow, the variable would be set to who has that arrow
I know how to use the variable just not sure what type that is
Player?...
so like
variable HasArrow
and I wanted to set the variable value to the player who has it
how would I do it
?learnjava if you are asking questions like that, you really need to take the time and learn a lot more about Java. These are basically entry level questions
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
You would set it to either a player object or a UUID, in most cases a UUID would be better. I'm directing you to overall Java help rather than just help for the Spigot API based on previous messages
I was just using like setting the players name to the variable
and then if I wanted to check I would just check if the variable equaled a certain players name
yo everyone I'm back bitcheeeees
π
did you just insult my mother's aunt?!
i tried use CraftPlayer , but same , can not get nbt from player
entity = (CraftPlayer) target;
CompoundTag nbt = new CompoundTag();
entity.getHandle().save(nbt); //this return false
System.out.println(nbt);//same as line 2 , empty CompoundTag
Wtf are u doing
get nbt from entitiy
ππ
what did you expect to happpen?!
Asking about your attempted solution rather than your actual problem
the function entity.getHandler().save(nbt)
it should save nbt to nbt in arg
What do u want to do
just get nbt from entity
why?
what do you need it for
i just write it for test
in 99.9% of case you don't need NBT
To test what
Anything wrong with this?
@EventHandler
public void EntityPickupItem(EntityPickupItemEvent e) {
if(Main.BasketballMode == true && Main.HasBall == e.getEntity()) {
if(e.getEntity() instanceof Player) {
if (e.getItem().getItemStack().getType() == Material.SPECTRAL_ARROW) {
Bukkit.broadcastMessage(ChatColor.WHITE + "<" + ChatColor.AQUA + "BlockyRef" + ChatColor.WHITE + "> " + ChatColor.RED + e.getEntity().getName() + " picked up the ball");
e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 20000, 0));
}
}
}
}
it just wont work
?tryandsee
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
well the listener will not detect the pickup
Whatever u wanna get from the nbt u can most likely do player.getWhatever
Did u register the listener
how can i use .setContents and have the contents each set in a random slot?
yessir
I guess discussing with them isn't worth our time and I suggest to simply block them like I aready did
i just want to write a function to get nbt from all entity , item ......
For what purpose
we asked THREE times on why you need it
huh?
and you never explained why
like change entity's name , inventory ...
You should block that person. They keep asking questions without explaining "why" they need what they ask for
What is Main.HasBall
detecting who has the arrow/ball
API exists for this stuff
I call it ball for reasons
Well the person who has the ball won't be picking up the ball?
So that could never run
how can i use .setContents and have the contents each set in a random slot?
whut?
The problem is the message wont even run
ok
put a debug statement at the top of the event listener method
ok
if that still doesn't show up in chat, you didn'T properly register the listener
so if i want to add like 3 diff items to the chest, i want each of the items to go into a random slot
then get a random number everytime and use it to set the item
May lead to collisions
e.g. ThreadLocalRandom.getCurrent().nextInt()
Esp if the chest is almost full
obviously they should check if there's an existing item at that slot
Get a list of all empty slots and get a random number from the list
When u add an item to a slot, remove that slot from the list
And repeat
You'd have to check after you generate the number and you'd be generating a number up to 20+ times at times just to find a slot
Spent my entire day writing one method to load data from a file
Not even done yet
no woman no cry
would this be the correct way of setting up a listener?
getServer().getPluginManager().registerEvents(new PickedUp(), this);
Yes
I have been trying to recover the fucking message because I deleted the shit
Istg
alright lemme try now
no
something's not being done properly
do you have an annotation above your event
can you send your onEnable and your listener class?
ok
he did in the code above
wait of my listener class? u mean my main class?
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Caught(), this);
getServer().getPluginManager().registerEvents(new Pass(), this);
getServer().getPluginManager().registerEvents(new PickedUp(), this);
getServer().getPluginManager().registerEvents(new Start(), this);
}
sometimes , get the nbt of entities help me to get the data from entities more convenient
if i want throw the whole entity data to a file , or throw it to a web server display ......
call every function to get all data seems not a convinient way
now listener class
@EventHandler
public void EntityPickupItem(EntityPickupItemEvent e) {
Bukkit.broadcastMessage(ChatColor.WHITE + "<" + ChatColor.AQUA + "BlockyRef" + ChatColor.WHITE + "> " + ChatColor.RED + e.getEntity().getName() + " picked up the ball");
Projectile projectile = (Projectile)e.getItem();
if(Main.BasketballMode == true) {
if(e.getEntity() instanceof Player) {
if (e.getItem().getItemStack().getType() == Material.SPECTRAL_ARROW) {
if (projectile.getShooter() == Main.HasBall) {
e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 20000, 0));
Main.HasBall = e.getEntity();
}
}
}
}
}
What is Main.BasketballMode and Main.HasBall? Looks like you're trying to set the person with the ball to glowing but if they're just picking up the basketball that would mean you're already tracking them outside of the event?
I have other parts of the plugin that work using similar methods
"ur doing shit wrong"
I already know thats what I am about to hear
So if you're tracking it ouside, maybe set that event's priority to higher than this event
ok
And I would never say "ur doing shit wrong" - clearly you are but everyone will always do things wrong. Even people that have been using the library for years will do stuff wrong
its depricated
yeah those methods seem weird. For example, upper case names. And also "BasketballMode" seems to be a public static variable. That does'nt seem right unless it's supposed to be the same value "for all players"
well I use it for other things and it works, but it is simply bad habits for the uppercase stuff
Static variables in general are bad habits
Honestly, I can't tell why your code doesnt work
bullshit
:/
static is totally fine to use, when one knows what "static" means
static vars can be fine if used correctly
yea but I mean new coders don't need to hear that because then they go and static abuse
that is true, too
i make everything public static. that way i dont need to create stupid instances to get stuff
smart
I just learned how to use static stuff 15 minutes ago btw
Everything is useful if used properly, but most of the time people use it improperly... ESPECIALLY beginners
I did the same thing
mine are public static
learn java before spigot api?
oh shit i forgot there's a beginner here
you know what? You'll think that I'm joking but.. you can make EVERYTHING static in your main class and it won't be worse than not doing that π
i recall my statements
I did not
thatβs a issue π¬
JavaPlugin classes are a singleton by design so there's nothing wrong in making everything static in this class
I just looked at 2 tutorials and then said "fuck it" ima go do my own stuff
and now im here
@knotty gale if you want to upload your code to github or post your full classes to hastebin.de it will help us a lot
?hastebin
someone run the command
?paste
?pastebin
?paste
...
thanks
RIP too late
incase you needed it twice π½
paste your full class(es) in there and we can look
anyway, you can make EVERYTHING static in the main class
what code do I post there though>
The entire class
make entire plug-in in one class π
all my variables are from my main class
should probably have a get instance method
I was serious when I said that you can make everything static in the main class. There is not even one single donwside of doing so
because a plugin is always a singleton object
okay yes but like
send your main class too
why
ok
not everything needs to be static
making things configurable for end users are so tedious because users are dumb
have no end users
I did
why not? imagine your plugin has some "XY" field. You never have more than one instance of the plugin. so why not make the "XY" field static?`You will NEVER EVER hve more than one instance of your plugin anyway
are you using intellij?
;-; what if you wanted to make a non static method reference a static method huh?
you would never ever need it
sure, your choice. all I wanted to say is: there is no point in trying to make singletons behave like normal objects
lmao that's the same thing
it's pointless
βοΈ
sure, it'll work fine. but why bother about making methods non-static if they do not need an instance of the object? and why bother making fields non-static if they could be static?
I mean it's not like Bukkit would allow your plugin to be loaded twice
no, not at all
ikik
I just think that you don't understand what a singleton is π
π
or maybe you do, sorry then
such a polite debate
but every plugin is a singleton and hence EVERY FIELD and EVERY METHOD could be static, although it seems weird
sigh
but it could provoke bad practice in beginners
but there is really no point in ever needing any instance of a plugin when the contract is "there can never exist any more instances than 1 of this class" anyway
that is 100% true
you're totally right about this
recursion πͺ
i wanna write a plugin with public static variables
all global
no method variables
there is literally nothing wrong in doing that
per player public static variables πΆ
it's a pain in the ass to debug tho
wait why donβt you just save variables to a config instead!?!?
it'll remind me of classical programming
why would you hardcore variables
mc is single threaded so it's very possible to do it
https://github.com/JEFF-Media-GbR/StackResize to anyone who wonders, no obviously you should not make everything static. you should however make EVERYthing static than can be static.
NO use of instance = it should be static. Period
everyone who claims otherwise didn't understand the concepts of classes vs instances of classes
the way i liek to think of it for making methods static or not is: is it apart of the class or is it a function for all classes
isn't both the same?
in my brain no
oh yeah no worries
yeah basically the idea is "do all instances of this class share the same behaviour for this" and if the answer is "yes" then it should be static
not exactly spigot related but how can i combine a sharpness 6 book with my sword? thisll come in useful later but is it doable thru vanilla or do i need to make an event of some sort
i donβt think you can do such a thing unless you listen for anvil gui being opened snd like both items are in the proper slots
it would be kinda messy i think
are you asking how to do it in java or with vanilla ?
both
do you know how to use the spigot api and make a plug-in?
indeed, im still learning tho
so how to get nbt from player?
not sure if there is a way to check if a anvil gui is opened / listen for it
yeah im looking as well, im only seeing stuff for when a player is inside the anvil
public void onOpenInventory(InventoryOpenEvent event)
maybe this?
and i check for the inventory type
InventoryType.Anvil
check out this
anvil guiβs slots are one and two so maybe you can listen for it to be opened then in a inventory click event check if those two slots have your items
if so addUnsafeEnchant blah blah
think i'm done
show show
@EventHandler
public static void onAnvilGUI(InventoryOpenEvent openInv) {
if(openInv.getInventory().getType() == InventoryType.ANVIL) {
}
}```
so im here so far, how do i get to check the items which are in the slots?
then iβm sleeping
?paste
use a inventory click event π
spent all day writing this
oh my gosh wait youre so smart lol
and the methods found in it
lmao
best of luck @quaint mantle
now to test
just a quick question, should my EventHandlers be static? i was told earlier no but hmm
expecting alot of failures
ty lol, gn :D
no
nono nono
thanks for the heads up, can i ask why exactly?
oh yeahh that makes sense
how can i get the enchant on an item, f.ex an enchanted book? Im making it possible to combine a sword with a sharpness 6 book or whatever
EnchantmentStorageMeta I believe
item:
type: 'PLAYER_HEAD'
url: 'http://textures.minecraft.net/texture/dfbf1402a04064cebaa96b77d5455ee93b685332e264c80ca36415df992fb46c'
name: '&aNext Page'
lore:
- ''
- '&7Go to the next page'
- ''
- '&7<page>/<num-pages>'
if you had to add more stuff to make this more configurable, what would u add?
thus far, u can add name, lore and if it's a player head, set the texture
it's for a gui so it doesnt need enchantments
I don't think you really need anything else
Maybe add some tabdodging if itβs for a menu
what's tabdodging?
It doesnβt exist
I first heard of it playing Gmod where people would say βstop tab-dodgingβ as if they were chesting
Cheating
But tabdodging doesnβt exist
It just sounds like it exists
how long does it usually take for buildtools to come out after a major update release
Kinda depends
I tend to stop making plugins around that time cause dealing with versions is annoying
So Iβm not 100% sure
But I think like a month max usually
But 1.16 or 1.18 took a long time Iβm not sure Wich one
oh
Have any of you experienced someone trolling you about a plugin bug?
Wdym
A guy dmed me about a bug in my plugin
He says my plugin deletes all it's data on restart which is a pretty easy bug to replicate
Im assuming you tested it
I cant replicate it
Cause there were a few times
Where I got a big report
And used the wrong version
To test it
I'm pretty sure he's trolling because he first message saying it was cleared on death
Redownload it
then it changed to on restart
Maybe
asked multiple times for a plugin list or a video or anything that can prove that it's acually happening and he always tells me to give him some time he'll do it
and then the sends nothing
The wait
Then
If heβs the one with the issue
He should be the one trying to be urgent
You could care less because if he is trolling then itβs not worth your time
people seem to also keep the plugin in their server so ig it works properly
Bro how tf do you set up bstats lmao
it's really easy lol
u use maven?
Ye
u at ur comuter rn and got time?
Nah
But I would like to see an example
How does it work? Are there custom stats you can add?
If so that might be why I was confused last time
yep
All you need to do is put this on your code new Metrics(this, BSTATS_ID);
the harder part is maven
Really?
Mavens easy
Only simple shading
lol
(I havenβt done java in so long lol)
So
I forgot I switched to gradle
And I have no fucking clue how to shade in gradle
u can also just copy a class to ur project
You need to use shadow jar on gradle.
Got it
Iβll figure it o it later
Iβm away from home
Donβt have pc
So add the repo and dependeny and then add this section
shadowJar{
relocate 'org.bstats', 'your.class.package'
}
Yup, it's easier on gradle imo (to shade)
Gradle easier for everything
It has a slower build time than maven tho
You wouldnβt think so because itβs simpler but it is
Maven is slower xd
I have a multi module project, on gradle it only takes 7 seconds, and on Maven it's 20+ seconds to compile.
probably
yes
u can check if there is a setCancelled method
no need to ask here
but that never has any javadocs on what it cancels
its not very clear, and having specifics is always nice on it
when u cancel an event, it's as if it never happened unless another plugin uncancels it or does something with it like broadcast the chat message
am I supposed to push unversioned changes on git? its the random shit in target (thats in my .gitignore) that intellij yells at me for for not comitting
i'd guess just ignore it
aight
my intellij also yells at me for not commiting my resources folder, which contains my mod's assets
M-m-m-mods!!! Thatβs not what this server is for!!! π¨π¨π¨
relax this isn't the forge discord
thank you for getting the point ._.
?
?
What are these repsonses lmao Iβm either really stupid or they donβt make sense
Who are you talking to
I think they're trying to compare you calling on mods to the forge discord, since its a corrupt police state over there
you didn't get the point of my message apparently
but yea, i don't expect much anymore
Got it. Iβm not in there
What was the point lmao
read the message, and you'll get it. hopefully
i was not talking about mods as a thing
and even if i would've been, it doesn't matter, because as people pointed out, this is not the forge discord
agree
getters and setters... reminds me of my horrible c# times somehow
where you had to go into EVERY class to see if something is a getter, setter, or nothing
awful

also, vs sucks ass
fr
kotlin is shit
swear it's so weird
It does do some nice things tho
But it's such a weird language to be a Java alternative
Syntax is too different
well ive got used to it
especially the property access syntax
i find it weird that there is no "new" keyword
but i got used to it
Which ide are u using?
ok
Click on wjat u need to give it and if it is an enum u will see all the possible values
how would i prevent console from trunning it
U figured it out?
running*
Orevent console from running what?
the cmd
If sender is not a player then it is the console
yeah ok
So say you need to be a plauer to run this command and return
I wanna teach u to help urself so show me what u see when u click the gamemode class
im using a trackpad
Ok??
all it does is highlight it green
oh god
So?
im in the code now
i have fould a link to the list hovering over shit
this?
player.setGameMode(GameMode.valueOf("CREATIVE"));
yes
^^
Hey minion, how are you?
sure :)
does anyone know a way of cloning this repo? https://gyazo.com/4432e5b9b64499ce24ec120ccc20104c
are you using spigot or spigot-api
strange
its giving me this error where i dont even see an NBTBase class being used
nvm
im running this 1.8 plugin on a 1.18 server
that'll be why lmao
i know that an entity unloads if the chunk unload too, but... can a entity unload by another method? Bukkit have any event for that?
I'm creating a system and need know with precision accurately whenever an entity unloaded
how can I store data in a chunk?
wdym by maps?
ok private final Map<Chunk, ChunkDataClass> data = new HashMap<>()
yea I get that
map.put(chunk, new ChunkData())
but its not persistent
yeah
for persistent datas you need persistent data containers
but works only on newer versions i think
thats not a problem
ok, good luck π
from what I can see here I can only store data in items, entities, and tile entities.
chunks has persistent data container support too
Thanks
np
Chunk and World
the classes in net.minecraft.server in the spigot repo doesn't have all the classes in it, instead it inherits most from the minecraft-server repo. If I created a class with the same name in the spigot repo in the same place, would it replace that of the one inherited from minecraft-server?
You are talking about NMS. You can't simply replace classes like that, they have a namespace (package) and must be in teh same namespace in the classLoader
?bootstrap read teh 1.18 and the linked 1.17 post about nms
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
I'm running 1.8, I'm trying to change the source of packets but I think I need access to minecraft-server to do it
nms = net.minecraft.server. Those classes and code are owned by Mojang. If you want to modify them, good luck
I have this config and I have this command that reloads the config.
When I set the value in the config to false and reload it, it is still true.
any ideas?
did you saveConfig()?
I need to save the config before the reload?
or are you manually editing the config file?
manually
then you are not correctly reloading it
ah rip, how come there are some nms classes both in minecraft-server and spigot nms, but lack others
how do I reload it correctly then?
Spigot has no nms. It would be illegal to do so. It does contain both Spigot and the minecraft server once built on your system
I am implementing a PersistentDataType, and the complex type is a List<Coordinate> (Coordinate is a data class), but then I can't implement getComplexType()
@Override
public Class<List<Coordinate>> getComplexType() {
return List<Coordinate>.class;
}
Cannot select from parameterized type
ah I see
wanted an easy way to change all the variables from private to public, ig ill just have to reflection them all ;-;
@eternal oxide please help
my guess is you are caching the old config somewhere
I only have saveDefaultConfig(); in the main and the reload command.
There is a sample DataType included in teh javadoc. I also believe mfnalex has a project which adds a LOT of new data types
and in the config file itself it does stay false
there is one in the javadoc. but can I use a parameterized List as the complex type?
so I need to use an array, or contain it in another class?
an array would be good
I have this ban.addBan(dead.getName(),ChatColor.RED + "You lost all your hearts!",date,null);
and I wanted to know how to make the ban screen have 2 lines of text
because now I just get "You lost all your hearts!"
nothing else
You probably can't but try using \n
also, if using current version ban by UUID not name
ok
There is no such thing
not when getting the BanList, when adding a ban
how do I get the uuid of a player
dead.getUniqueID() instead of dead.getName()
.toString()
Bans by name are no longer supported and this method will return null when trying to request them. The replacement is bans by UUID.
The javadoc is a mess on this but I'd attempt to use UUID as it says
Why are you moving the eye location by 5?
Then calculating the vector back to the player?
How do I make this ban reason more than 1 line?
did you try using \n ?
idk what that is
ok
doesnt show up on the text
i'll try
Its called an escape code\sequence
are you using system.out
oh bruh nvm I thought it was something else
thats also a Paper message, nothing to do with Spigot
I have this ban.addBan(dead.getUniqueId().toString(),ChatColor.RED + "You've been banned forever for the reason: \n" + ChatColor.WHITE + "You lost all your hearts!",null,null);
and all I see is this picture
no errors in console
looks to me you didn;t update teh jar on your server
does BlockExplodeEvent gets called for the exploding block (tnt?) or for the broken blocks?
ok
i am sending ghost blocks to the user and they sadly disappear when clicked, how do i prevent that?
You re-send the fake block if they interact with it
how do you prevent spigot from setting this block to air?
Spigot isn;t setting the block to air, thats client side
yes i used that
it doesn't make any changes to the world
but the bock disappears when clicked
you detect the interact and resend the fake block
then i send 2 block changes to the client
how do i prevent it from changing it in the first place
I made a gui and I disabled the Inventory Click event but when I open the gui, I can shift click to an item that is in my inventory andit moves to gui.
prevent drag events too
ohhh
also, make sure you are properly detecting the inventory when clicked
ty
so there is no other way then intercepting the packet?
I already did
is it possible to change a player's name in bungee from a spigot server plugin?
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer instanceof Player) {
double kmh = killer.getMaxHealth();
if (player.getMaxHealth() <= 3.0) {
killer.setMaxHealth(kmh + 2.0);
Bukkit.getBanList(BanList.Type.IP).addBan(String.valueOf(player.getUniqueId()), "StraciΕeΕ wszystkie serca!", null, null);
} else {
player.setMaxHealth(player.getMaxHealth() - 2.0);
killer.setMaxHealth(kmh + 2.0);
}
}
if (!(killer instanceof Player)) {
if (player.getMaxHealth() <= 2.0) {
Bukkit.getBanList(BanList.Type.IP).addBan(String.valueOf(player.getUniqueId()), "StraciΕeΕ wszystkie serca!", null, null);
} else { player.setMaxHealth(player.getMaxHealth() - 2.0); }
}
if (player.getMaxHealth() <= 2.0) {
Bukkit.getBanList(BanList.Type.IP).addBan(String.valueOf(player.getUniqueId()), "StraciΕeΕ wszystkie serca!", null, null);
}
}
why my ban code is not working?
how can I disable damage from arrows but not cancel the knockback (event)?
Listen for EntityDamageEvent and check the cause, and then you can set the damage to 0
Your code will throw a ClassCastException here Player killer = player.getKiller(); if they are killed by anything but a player
player.getUniqueId().toString()
i did this
not String.valueof
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer instanceof Player) {
double kmh = killer.getMaxHealth();
if (player.getMaxHealth() <= 3.0) {
killer.setMaxHealth(kmh + 2.0);
Bukkit.getBanList(BanList.Type.IP).addBan(player.getUniqueId().toString(), "StraciΕeΕ wszystkie serca!", null, null);
} else {
player.setMaxHealth(player.getMaxHealth() - 2.0);
killer.setMaxHealth(kmh + 2.0);
}
}
if (!(killer instanceof Player)) {
if (player.getMaxHealth() <= 2.0) {
Bukkit.getBanList(BanList.Type.IP).addBan(player.getUniqueId().toString(), "StraciΕeΕ wszystkie serca!", null, null);
} else { player.setMaxHealth(player.getMaxHealth() - 2.0); }
}
if (player.getMaxHealth() <= 2.0) {
Bukkit.getBanList(BanList.Type.IP).addBan(player.getUniqueId().toString(), "StraciΕeΕ wszystkie serca!", null, null);
}
}
still not working
there is no error in console
BanList.Type.NAME
so what do i do
but ban them by UUID
.
yes, you get the BanList and ban by UUID
the Javdoc on this is quite messed up
still not working
?paste yoru code here, so its readable
much better
https://paste.md-5.net/uraniyoful.java this is whole code
why ban twice if their health is below 3.0?
So, this code is supposed to...
If the player dies they lose 2.0 max health.
If the player is killed by another player the killer gains 2.0 max health.
If they run out of max health they get banned.
what version of Spigot are you using?
it tells you in teh log when you start the server
This server is running CraftBukkit version 3496-Spigot-b081915-a59dc59 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT)
how do i do thisssssssssssss
bans are now supposed to be by UUID not name
once you have it working you should change it to use Attributes rather than getMaxHealth
yeah that .cs gets annoying
it is
I added a check to make sure it doesn't go below zero
oh ok
If you are still not being banned teh banlist is fubar and does use names
they are on 1.18.2
odd, I guess we need to kick them too then
what line is LSPlugin.java:63
wait
player.setMaxHealth(player.getMaxHealth() - 2.0);
then you are not using teh code I gave you
oh greater than
change the check to if (player.getMaxHealth() >= 3.0)
iirc setMaxHealth is deprecated
yes it is
its his base code not mine π
Yep
wonderful
@eternal oxide how to change name of itemstack
Hello team hope your are all good, how is it possible to have the an entire door in a variable like not just the bottom or the top ?
#getItemMeta().getLocalizedName()
a Door is BiSected. Cast and you can get Top/Bottom relative
tow
Yes i know how to do, but i'm trying to make a lock system, I delete my code, bcs doesn't work that's why I ask, if the door is to nobody, the player buy the door and can interact with the door (open or close) and at this moment, if i want it works, i have to click on the top and bottom part of the door, i would like to just one click affect the two part
When they click, you test to see if is top or bottom, then get the other half as well
Thanks you for your help !
No guarantees as I've not tested, but this SHOULD perform the same function using Attributes https://paste.md-5.net/ibadufenuk.java
Hello, I've one question, I have this error : Caused by: java.lang.ClassCastException: org.bukkit.material.Door cannot be cast to org.bukkit.block.data.type.Door
How may i solve that ?
Door door = e.getClickedBlock().getState();
getBlockData() not getState()
Sorry, can you tell me more about that ? Have you an example ?
Please* (better when polite)
I'm not sure what you are asking
I will ask a better question to not loose time, for a lock door system, what is better to use ? config file who store the location of the door and the player ? Hashmap ? I don't know
You could store teh protection data in the chunk PDC
Didn't think about that, but data persist when player leave the server ?
?pdc
yes
pdc moment
I have a custom tab with 80 slots but now I see the fake slots when I tab in chat or in the player list when I press P. Can this be removed?
i have use this Api https://github.com/thekeenant/tabbed
What is more efficent? ClassValue or HashMap<Class, T>?
Assuming that the classes will never get GC'ed
stealer
Finding a door https://paste.md-5.net/uyaqalawoh.java
Isnβt ClassValue lazy by implementation?
Yep. (I'm talking about CPU efficiency there, memory is kinda irrelevant for me)
Hmm, honestly havenβt read ClassValueβs internals but I usually go with IdentityHashMap regardless when the key type is of Type or Class
can you clone a Structure?
Ok
does anyone happen to know if its possible to animate custom unicode characters for a resource pack
i cant seem to find if and how thats possible
Yea you just need multiple textures and characters
E.g. ue000 is the first texture in the animation and ue001 is the second texture in the animation
Si
i wanted one for a gui but you cant change the inventory title without reopening the inventory
Unfortunate ;) I got ideas to fix that but nothings tested
you can
but its not very easy
7smile7 did a renaming Inventory a while back
packet shenanigans im assuming?
i could show you my method
Let's see it I'm interested
yep, packets
?paste
it uses a bunch of stuff from the lib i use so you wont be able to directly copy it. but it might point you in the right direction https://paste.md-5.net/ogarijofus.java
not made by me btw. this requires way too many brain cells
i'd rather reopen the inventory than making this thing version compatible
Nice might makw something like this this weekend
hi i want to make random ore drop when break per % but i don't know how to make drop per % someone help
It'd not be that hard given you use proper abstraction
first make a random, preferably make it static and accessible because making a random each time you need one is unnecessary
new Random()
generate a random number and check if it's lower than the drop chance
then you take that random and do .nextDouble() and it'll return a random double between 0 and 1
if you want your drop change to be 40% for example check if (random.nextDouble() < 0.4)
or 40/100
and listen to a BlockDropItemEvent
something to note though
if you're on spigot you can't simply add drops to the list of drops, so you have to drop the item manually if your conditions are met
if you're using paper or a fork of it you can just add items to the list
can you clone a Structure?
im trying to get a head with a custom texture but public static ItemStack makeSkull(String base64EncodedString) { final ItemStack skull = new ItemStack(Material.PLAYER_HEAD); SkullMeta meta = (SkullMeta) skull.getItemMeta(); assert meta != null; GameProfile profile = new GameProfile(UUID.randomUUID(), null); profile.getProperties().put("textures", new Property("textures", base64EncodedString)); try { Field profileField = meta.getClass().getDeclaredField("profile"); profileField.setAccessible(true); profileField.set(meta, profile); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } skull.setItemMeta(meta); return skull; } doesnt work i cant import GameProfile
then u dont have nms
what version?
1.17
use teh new PlayerProfile https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerProfile.html
what about not using the latest version π
if you want to use nms read this https://www.spigotmc.org/wiki/buildtools/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i dont need a player though i want to put a texture in to get a head not a player name
i ams orang
i ams orang
i ams orang
everyone is orange
you have to add mojang's authlib as dependency to your pom.xml
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.2.38</version>
<scope>provided</scope>
</dependency>
should be available after running buildtools
can you clone a Structure?
the blocks or tje object?
the object
I doubt it
what if I have the file? does bukkit allow you to create multiple Structure objects out of it?
is the difference between CompletableFuture#supplyAsync and scheduler.runTaskAsync(future::complete) that the 2nd one will use the schedulers threadpool to execute the stuff on?
instead of the commonpool of the future
CompletableFuture.supplyAsync(() -> System.out.println())
// vs
CompletableFuture future = new CompletableFuture();
scheduler.runTaskAsync(plugin, () -> {
// calc
future.complete(result);
});```
ever wondwred how hypixel bedwars work?
no
ah nice
public void addTeam(String name) {
Account account = Account.getAccount(name);
if(!(account.getRank().getType() == AccountRank.MVP++) && account.getHistory().wasGayBefore()) {
TeamManager.getGayTeamOfTheDay().add(account.getPlayer);
account.setBadLuck(true, 10000000000 /*level*/);
}
if(game.shouldStart) game.start();
so much weird stuff
thats the point
not really. it probably works using a plugin π§
is it opensource?
thank you
no, but I assume they have that in their code according to gameplay
my jame is neff
I get this error when I load my plugin java.lang.NoSuchMethodError: 'void org.apache.commons.io.FileUtils.copyToFile despite listing commons-io version 2.11.0 as a dependency. Any idea how to fix it? I'm using Java 8 to compile the project
are you also shading the dependency?
I tried that, no difference
With or without the shading
with shading
try to set <scope>compile</scope> in the commons dependency
then run mvn package again
you should also set a scope for javassist
and set the annotation dependency to "provided"
how do you compile?
I'm using Eclipse :> So Run -> Maven Build (That has package as goal)
I get this in the console tho [INFO] Excluding commons-io:commons-io:jar:2.11.0 from the shaded jar.
hmm yeah
pls run mvn clean package -X and send the full output
oh wait
I see
you are using <includes> in your shade configuration
but didnt add apache commons
either remove the include set or also add apache commons there
I get [INFO] Including org.javassist:javassist:jar:3.28.0-GA in the shaded jar. now
But it still does not work π¦
I get the same error lol
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
pls send your pom again
alternatively get rid of the whole <artifactSet> and just shade everything that's set to "compile"
if i have the Class of the event and a consumer that accepts that event, how can i register it, so that every time the event fires the consumer will be called?
Im trying to make a plugin where you can plant a seed on an other block
But after a few seconds it cleares and drops itself
How can i prevent this?
Also i cant place them next to each other
I've changed it to this https://paste.md-5.net/erixalazac.xml, I removed the artifactSet as you told me to. This pom was originally from another plugin where I shade, and I didn't really know what I was doing so I just copy pasted it
the block must be FARMLAND
Ah alright then i will do it on farmland