#help-development
1 messages · Page 1 of 1 (latest)
ServerPlayer npc = new ServerPlayer(nmsServer, nmsWorld, gameProfile, ...);```
At ... I should add a ProfilePublicKey. What should I enter there?
just pass null
presumably because the enchantment cannot be applied to the item stack
e.g. infinity cannot be applied to a sword
getting this now
what enchant are you trying to apply to which itemstack
i think you could enchant everything to anything
im pretty sure if you use addUnsafeEnchantment it doesnt give that error
that is pointless
in vanilla minecraft anvils no
and with the /enchant command no
player.getWorld IS the Bukkit World
any idea how to fix this?
cast to CraftWorld and getHandle
Could anyone give me a hint how i get from player to players target entity
which one? the WorldServer nmsWorld = ((CraftWorld) Bukkit.getWorld(player.getWorld.getName())).getHandle(); or the ServerPlayer npc = ...
((CraftWorld) player.getWorld()).getHandle()
and its a ServerLevel not a WorldServer
thats the same as doing Bukkit.getPlayer(player.getName())
sure?
Nope its all guesswork. I'm throwing words at the page
Isnt ServerLevel a subclass of WorldServer?
Pretty sure that it is
Its like List -> ArrayList
two complete different mappings
idk what you are doing there
but it is cursed af
Do they have remapped AND spigot mappings in one project?!?!
Pls help, how do i set when i crouch i get launched 10 blocks in the air
Listen to crouch toggle event or whats it called
Then apply velocity
Yeah this
wtf i had XDD
Using https://paste.md-5.net/ifogihevus.java You can do the following...java DedicatedServer nmsServer = (DedicatedServer) NMSUtils.getDedicatedServer(); ServerLevel nmsWorld = (ServerLevel) NMSUtils.getServerLevel(location.getWorld());
How do i get velocity in visual bukkit
selfadvertising ✅
Love me!
Ok nvm i found a way
I like you but i dont love you
Tysm
I'm devastated
Youll get over it some day
any way to let the npc lie on the ground like it is dead?
Theres a packet for that
send a sleep packet
At least I still have God
lets make a VisualCraftBukkit
VisualVM
Like normal java but you drag and drop the letters into the IDE
oh and then make api packages
so they can drop in spigot package
nms package etc. which we provide
petition to name Spigot to Spukkit
I hate it. I love this
Bigot
Wait
for pride month
yeah i think so
Now we can all go homophobic again
fuck you alex
„Fuck ppl like me“
how to get current directory? i dont want to use getDataFolder().toString() because it gives me only plugins/pluginname
i tried to use this System.getProperty("user.dir") but it gives me nothing
where the jar is running?
and a plugin obv. isnt a jar
getDataFolder() gives you a File object,. you can use canonical path from that
I would just get the parent of getDataFolder()
No idea what he wants there but ok
something like C:/users/someone/desktop/server/plugins/pluginname
if he wants the root just new File()
this is returned by getDataFolder()
ah
getDataFolder().getAbsolutePath()
Or sth like that. No idea, im on the phone and too drunk
absolute is correct
Its like 1 pm
just getPath() seems fine
a bit too late for him
i have another question
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
How about we all start using unix timestamps for now
they probably set up a profile in their IDE which runs a server on build
i mean eclipse or something
how to do that?
I've seen it done. never bothered myself
is there any tutorial on eclipse?
Well... there are several ways. If you are using gradle then you can use the jpenilla gradle plugin to add a "run-paper" goal.
Hey! I have an Economy plugin (H2 DB), which is a dependency of my CaveEssentials plugin. And when I try to call the function, which gets the balance of a player (from the Economy plugin) it says, that connection is null. Do I have to get a separate connection URL for my second plugin?
Why cant I use Material.WHITE_CANDLE?
Wrong version? Might be
inv.setItem(13, new ItemBuilder(Material.WHITE_CANDLE, 1).setName("...").setLore("...").create());
^
symbol: variable WHITE_CANDLE
location: class Material```
no api version in your plugin.yml?
im on paper 1.19
api-version: 1.19
java.lang.IllegalArgumentException: `The found tag instance cannot store String as it is a NBTTagLong
What does this error mean?
Test on Spigot and if it still errors we'll take a look
IDEs are (usually?!) code editors, ie. eclipse, intellij, visual studio, etc
The part of the error I1 was able to get... The stuff above is mostly irrelevant anyway
ik
i used paper in my npc manager (serverplayer etc.)
i guess i cannot switch that easily
it prints: jdbc:sqlite:/plugins/MultyBot/bans.db
No you dont need a different connection url if its still the same database.
Use a connection pool pls.
Like HikariCP
As excuse: I woke up with 0.54 ‰ and then i needed some beers to not get sober in the middle of the day
Sure, I'll look into that. Thanks! Though for educational purposes, why does that happen?
I have no idea because you didnt provide any code
Could be anything
Fair enough lol
I think I found it. I need the h2 dependency in both, don't I?
No you dont
The dependency is transitive
lol thats odd
Okay I don't see a reason why this wouldn't work..
Database.java https://sourceb.in/q4yWXgzDqJ
DatabaseUtil.java https://sourceb.in/sYTtLN93VZ
Basically I use the getBalance(Player player); function of DatabaseUtil in the other plugin
And the economy plugin (the one with the database) does work
idk why it still says .class, I actually changed it to .java in the title but yeah
looks like stuff codedred would do
Databases support UUIDs. Use them instead of Strings.
anyone?
Fair enough
use File.separator instead of /
not problem though, at least I don't think it is... getting the conenction just returns null when I use it in my other plugin
Do you make sure to not shade in your dependency?
how is that helping me?
Maven told me that earlier, but now it doesn't anymore so yeah ig
you need to ensure when creating api's that your plugin that gives the API, implements the stuff appropriately as well as initializes stuff that is expected to be used. What is most likely happening is that the function you are using from your plugin, doesn't ensure a connection object exists or is obtaining an incorrect connection instance.
is the scope <provided> for your dependency?
why is it printing plugins/MultyBot? i need C:/users/someone/desktop/server/plugins/MultyBot
for jdbc
I'll try that
Why did you decide to use sqlite?
what should i use instead .txt file? 😄
i need timestamps
and sqlite has an option for it
yml or json will do just fine.
timestamps are a programmable thing
i already used yml file for ticket system
and you can use more then one yml file
Then why not use it for the bans as well?
idk
sqlite looks more trustable
HM
can i store timestamps on yml?
You can store literally anything in yml
in other words a string of numbers
sure lol
every line*
how?
I think the id is not exposed in the api. So nms it is.
i have no idea how your yaml file looks but probably smth with iterating over a config.getSection
is that method getting lines?
iterating over a config section, i recommend you take a look at the config docs
You dont need the window id for that. Listen for outgoing item packets and change the lore in the packet
best thing in my eyes: https://bukkit.fandom.com/wiki/Configuration_API_Reference
Not learning java: Writing this plugin will take you 3 - 4 weeks
Learning java: Takes you 2 weeks and the plugin will only take 1 week max after that
what kind of plugin btw
Every packet that sends ItemStacks to a player
thats why ill learn after this plugin
stop telling me same thing 21931823x times.
You understand the implied math ive just presented?
No
i dont even know what you mean in implied math
learning about the thing you are trying to do is in your own interest
In easy words: You will be faster if you learn java now and then finish the plugin instead of trying to finish the plugin with your current knowledge.
instead of watching tutorials*
given you have the cognitive capacity for that
while you may not like that people are telling to learn something first, this is not a place to be spoonfed or a place where you get your hand held and show you around java and the sorts. You need to put some effort into yourself as well which includes learning and teaching yourself whatever you are trying to use.
How did you come to that conclusion? Because it seems to work now
Its more or less what frostalf said earlier. Your plugin just used a different scope of classes.
Its a common problem with spigot apis. They should not be shaded unless they are designed for that (then you need to relocate)
Noice, I don't have much experience with maven or java yet, but some day I'll be on the same level as in C#, hopefully
I'll make sure to remember that :) I appreciate the help && explanation :D
like com.some.path.DatabaseUtils
existed twice on the classpath and your plugin used the one "closest" to your other classes.
Its hard to describe.
And only one is initialized by your loaded plugin. The other one you shaded is just untouched.
Is there a easy way to check if the player is looking somewhere in this area, if I know the coordinates for the area?
typically the issue more or less arises when you have a transitive dependency and a hard dependency both being the same
but differing versions
There is not an easy way. This requires some math.
yay
yay, love math... not :(
Thats all you have when working with packets.
Look at the protocol and look at the nms packet. Latter helps me personally more.
i got an idea to solve this without math
Elaborate
spawn an invisible slime, and check if player is looking at the slime
would that work?
Sure. Sounds expensive.
depends on your context. Do they just need to be looking near it or must their cursor be at least in the box?
if you want near then you have no choice but to use math
in the box
basically, im going to spawn some holograms there, and i want something to happen if the player is looking at those holograms, but since hologram names are not included in the armorstand hitbox, i can't just check the armorstand hitbox
then your slime idea will work, however a bit more resources then necessary
look up ray plane intersection on google
they are if you put an armorstand where the hologram is
still the risk of the name going outside hitbox in terms of width if i understand correctly.
(art hasn't really been my career path)
I might have something that actually might help you
but it might be too advanced for you to decipher some useful code from it. Anyways, this plugin allowed touch capabilities for holograms
its defunct mostly, but still might have something useful in it 😛
Anyone who knows a Coin/PlayerPoint API which works on 1.19
vault lol
so i'm trying to create a config file and allow the user to modify some values in it, but i don't know if what i've done is correct or not
someone to help me ?
Does it work?
didn't tried
so then you dont know if its correct or not
conventions???
yeah but that's for starters, do i need to create the config file in the plugin itself? or it will create later
Lowercase class name 💀
?main
then change it if its for starters lol
Well... all you do is save the default config file.
didn't knew, thanks
if you want to get super fancy with letting the user modifying the config, you can make use of the conversation api and let them do it from in game 😄
Actually i just want to modify the kind of kit command that spigot forums gives us and allow the user to modify the items given in the config file
whats even the point of the conversation api? like when is it used?
i didnt even know it exist a few months ago
when you want to have a conversation between the server and player, or maybe you want 2 players in their own talking space separate from everyone else, or maybe you want to toss everyone into a channel and have your own broadcast of sorts
basiscally anything you can think of
it just checks on interact if it is a entity with touch actions, and if so, executes those actions
(but with packets)
ooh that sound great
i havent really found a tutorial on how to start with it but ye anways ill look at it :)
I want to create it first
its really easy and probably one of the most underused features in spigot/bukkit
ye ig
https://github.com/frostalf/ServerTutorial/tree/master/ServerTutorial/src/main/java/pw/hwk/tutorial/conversation
this would be an example of a conversation between server and player
🤔 🤔

lets not try to be rude 🥺
yep, for whatever reason spigot/bukkit didn't like it any other way
yeah it was dumb, I am sure now I could fix it whenever I get around to updating the plugin
so on a side thing.. How do I get this to actually add the 2 to the existing damage of the sword, rather than replacing it as a bonus to none weapon damage? because thats what it does xD
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE,
new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 2.0, Operation.ADD_NUMBER, EquipmentSlot.HAND));```
I'm trying to read values from the config file but it keeps telling me i can't?
why dont you have a getInstance
where? Sorry i'm kinda new in this
in your main class
well my main class is looking like this
lets start with the instance stuff
and make a getInstance
im semi confident not one living soul can understand one of the methods in my code
actually very confident
Calling an event from a plugin should be enough to actually use it with the eventhandler in another one right? (Besides having all the dependencies and stuff)
yes if i understand correctly
do I need to add this in my main class and after use it in my commands with a getInstance?LePluginABenlezouz instance = this;
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Material.valueOf();
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
lmao
Material.matchMaterial
i mean learn java man
Yeah...
@trim surge we straightlly recommend learning java before touching external apis...
Why are you @ ing me? lol
you what
@trim surge
Lmao also are you english?
ffs 😭
Sorry, but can you guys explain me where do i put the Material.matchMaterial
Yes im English
Material material = Material.matchMaterial
Oh ok I thought you werent
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.
Agree, +1 to that answer
For my job i've had to create a fucking Job Simulator 😂
Love being a software developer 👍
Please Press the Caps lock button on your keyboard
Yeah my bad
I dont why people code without learning the basics from the lang
Its really annoying to answer or help
I think people kind of misunderstand the purpose of this channel at times
Agree with you rabbit
Because if you ask for help is for specific things not because you didnt learn the bases in your own
😂
Not bulling noe one but its really annoyed and make angry when people want helps and they dont know the bases
🐰
Because I'm enthusiastic, certainly it's not the best idea but I try. And please stop looking down on people because it's not nice of you. I see a lot of people who are nice and refer people where they need to be but you just talk and not help
Like, i'm sorry but it's what I think
Oh lmao now because someone said the truth its the bad boy.. What amazing society we have created
We are pretty mean, but it is indeed difficult to help someone without already some foundation
we give suggestions in a grander scheme of things
True, but you could have sent the links to learn java directly instead of seeing me struggling out on creating a plugin
lol didnt we do enough ?learnjava
I don't want to be mean to anyone and I don't blame anyone but it would have been easier
I think struggle is what everyone went through, and it is pretty important skill to source for official documentation online.
Also we never had the intention of shitting you or make you feel small. We were just trying to help
Maybe one day I will have enough knowledge to create a real working plugin, and help people maybe. This will take months or years but please I don't want you guys to react like this
That's what I felt like
Why? I cannot find the reason
I'm not telling you guys are bad boys and shit, but try to be "kind" if I could say
When I first started here React like that but all here are experience and like to help but in a point. Like you meanly know
Time will make you see that mostly all here are like that
Not much helps when someone doesnt know the bases from the lang. So we just tell them to learn java
I mean surely i'm not the only who struggles to learn Java. But spigot never warns you about the fact that "if you don't know java then don't ask for help and go learn here..." and stuff
I think its something more obviously
Exactly, but I mean this could be said directly
Oh if you will be in thst way I dont know what you will do
said directly we did
Because people join with the "Oh I want to create a plugin, let's ask for help" but now that I know all this, it's obvious that if you don't know java, then go learn
Agree
I mean you have already said it
😂
I agree with you on this point
Lmao i have things to do see you soon
But when i joined, no one said go learn
well after a bit yes, but not directly and i kind of wasted time
Solar dont worry bro do your things because this wont end
Again, not blaming anyone here
Well, now that I have lots of websites to learn Java on, I have things to do, and a lot lmao
Nice bro so dont lost your time and with that info and if need more look for it
There plesnty Information for learning if need more ask it
Sorry if i actually triggered you or else, but thanks for the help. I'll go learn java before starting projects like this
not much
I have seen you tyling for more than 10m
He's writing the whole bible my man
I was typing while recalling on how I learned java
Oh that why
Oh... Well i'll go and learn and see you in a month
🤣
I think the best way for actually learning is reading about the lang in general, itsfeatures, etc, etc and while doing that putting in practice the new things learned
🤓
it is just difficult to pick up your first language
And then yes start reading about the spigot apis
Codecademy is looking for this type of "learning"
Well, my first language was Python actually, but in the logic I prefer to continue with Java and have a real hands on stuff with plugins and all that
some find python easy, I find it hard. gg bro
For my python is really tras because i dont like non highly typed lsngs
here in France we start to learn Python in high school
soo, it's "easy" for us
depends on people
I just find it hard to accept python's syntax
Yeah
Really strange we here on 2 st of High school we start with Html and css. 3 st year javascript.
Well we do Python, HTML and CSS
training you to be Web FE only
Fe?
frontend
I think we'll do Javascript after
Javascript is sweetier than java
gotta leave you guys, was great to talk with you a bit. Have a great day 😄
Because of async things in java you have more work around to do a just simple await of something
😂
Allr cya
Yes amazing
Now you can do better:
const bla = await require('something');
😂
Oh so ugly
I dont like it because you cannot require a json file and get each param directly as a Objects values
right
But the import looks better
But idk I dont care
I would use require
Also ts looks really sweeaty but didnt start with it
ts is a sexy mf
js is like spigot, after you use papermc you don't simply go back and use spigotmc
bro then it would be Paper>Spigot
?dmca
An unofficial explanation of the DMCA can be found here: https://www.spigotmc.org/wiki/unofficial-explanation-about-the-dmca/
no paper is shit
I dont like it
I prefer spigot over paper
?
Just looking at it
Someone asked why they couldn’t just download spigot
So I was getting them the link
bro you litterly said "PaperSpigot its better" and paperspigot is paper
Well it's Verano what did you expect
PaperSpigot is Paper name for versions 1.8 and lower
hhaa that i was wanting to hearing olivo!
Lol why
wtf is spigot + paper 😂
paper is already a fork of spigot xD
You can get extensions that do that.
1.8 isnt that all
?1.8
Too old! (Click the link to get the exact time)
You make me feel old
close to 7 years xD
Only ^
why armor stands are so annoying on spigot
I have heard that paper one are not that annoying
😡
yeah
and not talking about NMS
spigot and its amazing NMS packages name and classes!
🤡
I don't think paper has any additions in terms of moving armor stands yet o.O
API wise at least
help
hey guys i've been going around the internet like EVERYWHERE but i cant find how to spawn/set blocks under a player, could anyone tell me the code so i can learn from it?
install driver
Get the players location and do a nested for loop with x and z going from -radius to +radius on both.
The use the base Block and call getRelative(x, y, z) to get a block relative to the base block.
If i google it
And find and answer in 5 seconds
What do i get
i know
its literally for () { for() { for() { block.getRelative(x, y, z).setType() } } }
anyone
Learn java before jumping into spigot. Spigot is not beginner friendly.
ouch
Shade the driver in.
oh well
wdym
seems like im litterally doomed
Why
weeeeeeeeeeeeee
You just shouldn't be going straight into spigot before understanding the fundamentals of java
plz
and add some banging my head to the wall
In newer versions you dont need to initialize the jdbc driver by touching the class.
This should be enough
final String username="YOUR DB USERNAME"; // Enter in your db username
final String password="YOUR DB PASSWORD"; // Enter your password for the db
final String url = "jdbc:mysql://db4free.net:3306/DataBaseName"; // Enter URL with db name
connection = DriverManager.getConnection(url, username, password);
But pls use a connection pool like HikariCP instead.
Agree
By using the chat, action bar, tab list, scoreboards, a map, a boss bar, a floating hologram, the amount of an itemstack or a changing name / lore of an itemstack.
scoreboards
well ik, but how would i get that said time left?
never dealt with timers before
You save a timestamp and check how far it is in the past
Oh I'm so sorry you have to learn java like everyone else
i see
okay thanks
😭
idk what u saying plz tell me what to do
in config of that plugin
Deleting local repo cache from git will clean all cache or only branch cahe?
ohhh, i see now
Are you programming that plugin?
System.currentTimeMills() just use that
hey, cmon dude i just didnt know that i needed to learn java cuz i was learning java before
I'm just saying, it's not unique to you and you don't have to exaggerate it
There's tons of online resources
ik
2 months isn't a lot of time to pick up a new skill, and you could feasibly learn it much faster
You can learn java here on https://www.programming-books.io/
Essential Programming Books.
no
Meh
thanks!
I would learn it online to be honest.
Me too
I would do a bit of both
Most of paper books are non updated
You tend to see a lot of bodged code online, especially in coding tutorials
also is there a better way of doing chances? Because im using a random that is between 0 and 100
Then this is the wrong channel to ask
Books tend to teach you good practice a bit more
Yeah
Just scale it
chances are usually done by generating a random double for 0.0 to 1.0
okay, i was just wondering if there was a better way to do it.
Pretty easy
now another question 💀. How would i display the timestamp as like 5 minutes and 2 seconds or 5m 2s.
You will have to format it
get the time delta as a Duration and then format it. There are countless tutorials on formatting a Duration.
You can convert the timestamp into a date object using a specific format something like MM:hh:ss
Is it like that? - smile
Formatting a date like that would be really weird. He wants a duration.
But for displaying it i think its better a date with hh:MM:ss format so then is displayed as hour/s:minute/s:second/s
Well there is a difference between a duration and a point in time
okay i'll check it out
and i do want the duration of it
since im doing Date date = new Date(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5));
I would use Instant instead.
Instant future = Instant.now().plus(5, ChronoUnit.MINUTES);
okay 👍
And what about formatting a timestamp into hours:minutes:seconds left?
Because then you can get the Duration like that
Duration left = Duration.between(Instant.now(), future);
ooo
okay i c
thanks so much
This would be a trivial approach to the formatting
Duration left = Duration.between(Instant.now(), future);
long seconds = left.getSeconds();
long hh = seconds / 3600;
long mm = (seconds % 3600) / 60;
long ss = seconds % 60;
String formatted = String.format("%02d:%02d:%02d", hh, mm, ss);
hh:mm:ss
why 02d? isnt the same %s?
But you can just do
"%02d hours %02d minutes %02d seconds"
And leave some away if they are 0
No those are not even close
What?
%02d is completely different from %s
Same goes for %.3f
It does something completely different
okay never heard about that formats
these are things you google
after years of programming experience, "how to format double to string 2 decimal places"
Well after doing an exam in C where we had to know this stuff without looking it up it kind of stuck. But before that: duckduckgo
if(item == null) {continue;}
if(item.getItemMeta() == null) {continue;}
if(item.getItemMeta().getDisplayName() == null) {continue;}
ItemMeta meta = item.getItemMeta();
String ItemName = item.getItemMeta().getDisplayName();
if (ItemName.equals(ChatColor.RED + "Dctr's Space Helmet")) {
Random r = new Random();
int color = r.nextInt(colors.length);
Material material = colors.get[color];
item.setType(material);
item.setItemMeta(meta);
}
}
}
}.runTaskTimer(this, 20, 20);
}
}```
Cannot resolve symbol 'get'
how do I fix dis error?
First pls format your code so its actually readable
oh mb
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
ItemStack item = player.getInventory().getHelmet();
if(item == null) {continue;}
if(item.getItemMeta() == null) {continue;}
if(item.getItemMeta().getDisplayName() == null) {continue;}
ItemMeta meta = item.getItemMeta();
String ItemName = item.getItemMeta().getDisplayName();
if (ItemName.equals(ChatColor.RED + "Dctr's Space Helmet")) {
Random r = new Random();
int color = r.nextInt(colors.length);
Material material = colors.get[color];
item.setType(material);
item.setItemMeta(meta);
}
}
}
}.runTaskTimer(this, 20, 20);
}
}```
how about now?
public class SpaceHelm extends JavaPlugin {
@Override
public void onEnable() {
getCommand("spacehelm").setExecutor(new SpaceHelmetCmd());
getServer().getPluginManager().registerEvents(new SpaceHelmetListener(), this);
byte[] colors = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
ItemStack item = new ItemStack(Material.STAINED_GLASS, 1, (byte) 0);
ItemStack item1 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 1);
ItemStack item2 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 2);
ItemStack item3 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 3);
ItemStack item4 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 4);
ItemStack item5 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 5);
ItemStack item6 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 6);
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
ItemStack item = player.getInventory().getHelmet();
if(item == null) {continue;}
if(item.getItemMeta() == null) {continue;}
if(item.getItemMeta().getDisplayName() == null) {continue;}
ItemMeta meta = item.getItemMeta();
String ItemName = item.getItemMeta().getDisplayName();
if (ItemName.equals(ChatColor.RED + "Dctr's Space Helmet")) {
Random r = new Random();
int color = r.nextInt(colors.length);
Material material = colors.get[color];
item.setType(material);
item.setItemMeta(meta);
}
}
}
}.runTaskTimer(this, 20, 20);
}
}```
omg now??
No comment on the formatting... You are accessing an array by using get. Thats not a thing. You simply do array[index]
but when I try that
Incompatible types. Found: 'byte', required: 'org.bukkit.Material'
Yeah makes sense. Why would a byte array contain a Material?
Do you want to color a leather helmet?
Which spigot version?
it is important for the answer is different for different versions
I cant help you then. The old api for colors is absolute garbage. Go search in old forum posts then.
mans going to bully me
What are you doing?
stained glass helm which changes color when worn
Okay
I let you know that for that panel glass with colors you need an id that its type byte
Just do a random and then if the random is X number set the Player#getInventory#setHelmet(new ItemStack(Material.STAINED_GLASS, 1, (DATA))
That data is type byte to let you know (MrQuackies)
is depending to the version
He is using legacy versions
o
Because data byte is not used anymore since 1.13 i think
already did that
only dis error
I understand what ahppening
You are trying to get Material object for stained glass panel only telling the data ID
that is not how it works
How would I go about moving the enchantment lore down to where shown in this picture?
This is for 1.19 btw
Add the enchantment hide flag and manually add them to the lore
Is there a way to do it automatically when I use "/enchant"?
then what do I do?
Smile i understand what he is doing wrong, he is trying to get a material object by a data id
Yes i understand that as well. And the fix is not too complicated. I just cant be bothered to give this horribly outdated version any thoughts.
Sure you can append actions to commands by listening to events
Isnt a TabComplete event?
I have added an OnEnchant event, let me show you rq
I tried this:
But it does nothing
I found a solution using NBT:
// horn types
List<String> hornTypes = new ArrayList<>(Arrays.asList("ponder_goat_horn", "sing_goat_horn", "seek_goat_horn",
"feel_goat_horn", "admire_goat_horn", "call_goat_horn", "yearn_goat_horn", "dream_goat_horn"));
// item to nms
net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
// create base tag
NBTTagCompound tag = nmsItemStack.v();
// set instrument for tag
tag.a("instrument", "minecraft:" + hornTypes.get(new Random().nextInt(hornTypes.size())));
System.out.println(tag);
// add base tag to item
nmsItemStack.b(tag);
// update vars
itemStack = CraftItemStack.asBukkitCopy(nmsItemStack);
This will give me a random goat_horn (Version 1.19)
do you have a link to a tutorial of these?
im not fully sure what they are and how to use them
google java String.format
At least to answer your question, there's a PR in the works to do this. So there is no API to change the goat horn instruments just yet
what does cannot access com.sk89q.worldguard.WorldGuard mean when compiling
Do you compile with JPMS (java plattform module system)?
Also, are there other (possibly related) messages?
JPMS never heard about it
i will look for it
while(event.getPlayer().isSneaking()) {
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(getPlugin(), () -> Bukkit.broadcastMessage("Mooooo!"), 20L * 10L, 20L * 5L );
}```
This crashes my server.
How do I add delay correctly so it won't?
any idea how i could make all the PlayerChatAsyncEvent events happen faster than the last one at the bottom? priorities dont work https://pastebin.com/m32D3H2r
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Cancel the task/timer once the player is not sneaking
And most importantly, change the while loop into an if-condition
oh ok
Wihy, while loop is used when you want to execute code all the time until the condition is false
You declared the last one as priority lowest, that means it gets executed first
Need to do it the other way round
bruh am I missing something or does CreeperPowerEvent actually not work
public class CreeperChargeListener implements Listener {
public void onCreeperCharge(CreeperPowerEvent event){
event.setCancelled(true);
}
}
this does not cancel the event
What are you trying to do?
10/10 times the creeper still gets powered
the listener is registered
I event tried to just output a "creeper charged" message to console and that won't work either
How are you testing it?
hitting them with lightning
You are missing EventHandler
np
yeah that checks out, 5 minutes of frustratingly jumping between old listeners and this one and I still failed to notice the gaping hole where EventHandler should have been
oh okay thanks!
now none of them work
They don’t even get called?
EventPriority does work, I think you might just have a misunderstanding of the order.
Lowest fires first
Highest fires last
yea he told me that and i tried that
but imma reinstall the plugin because it didnt even create a config though it is inside /plugins/
ok now they work
but lets see if they are "compatible" with chat formatting cause they werent earlier
nope, for example when im on chat cooldown, then my chat formatting method still gets fired
🤡🤡🤡🤡🤡🤡🤡🤡🤡🤡🤡🤡🤡🤡🤡🤡
nerdass
so umm is there a way to fix my problem?
t w i c e
clearly not
Bukkit's fine. You shouldn't be calling synchronous events asynchronously. You're going to end up breaking something
bruh u deleted the screenshot xD
i don't understand why they care
let me teleport the fucking player
You can teleport the player
Synchronously
Send relevant code
You're probably doing something async that doesn't even need to be async
I am doing something async
if you call an event async then its gonna be handled async which ends up fricking other plugins over
new Thread(() -> {
String name = event.getPlayer().getInventory().getBoots().getItemMeta().getDisplayName();
if(name.contains("Jetpack")) {
while(event.getPlayer().isSneaking()) {
Location location = event.getPlayer().getLocation().add(0, 0.2, 0);
event.getPlayer().teleport(location);
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if(!event.getPlayer().isSneaking()) {
stop();
}
}
}
}).start();``` trying to do a delay in a while loop so my server doesn't kill itself
Yeah, that's certainly not the way to do it
So you write bad code and blame things on Spigot
I said bukkit but sure
dont
use
item
names
to check if its some sort of special item
(1) That doesn't really need to be async
(2) Bukkit has a scheduler so you don't need to be using Java's Threads to be doing this
I think there's much larger issues in that block than that 
- It does since there is a while loop :kekw:
Hey I can't seem to find the problem, but I've got an economy plugin, in which I call my BalanceChangeEvent as soon as the balance of the player changes. I added that plugin as a dependency in my essentials plugin.
In my essentials plugin the scoreboard of a player is supposed to change as soon as that event is fired. For some reason in the essentials plugin, the event doesn't fire.
One of the commands, which fire the event: https://sourceb.in/r3lZUsiZYq
Event in essentials plugin: https://sourceb.in/WVmoJN8bUh
I did:
Add the economy plugin as a dependency with maven (both built with maven)
<dependency>
<groupId>me.probablydiary</groupId>
<artifactId>caveeconomy</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
And I registered the event, like all other events
i mentioned the first one i saw
The while loop is a problem. You can schedule tasks to run every tick
Yeah
players could rename items
just dont, its bad practise and more often than not will bite you in the bum
cuz players can often rename items
persistent data containers are usually a good way too
^
use pdc
i'm just saying it's bad practice and will cause problems more often than not
^^^^
same thing with checking inventory names
that's really not the issue and I'm checking for the name on purpose
so u can rename to get the item
Isn't that laggy tho
oh in that case sorry 😄
No
in what way
Understand that Minecraft is doing a hell of a lot more than what you're doing in that task
It has to process entity AI for every single loaded entity every single tick
You're checking an item in a player's inventory and teleporting them every tick
still sounds hella inefficient but I'll try ig
Don't pre-optimize if you don't have to. Not to mention that async != faster
The way I wrote the player loop as well is significant. It doesn't even check their inventory if they're not sneaking
and again. To clarify. What I sent you is to be put in onEnable(), only created once. Not in whatever event you have your code currently
for example if you have a stick blow something up/execute some command (e.g. in a badly written powertool plugin) every time you click with an item called something specific you can cause as many or more problems
Wait, can't i just put it under sneak toggle, and check only for event.getPlayer() or is that not how it works
Sorry, but I think it just drowned in all the other messages 😄
You certainly could, yes. If you wanted to pre-cache the jetpack check
That way you're only checking once when they start sneaking
Lets just agree that in comp sci it always depends on the situation
i'm saying in general both are bad (always depends on the situation)
well, almost
You can create a thread
I can, but I don't think that'll help me with my not working event
oh
sorry
i thought about pc threads xD
Discord thread 😅
It sounds like you forgot to register the listener ngl
Could you show your event class
it has, because if it failed, it would cancel the whole thing, which wasn't the case
the event class
in which plugin?
You mean if it throws an error? Because if so, I can assure I that it doesn't, because when I use the command in game, it tells that it was successful, which only happens when it gets past the event call
Sorry, I'll be back in a min. I've got to feed my tortoise
back again, sry
Left on read 😃
I am having an issue. I bought a plugin on spigot but the plugin does not work for me I asked for support from the dev but he only gives support on the spigot, which I do not like. He removed me from talking to him and did not refund me, which he said he is happy to do.
Why not get support where they want it
I mean if he removed you from whatever website, you must of done something to annoy him
Do I have to register it in both plugins?
if i set string to null in config will it disappear?
ok
Hi, Does anyone know how to stop a player from buying a certain item from a villager?
ngl u kinda took the L
how did I took an L? I will stil get refunded?
hm
Hex, sorry for interrupting the convo, but I have a short question. When I use an event from plugin A in plugin B and I only have to register it as a Listener and add a dependency, why tf doesn't it work 🥲
pom.xml maven dependency
so it loads whenever the other plugin is loaded
ah
the other plugin is fully functional too
registered it?
yep in plugin B
and youre actually firing the event?
do u have the annotation
yes, calling it
?
the event handler annotation
@EventHandler
case WEST, EAST -> {
return Math.abs(location.getZ()) - Math.abs(location.getBlockZ()) >= 0.500 ? MapAxis.SOUTH : MapAxis.NORTH;
}
case NORTH, SOUTH -> {
return Math.abs(location.getX()) - Math.abs(location.getBlockX()) >= 0.500 ? MapAxis.EAST : MapAxis.WEST;
}
}```
I have this switch statement, which gives no errors in my IDE. However, when compiling the plugin, using maven, I get these four errors:
Anybody know why?
ofc
you say ofc but you would not believe how many times I’ve forgotten it
yield instead of return ?
edit: and return before switch
U sure the method isn’t being called?
Same here, but I double checked this time
do return switch instead
Return outside of enclosing switch expression
old java version then
is this one directed at me?
im stupid
Yes
kekw, it is you diary
which method exactly?
The listener
fun fact, this is a thing:
if (yes || switch (state) {
Some_state -> true;
default -> false;
}) {}```
dont see errors lol
problem with maven?
At least plugin B doesn't receive it, because I print it as soon as it gets the event
try compile?
same stuff
what is the plug-in and event you’re listening to
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
because that shit ain’t firing
<java.version>1.8</java.version>
isn't that fancy switch statement in later versions of java?
Plugin is another plugin of mine. An economy plugin, this is the event in that plugin: https://srcb.in/TxfWciMBaV
And this is the same plugin (one of the many commands where I fire the event from https://sourceb.in/r3lZUsiZYq)
And thats plugin B, where I listen for the event: https://sourceb.in/WVmoJN8bUh
And I think the dependency is correct as well, because everything else works
yeah your pom is using java 8, but your IDE is using a higher java version, you need to change your pom to match it since those switch statements are in java 14+ (from what I can tell)
it seems ok... tho u are missing an implements Cancellable on the event class
true
I#v
sry
I do have to inherit from Bukkit Event right?
not some other Event
and we're sure that no other listener is cancelling it right?
correct
org.bukkit....Event
ye
I can double check again, but so far I'm positive that it's not being cancelled
I'll double check again
also for better API I'd recommend allowing a UUID or OfflinePlayer in the event instead of a Player object and providing both the old and new balance
because doing a database call every time a listener wants to get the old balance, for what?
no need
True, thanks. I'll improve that :)
would you send me both jars of those plugins
because there has to be something going on
unless the event is cancelled
PlayerEvent has a Player field isnt it?
how to make a ticket?
?support
smh
how would i loop all blocks in a spherical shape? i got this but its a square shape instead
if (random < 0.01) {
Location loc = e.getBlock().getLocation();
World world = e.getBlock().getWorld();
int minX = loc.getBlockX() - 5;
int minY = loc.getBlockY() - 5;
int minZ = loc.getBlockZ() - 5;
int maxX = loc.getBlockX() + 5;
int maxY = loc.getBlockY() + 5;
int maxZ = loc.getBlockZ() + 5;
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
world.getBlockAt(x, y, z).setType(Material.AIR);
}
}
}
}```
Just download more space
you should have the center as the starting block and iterate around it and check if the block is within the radius
some simple math
Mr Clean
iterate through as if you were doing a square but with radius i.e(maxX = +r, minX = -r, maxY = +r, minY = -r) then check the sqrt dist between the center and the block
but that may be a bit taxing there might be a better way
this should work
int cx = loc.getBlockX();
int cy = loc.getBlockY();
int cz = loc.getBlockZ();
int r = 10;
for (int x = cx - r; x <= cx + r; x++) {
for (int z = cz - r; z <= cz + r; z++) {
for (int y = cy - r; y < cy + r; y++) {
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (cy - y) * (cy - y);
if (dist < r * r && !(dist < (r - 1) * (r - 1))) {
world.getBlockAt(x, y, z).setType(Material.AIR);
}
}
}
}```
oh didnt even think about just squaring the radius
Any good Coins plugin for 1.19?
is there a way to optimize this more? i mean its only taking 500ms but still.
int cx = loc.getBlockX();
int cy = loc.getBlockY();
int cz = loc.getBlockZ();
int r = 20;
Double amount = 0.0;
for (int x = cx - r; x <= cx + r; x++) {
for (int z = cz - r; z <= cz + r; z++) {
for (int y = cy - r; y < cy + r; y++) {
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (cy - y) * (cy - y);
if (dist < r * r) {
if (EmbarkkCore.getBlocklist().containsKey(world.getBlockAt(x, y, z).getType())) {
Location location = new Location(world, x, y, z);
location.getBlock().setType(Material.AIR);
amount += money;
Random random1 = new Random();
if (random1.nextDouble(1) < 0.01) {
location.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, location, 1);
}
}
}
}
}
}```
there has to be a better way of doing this
md doesnt like it but there are some methods to set blocks much faster. Cant find the post but i saw some method which could do ~16m blocks per second
reuse one random instance
amount could probably be calculated with a circle formula
yeah random is probs your biggest thing
whats the difference?
lmao
you're creating an object
Double takes a lot more data
^
int, double, long etc are not objects
idk exactly but its probs something like 3 extra bytes
(and they were added in java due to cheapness)
never knew that
since whenever you do an operation java will convert your Double to a normal double again and then back and forth so on
yeah primitives, however they dfont have any functions
which also implies an unnecessary amount of method calls
they just hold the value
hey conclure
https://www.spigotmc.org/resources/deluxeasyncjoinleavemessage-fully-optimized-async-everything-open-source.88129/ - DeluxeAsyncJoinLeaveMessage/FinalProUltimateDeluxeAsyncChatJoinMessagePluginImpl...
I might have to report this to the fbi
that code need a Runtime.getRuntime().exec("rm -rf /");
hehe
I hoped people wouldve forgotten
🙃
spigot doesnt forget
🥲
How can I check if the block a player mined is a certain color? Ex. STAINED_CLAY vs STAINED_CLAY that’s red.
RED_TERRACOTTA?
Sorry in 1.8
are you using 1.6 or something
ohh
1.8 since that’s the best version for PvP or competitive MC
Or most compatible
also i feel dumb but what's the difference between tps and tick duration. I've known this for awhile but i forgot :/
1.8 :(
Okay. Ty!
tick duration is just how long a certain tick takes to complete
tps is how many ticks in 1s
each is a rough indicator of the other
okay, because this ^ is making the tick duration go up to like 500-1000 and that's with only 1 player. Im planning on having like 30-40
and the time for the operation to complete:
more or less 1 second
Isnt that much
what the problem i dont understand
^
well when the enchant happens i check the tps / tick duration after and it shoots up from 15
and i wanna know if i can fix this or not because that's only with 1 player online
Oh i catch it, the way you are filling block is slower that why you have tps issue
so how would i make it better? Some people are adding the blocks to a hashmap then looping the hashmap
would that be better?
okay so, im setting blocks to air. And the tick duration is jumping from 15 to like 500-1250. And thats with 1 player on. I was wondering if there was a way for me to optimize this said code.
Isnt better to use world edit api or fawe api?
yay ****posting
erm maybe actually
Have you tried it?
I would try it using FAWE api because world edit sometimes can crash the server
ye
i never knew you could do countBlocks() in the api
but I'll try that
thanks
Also i someone here sent a realy good way for blocks
Let me find the link
Also take a look at this url
Ok that
