#help-development
1 messages · Page 1375 of 1
me?
people with formatting
proper
ugly C style namespacing
formatting
C isn't ugly
quit being a bully 😭
void a(ReturnType myVar) {
MyObj obj = myVar.getMyObj();
obj.doSomething("With an argument");
}
I should find a way to get intellij to auto format each save
Are you telling me it won’t automatically add early returns
i wish
Worst program 0/10
@stoic elk still confused?
Visual Studio does offer a lot of reformatting options actually
Net beans did too from what I remember
I enjoyed using NetBeans
sendMessage
player.sendMessage("msg");
sigh
p
bruh im trying my best here
You can't pull an event variable out of your ass either
p.sendMessage()
^ only in lambdas!
bully !!!!!
ive been working on this for like 1 hour my guy

kidding
One letter variables are great for saving precious bytes in networking data
jeez
that looks like nms obfuscation lmao
You can have two Exception catches in one btw
Caps sensitive?
There cannot be a space between MyMethod and ()
lmao
class A {
void b(String arg) {
String c = arg;
}
}
@Oute#5707 how would you do this with an event method?
intellij usually warns you about the Catch when they can be compressed into one
@stoic elk
naming conv
more short variables
arg would be the variable right
right
but we want an event
so put an event as the argument
remember, (ReturnType variable)
arg is a parameter, so yes a variable
uhhh
just try using what i just said
i gave plenty examples
Do you have a personal vendetta against vowels?
Should the MySQL connection be run in an new thread ? I'm not sure if I keep it this way that it will cause server freezes.
yes, db should always be on another trhead
if possible i would
Okay thanks 🙂
You should use bukkit runnables over a thread
dude i dont know where to put what
^ I actually never used those. Mostly used java schedulers etc
bukkit runnables and java runnables are pretty much indentical, just has more bukkit related methods in it lol
Ah then I keep it just the way I do things :p
class A {
void b(String arg) {
String c = arg;
}
}
the parameter would be YourEvent event
then you can get the player or whatever
no
like PlayerInteractEvent
would be the type
then event as the name
void myFunc(PlayerInteractEvent event) {
}
then you need to set up this class for listening to events
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I have several questions
Is PlayerNameEvent even an event ?
No
idk
bruh im trying
sure
You are missing @brave glenHandler btw @stoic elk
when I have some free time I will
after i get this working im going to bed
its 12:30
And did you implement listener?
dont confuse him too much
you too
It’s just something he has to add
its not your vurrent issue
Above the method
idk what the fuck it does but i had it
(The public void)
o
stop adding me lol
ok i saved it
I’m talking about personally
is a class worth taking on it
People who actually talk to me
No, a website/YouTube tutorial is good enough
bruh im not learning jack tbh
Don’t bother spending money or anything like that
i learn more by reading over existing code and by hearing other people talk about it
public class BlockBreakListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
player.sendMessage("Hello");
}
}
@Oute#5707 promise me you will learn java before coming back asking a syntax question
@stoic elk
i have rly bad adhd and cant pay attention to that shit
Correct
Yes you’re a robot, designed to help people with plugin development.
ik i just must seem too pefect
wtf
Lol
where did you get that code
That’s funny
?
you just pulled code out of your ass
wdym
what did i do
im so confused
Why is that class on the If 🙃
Where did you get the top part
thats the diamond ore thing from before
i'm losing my mind ffuuuuc haha
enough discord for today
im braindead im sorry
I have an event where if a player drinks a potion, they get "potion effects" which works all fine and dandy. But I also want to implement another feature where the player will get knockback resistance 100 when they drink it, then have a scheduler which sets the player's knockback resistance back to 0 when it the timer ends
i don't understand
Good job
Noice
Congratulations @stoic elk :D
Like I told you, pass an instance of your main class into the constructor of that class
Aka dependency injection
Might want to reformat the code with intellij though oute
he already had the fucking code
he was making another method inside his if statement
Oh so he just had an extra brace and tried fixing it by pasting a listener class inside his method inside his listener class
i have succeeded
but the events class is in a different file to the main java file
UHCum
yes
Nice plugin
i followed a tutorial for most of the first part to try to learn basic stuff
Does it spawn particles
it doesnt matter
thanks, I still don't know why it works
import it
i did do some stuff on my own tho not alot but
I suggest learning the basics of the language first
it's already imported but how to i inject it or whatever it's called
like it's greyed out, the rest of the imports have colours
@quaint mantle thank you lol
I assume it’s because you haven’t used it
new ClassName(this);
Assuming you have the constructor setup to take an argument
Public UhCumEvents(Plugin plugin){}
public*
Maybe show the whole class of your event.
Most LCD screens don’t support ink based input
this is what i got
I dislike how Intellij markes events as being unused
You haven't create the constructor
Like this
what kind of class name is that btw
hol up, what
lol shit what's that?
although if you're not dependency injecting you don't need a constructor to call the class, just (new ClassName(), this)
If you don’t know what a constructor is u should learn that
he needs DI for creating a runnable.
Not that I’m one to speak I did the same thing lol
I did not know this, the class looks like it's not throwing any errors and is just a Listener without any JavaPlugin calls 🤷♂️
they named their main class Main 
first reply is a staff tells to avoid naming main class as Main xd
pff
Anybody ever made a roblox game that made money
Bet some of them take in serious cash
At no cost other than development
I used to make em ages ago but never made anything lol
Screams in 1-indexed arrays
man lua hold your hands so much lmao
using bungee api?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
well if it's unused, then that gives you the answer that you aren't calling the event, since I'm pretty sure all events get marked whenever they get called
in the called class
It doesn't, at least not for me 🤷♂️
and yes they are being registered
I'm trying to figure out if there's any event thrown when a baby hoglin ages into an adult hoglin. From what I can tell there is no event.
Marking public methods as unused is a stupid default
Same for me, and it's bothering me for some reason xd.
Looking at that gray colored method
There is probably some way to disable it in intellij's configuration, I'll have a look later c:
How would I make a cooldown for lets say interacting with something?
Here you can see how we did that with this listener. When you attack a mob it shows you debug info. When the event fires it adds the player's UUID to an array, then starts a BukkitRunnable with a 40 tick delay which will then remove that UUID from the array. If the event fires and the UUID is present in the array, the function is exited
https://github.com/lokka30/LevelledMobs/blob/master/src/main/java/me/lokka30/levelledmobs/listeners/EntityDamageDebugListener.java
ty
@fickle helm delay.add(player.getUniqueId()); new BukkitRunnable() { public void run() { delay.remove(player.getUniqueId()); } }.runTaskLater(plugin, 80);
would that work?
(I have nothing in my main method idk if that has anything to do with it)
I think so. Looks like how we have it setup
hey guys
does inventories
or playerinventories
have the items in them?
cuz im making a staffmode plugin
where they can switch between their staffmode inventory and their in-game inventory
hello
can someone exmplain me how to include external library to my plugin ?
java.lang.NoClassDefFoundError: org/java_websocket/server/WebSocketServer at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?] at java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[?:?] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) ~[?:?] at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:163)
Are you using maven or gradle?
set the dependency to compile rather than provided in your pom
it is set to compile
then it shoudl be auto shaded. no shade plugin needed. its auto
Read through that guide and setuo the maven shade plugin
@chrome beacon ok thx
InteliJ or Eclipse?
InteliJ
I've always needed the shade plugin
I can;t say on Intelij. in Eclipse you don;t need the shade plugin defined in your pom, its auto included with defaults
It's smart to relocate shaded things anyway so might as well use the plugin
relocation is really complex though as the references are not updated in yrou source when teh lib is shaded/relocated
@gleaming grove what lib are you wantign to shade?
<dependency> <groupId>org.java-websocket</groupId> <artifactId>Java-WebSocket</artifactId> <version>1.5.1</version> <scope>compile</scope> </dependency>
hey guys
does inventories
or playerinventories
have the items in them?
cuz im making a staffmode plugin
where they can switch between their staffmode inventory and their in-game inventory
Yes they have items they are inventories?
okay
i thought it was just the inventory object
like size
not contents
but ty :P
@torn oyster for(int i=0;i<player.getInventory().getSize();i++) { ItemStack itemStack = player.getInventory().getItem(i); }
what
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.java-websocket</pattern>
<shadedPattern>org.shade.java-websocket</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>true</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>````
still dont work, what I'm doing wrong ?
hi i have a problem i wanna create a tablist but there's no method like IChatBaseComponent or CraftPlayer or anything on 1.12.2 spigot.
import your spigot.jar file to your project
Yeah you're going to have to build the 1.12.2 jar and import it 
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
?bt
public static void onBlockBreak(BlockBreakEvent event){
Player player = event.getPlayer();
if(player.getItemInHand().getItemMeta() == null){
return;
}else{
String mainhand = player.getItemInHand().getItemMeta().getDisplayName();
if(mainhand.equals(ChatColor.GOLD + "Excavator")){
Location loc = event.getPlayer().getLocation();
World w = player.getWorld();
w.createExplosion(loc, 2, false);
}else{
return;
}
}
}``` anyone have any idea why it doesnt explode?
copy
I'm betting it fails on yoru mainhand.equals test
have you include @EventHandler above method?
i just use maven jar spigot and idk fixed it
how do i add placeholderapi to maven?
it says it didnt found
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
it doesnt work for me
are you using the right version
yes too
used by this
inteliJ or Eclipse?
intelij
are you just nto seeing PlaceholderAPI in your IDE or not workgin when exporting?
when you export are you using Artifacts or lifecycle?
artifacts
thats wrong. You probably also manually imported spigot
no i did it with maven
.
you are not using Maven in yrou enviroment so your pom is doing nothing
i do use it
If you are using artifacts you are not
show me a SS of your projects dependency libraries
expand external libraries
how do you code with lightmode lmao
You have two issues...
- your are exportign incorrectly, Right hand side expand the Maven tab and use package in the lifecycles section.
- You need to clean/refresh yrou project to include yoru maven pom changes
main screen, very right hand side is a bar with a Maven symbol
yes
okay
open that, expand the lifecycle section and run a clean
omg it works?
to export yoru jar properly you run package adn yoru new jar will be in a target folder
guys any ideas how to make /reply command?
do you do /msg?
yeah same idea
ig u could use hashmap<string, string> first string is the playername and the other is the other players name
use UUID not names
in hashmap
yes
dont do static
and how it would blow
i mean you can use hashmap because its the most easiest way, but if you want you can use something else
actually in this usecase static wouldnt be bad
man i had some problems with my RAM memory
because of using public static maps
etc
just have a messagemangaer class which has a hashmap which is a cache of last message sender
one map wont do anything
i doon't know how can i say that in english xD
on yeah xD
and geetting it with Bukkit.getPlayer?
yep
@graceful turret Moge ci pomóc na priv
private static HashMap<UUID, UUID> playerMessageCache = new HashMap<>();
public void sendMessage(Player sender, Player recipient){
playerMessageCache.put(recipient.getUniqueId(), sender.getUniqueId());
}
public Player getReplyRecipient(Player sender){
return Bukkit.getPlayer(playerMessageCache.get(sender.getUniqueId()));
}
done done
man
is that 'java.util.uuid'?
yes
have you never used uuids before?
Liskovs substitution principle tho
i have
but
i had small mide fuck
lmao
@drowsy helm https://paste.md-5.net/ricuyolado.java check
are you registerign msg and reply to teh same command executor?
what is the async event where I can get the session and do http request to Mojang with it (for cracked servers)?
looks good to me
why you have to iterate over each player
Bukkit.getPlayer(args[0])
then check if not nul
I dont see the method, also i wanna change the uuid
then you are on an old version
spigot
much newer
That method is not in 1.8
You might be able to do it with some reflection magic
see if this exists in yoru version https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerPreLoginEvent.html
I just gonna tell what i wanna code
A plugin that sort premium and cracked players
Every cracked player given random uuid
Premium gets his actual uuid on mojang
And cracked has to login and register
To know if user is premium
I need to make a request to mojang session servers
There is almost guaranteed to be a plugin that already does that
Whatever gonna make my own for my server
@client.command(aliases=['c'])
@commands.has_permissions(manage_messages = True)
async def clear(ctx, amount=100):
await ctx.channel.purge(limit=amount)
await ctx.send(f'Deleted {amount} Message(s)!')
You guys know wich code i've to add so the bot waits 3 sec and then delete his own message ?
Python?
yess
You'd probably have to make a string or something then call a wait value then remove that string
Idk how python works so I can't help you there
You should look at open source code by other devs or just Google it
alright thx
Np
Guys, i've a question, how can i make the item named "&dHello" with the texture hello.png (For example)?
You'd need a resource pack @green prism
You're just making an item by either an event or command so if an event OnPlayerJoin or something you'd need to use the Item class and generate it, set it to the position and item.Meta("&dHello");
item.Enchanted(true);
Search up some documentation
I half understood, I don't find any documentation about it
Learn to code your own Minecraft Spigot plugin in this complete tutorial series! In this episode, we create a custom item that has some custom text, lore, and effects.
--- Important Links ---
● GitHub: https://github.com/TechnoVisionDev/Spigot-Tutorial
● Discord: https://discord.gg/m5fjByfrKP
--- Music ---
● Chill Out Records - Minute Mix
-...
How tf do I delete embeds on phone
Send help
@green prism ^
No, this video is for a custom enchantments
not for custom resourcepack
TechnoVision should be avoided in my honest opinion
Hello mr.Eclipse!! How are u?
Also one way to avoid embeds is to make them code; like this: https://www.youtube.com/watch?v=dQw4w9WgXcQ
Never gonna give u up? Srsly?
Come on gentlemen, a little help please, I need a custom texture attributed to something, not custom enchantment (Stick texture = "stick.png" Stick named hello = "hello.png")
Thats what I was stating :/
Youd need to set it through the server
And then the item should be it
I never worked with custom textures though, so I cannot say how exactly that works, except that you need to use resource packs
So like a barrier block could be replaced as Hello.png
Hello, if I use Bukkit.spigot().restart();, the server only stops.
Or you could use the 2000 blockstates mushrooms introduce
Okay, now thanks to the dearest gentleman whose name I can't remember, how do I set it up via server?
Send a resource pack?
How is nuclear power created? Put the plutonium, easy
https://www.spigotmc.org/resources/force-resourcepacks.10499/ just copy whatever that plugin does
How would I get around the "Unsupported API version 1.16" to allow the plugin to support multiple older versions?
You have to write for the oldest version
ah.. Great
I know but... i need to make Stick A = png1.png and Stick B = png2.png not send a resourcepack
You cannot do that without a resource pack
If you think that you can do that then you should not ask me about how to do that since I will say "no, you cannot do that that way"
I try to explain better what I did not understand before:
I didn't understand how I associate a blockdata with a resourcepack.
I don't need to know how to send it.
how do i inject this into the main plugin? I'm quite a big newbie
I HAVE NEVER DONE IT. I cannot really help you on this since I have never messed with resourcepacks nor with custom model data
Ah perfect, so i like myself
You'd either need to do dependency injection (pass the plugin instance across the classes) or you have to create a private static field with a public getter
You can pass the plugin instance across classes by using the constructor; so instead of doing new MyClass() you'd do new MyClass(this) in you onEnable
Is that a guess or do you know?
I know that, I have worked with java long enough to know how it works
In according with this https://www.planetminecraft.com/forums/communities/texturing/new-1-14-custom-item-models-tuto-578834/
and this https://www.spigotmc.org/threads/custom-item-data-nbt-api.43987/
I don't know and thanks.
sorry I've been stuck on this for the past 3 hours and I still can't get it and I'm desperate because this seems so easy to so many of you guys but no matter how many times I try and how many example my brain just can't wrap around it
this is my main java file if it helps
What's the problem?
I just can't seem to get DI to work
like at this point I'm willing to just send the whole file over if I need to
Can we see the UH class?
you're not even doing any dependency injection at the moment
ideally you'd pass your main instance through the other class constructors
Yes, u need a constructor
I mean I did send you an example https://gist.github.com/Conclure/a01d187ab9127149a919daec6547757f but is it still unclear?
like
private final Main plugin;
public Class(final Main plugin) { this.plugin = plugin; }
pass this
it shouldn't be called Main then
but rather UHCum
since that's your main class
(the one that extends JavaPlugin for you)
yyuuuep
there is no EventHandler
so
private final UHCum plugin;
public UHCumEvents(UHCum plugin) {
this.plugin = plugin;
}
//then in main
...registerEvents(new UHCumEvents(this), this);
The EventHandler annotation is irrelevant here
Hello,
I currently rework my project with maven in multi project (one for each platform).
But i have some issue i want to fix :
- i want disable common and parent build
- find an way to have common shade but the specific relocation for bungee (adventure implementation)
- bonus: centralize final jar inside same folder at root
This is my repo : https://github.com/orblazer/maven-bug
Thanks by advance for your help
uh I mean gradle :>>>
https://github.com/Zedly/Zenchantments has always been my goto place to look up things when having issues with multi-module projects
In this case, the bonus would be something like
<build>
<defaultGoal>clean package</defaultGoal>
<directory>../target</directory> <!-- Build it one level up, because it is the one we care about -->
<finalName>Zenchantments</finalName>
<!-- etc ... -->
</build>
yes i have want to move on gradle but i have issue with that an i have lost 3 days without found an solution
You can also re-declare dependencies with the compile scope to shade them
Oh well I could make a pr for u or smtng in gradle if you’re interested
I. e. in the non-final artifacts the dependencies are all provided and only outside of that they are compile or other scopes
what are all the data types the configuration.getMapList casts? does it parse datatypes like Integer? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/ConfigurationSection.html#getMapList(java.lang.String)
You can't really know the signature of the map since signatures are stripped at runtime. When using that method you have to use "unsafe" casts (unless I'm getting things wrong)
ok, i just need recreate it because i have delete my project 🤦♂️
🍉
holy shit you actually fixed it for me ilysm
I'll definitely look at more tutorials and javascript introduction videos to expand my knowledge further more before diving deeper, but it is a lot more reassuring to know that the code is finally fixed
thank you savior
UHCum, interesting class name
Just refactor it if you wanna change it lol
nah I'm good, I have a ton of other plugins on my server and they all use uhcum so
too late
Is there a way that you can change durability of any item?
Like a player head for example
Depends your spigot vers
1.16.5
oh well it was worth a go
are you trying to set a player head to a skull?
if so cast the skulls itemmeta to SkullMeta and use setOwner
also is there still a way to have custom colors onto potions?
@elfin minnow
sorry for bulging in
it will work?
@haughty haven not without throwing a resource pack at the player
yeah I thought so
I already have a resource pack which works with optifine to change the texture of drinkable potions (can't get it to work on splash potions tho :()
I am using this to get the player head
since when is it deprecated?
Skull
then i give it attributes, dont look at the numbering
wait it has its own class now?
I'm not sure I've only ever done this in 1.16.5
was directed at elgar lol
oh
it means stop copy pasting code and use your IDE and javadocs to show you teh valid options
You are using + instead of ,
i changed it
And?
How can I do a block that replant seeds above him when the wheat is broken?
Can somone tell me why my code doesnt apply to baby zombies? https://github.com/SamiCraft/SamiMobs/blob/main/src/main/java/com/samifying/mobs/ZombieVillagerCure.java
I am speechless
When a baby zombie zombiefies a villager and then you cure it they lose the trades
i cant get it
Cancel teh harvest event, manually drop the drops and set teh block type for the crops (setting the type will reset their age to zero
A lot of plugins replant any broken wheat but I want that it replants only a block that the player can buy in shop
You can;t do a specifc block to do that without trackgin those blocks in a db or PDC
PDC is not really recommended, especially with bigger volumes
How do I track a block?
a database or the chunk PDC
Basically store it's location somewhere
save the location, i suppose a database is a much better solution although a little bit complicated for end users
SQLite is also a good compromise between setting up for user and speed
Well you dont have to be good at plugins you need to be good with java tbh
just use the Chunk PDC. no database to deal with
Idk why adults would keep it either, if you just spawn an entirely new entity. You have to set it's villager data as well. Afaik that's only possible with NMS or keeping track of the trades with a map or something. (At least I can't see any API methods.)
what's wrong with my plugin yml? https://paste.md-5.net/odequdowaq.css
I think I need a tutorial
Doesn't look wrong to me, what's the error you get
it does not have the API-version set
apparently it doesnt contain my plugin yml
Your JAR doesn;t contain your yml
Find your connector on maven and add it to your project
try{
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/sonoo","root","root");
//here sonoo is database name, root is username and password
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
rs.close();
con.close();
}catch(Exception e){ System.out.println(e);}
}
this is just an example select statemnet
This is just an example on how
That is an issue with your build system, not exactly your plugin.yml
This example doesnt represent a good way to store passwords ether
use hash for that
you don't need to, all it does is give you legacy materials etc. and not modern ones
With armorstands maybe?
There is an easier way, as I said, Use the Chunk PDC
Well i dont recommend anything else then a good old database
Yes, but as a 1.16 user it is pretty bad to see a 6 second wait just because some random plugin decided to not write this one line for absolutely no reason
Take a look at BlockStore (https://www.spigotmc.org/resources/blockstore.19494/)
Just use the damn chunk PDC. This is what its for. Tracking things IN the chunk
Idk how to do that
It saves and loads with the chunk
search Persistent Data Container.
all entites and every chunk has one
Look I'm a begginer with plugins...
Question is whether it can store that much data
...so can someone do it for me ?
Of course it can, you are only storing block locations
Just use a god damn hashmap that you serialise on shutdown and deserialise on startup
Yes, but you need to know what you "special" block is
(If someone know how to do it send me the code)
We don;t write code for you
Ok
Just remembered, there's also a neat resource smile posted the other day on exactly that topic (https://www.spigotmc.org/threads/tracking-blocks-that-were-placed-by-players.500216/)
No a special block like with a special name
private static final HashSet<Location> SPECIAL_BLOCKS = new HashSet<>();
here, this is your database
If you want a "special" block with its own name then you have to use datapacks
okkkkkkkkkkk
He would still have to save and load that
(How do I do a datapack heeeeeeeeeeeeeeeelp)
throwing it on the PDC its all done for him
How do I use** PDC**?
?jd
package index
At this point we're gonna end up with the question "how to install eclipse"
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataHolder.html and that is the holder (which in this case will be chunk)
Is there some JavaScript programmer that can exmplain why when i send ByteArray from WebSocket client i got empty array on WebSocket server ?
i have re create my issue : https://github.com/orblazer/gradle-bug
The bug i have for now : i have jetbrains annotations only in bukkit module
Why annotationProcessor
Pls don’t tell me ur Lomboky
Anyways add as compileOnly as well
btw how do you imbed lines of code here?
What is wrong with Lombok
?paste
It’s useless arguably
I like the getters and setters only. It’s just less work to type
To put it clearly Lombok doesn’t in fact provide any meaningful value
Well IDEs exist for a reason nevertheless
java //something
And they can also hide it such that it doesn’t get too verbose
Yea I realized that IntelliJ could do that after I started using Lombok
```java
<code>
```
//something
hello, i'm setting entityzombie(NMS)'s equip. but i have problem with Imaterial. how to use it?
oooohhhhh
zombieAI.setEquipment(EnumItemSlot.LEGS, new ItemStack((IMaterial) Material.AIR);
it doesn't work
IMaterial is an nms interface?
i understand now
Yup
zombieAI.setEquipment(EnumItemSlot.LEGS, new ItemStack(Imaterial...) //How to use it;
iirc you’d have to use the material registry if you wanna create an nms stack or maybe I’m wrong here but coming from the modding side you’d have to at least. Have you googled?
btw how do you reference this line of code
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
}
Reference?
hmm, of course, I already googled. like "spigot entityzombie equip" and i couldn't understood
like this ``` public static void init() {
createTnt();
}
private static void createTnt() {
// something
}
```
I mean it’s referenced now? Or you’re invoking that createTnt method in init
and so to reference this we can do this
item = Createtnt.createtnt;
uh what does mean? referenced
ZombieAI zombieAI = new ZombieAI(event.getEntity().getLocation()); if I understood correct
?
super(EntityTypes.ZOMBIE, ((CraftWorld) location.getWorld()).getHandle());
this.setPosition(location.getX(), location.getY(), location.getZ());
}```
That would create and put ur zombie into the world
uh getBukkitEntity()#getEquipment() isn't exists
What nms version
v1_15_R1
ZombieAI zombieAI = new ZombieAI(event.getEntity().getLocation()); // (NMS EntityZombie)
😦
super(EntityTypes.ZOMBIE, ((CraftWorld) location.getWorld()).getHandle());
this.setPosition(location.getX(), location.getY(), location.getZ());
this.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET,1));
} ```
try like this
or zombieAI.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET,1));
Oh yeah you might have to cast to living entity
so this is a way to reference code
public class CreateTntWand {
public static ItemStack wand;
public static void init() {
createTnt();
}
private static void createTnt() {
ItemStack item = new ItemStack(Material.STICK, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Tnt Stick");
List<String> lore = new ArrayList<>();
lore.add("§7The Staff of Gods");
meta.setLore(lore);
meta.addEnchant(Enchantment.KNOCKBACK, 5, false);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
wand = item;
}
}
and to reference it in another class is this
if (cmd.getName().equalsIgnoreCase("givetntwand")) {
player.getInventory().addItem(CreateTntWand.wand);
}
Ye I guess?
sadly, getEquipment() not exists 😦
so is there a way to reference this
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
}
Spigot references that.
Toto
Also, getEquipment().setHelmet() not exists
Cast to LivingEntoty
okay
how?
LivingEntity bukkitEnt = (LivingEntity) getBukkitEntity();
bukkitEnt.getEquipment()
Etc
(LivingEntity) zombieAI.setEquipment(EquipmentSlot.CHEST, new ItemStack(Material.AIR)); still error on Material.AIR
minecraft and spigot directly reference that when a command is run.
oh ok
Yeah use the Bukkit representation
e.getEquipment().setHelmet(new ItemStack(Material.AIR));```
thanks but still error on Material.AIR
yeah but how do i reference it like this
you cant put air
Why?
set setHelmet(null)
yup, I know but i'm just testing
I won't put air 😉
Check so it’s the Bukkit import of ItemStack?
OHHH Thanks
it works
e.getEquipment().setHelmet(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BAMBOO_SAPLING));
thanks @ivory sleet and @gleaming grove and who that helped me
np
my code is under that so i thought if i can reference it i can run that code without making a whole other class
Are you trying to make it so when a command is run you get a wand?
public class CreateTntWand {
public static ItemStack wand;
public static void init() {
createTnt();
}
private static void createTnt() {
ItemStack item = new ItemStack(Material.STICK, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Tnt Stick");
List<String> lore = new ArrayList<>();
lore.add("§7The Staff of Gods");
meta.setLore(lore);
meta.addEnchant(Enchantment.KNOCKBACK, 5, false);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
wand = item;
}
}
This should be in an item manager class.
if (cmd.getName().equalsIgnoreCase("givetntwand")) {
player.getInventory().addItem(CreateTntWand.wand);
}
This should be inside of the command manager.
what is a manager class?
Your CreateTntWand class is inside a separate file than your command manager yes?
but no not that, this
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
}
A class that manages something or somethings
so the code is under that and i want to reference it
Why are you trying to put it all in one file?
That will just lead to a bunch of confusion if you try to add more items.
im not putting it all in one file
if (cmd.getName().equalsIgnoreCase("givetntwand")) {
player.getInventory().addItem(CreateTntWand.wand);
}
This should be inside of the onCommand method.
im just trying to reference
*example
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
//something
}
*in another class
if (SomeClass.onCommand(//i know it doesnt work like that but this is a example)) {
//code
}
that is what im trying to do
@rapid roost you can trigger your command like this
Bool result = Bukkit.getServer().dispatchCommand(player, command);
Always use an API over dispatchCommand if you can
?paste
when my players are teleported to l, the chunk for some reason doesnt load and they fall forever in the void. heres my code, i make a chunk ticket before teleporting and stuff too so idk what the issue is
add teh ticket before you run your task to teleport
i did
not in that code you didn;t
really?
you are adding the ticket in the task
for (UUID playerID : players1v1) {
Player player = Bukkit.getPlayer(playerID);
if (player == null) {
// player is not online so just skip to next uuid
continue;
}
player.setGameMode(GameMode.SURVIVAL);
player.teleport(l);```
i add it before the for loop
yes, Inside teh task
i add it before the scheduler?
Are you having problems reading your own code?
no, im just confused abt what task ur talking abt
you only have one task in that code
Bukkit.getScheduler().runTaskLater(this, () -> {
yes, add the ticket BEFORE you run your task.
thank you
guys there is some option to get currert server tick
int startTick = Bukkit.getTick();
// code here
int lastTick = Bukkit.getTick();
int deltaTime = lastTick - startTick; ```
i would like to get sth like this
Caused by: org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here
in 'reader', line 18, column 21:
description: allows players to set warps
^
i got this error but have no clue what it means, can someone help me? TIA
?paste your file
int currentTick = (int)(System.currentTimeMillis() / 50L);
Hello, spigot i have problem in get custom name in creature spawn event
:
public void onEntitySpawn(CreatureSpawnEvent event) {
Bukkit.broadcastMessage(event.getEntity().getCustomName)``` it returns null
(I set mob's custom name in another plugin)
Btw, I made custom name and summon in another plugin.
I see nothign wrong with that yaml
I deleted the 'description: allows players to set warps' and retyped it. then reloaded it and it worked fine. Thanks for the help anyway
Might have used a tab space in it maybe
nope, it would have said tab
oh, idk what did it then. Works now though
Hey, does anyone know the cause of the error:
#This is the code
#And the error is ```Cannot resolve method 'setPlayerListHeaderFooter(java.lang.String, java.lang.String)'```
You are not using 1.16 or any version that has that method
Ohh
It was introduced in 1.13, so your server is below that while the API you're trying to use is above that
Nvm, I knew the cause
what version spigot are you building against?
1.12.2
What happens when I use bukkitRunnable.runTaskLater(plugin, 0)?
Does that just queue the task onto the next tick or what?
it'll run on the next tick
Look to see if it has teh seperate header adn footer methods
Alright thanks.
Is there anyway to make a Tablist plugin on 1.12.2?
yes there is
Send me link or something
Love the video or need more help...or maybe both?
💬Join us on Discord: http://discord.gg/invite/fw5cKM3
Thank you for tuning in to this episode of TheSourceCode! ❤️
If you enjoyed this video make sure to show your support by liking , commenting your thoughts, and sharing for all your friends to see and learn!
All code is available on Github:
...
That didn't work
Ever heard of Google 🤔?
you have to use 1.12 api instead of 1.8
How do I change the API?
what IDE are you using?
Intellij
alright go in pom.xml
scroll down until you find something called 1.8.8-RO something
change it to 1.12.2
anyway I meant the code
<version>1.12.1-R0.1-SNAPSHOT</version>?
put 1.12.2
I'm using 1.12.1
oh
They
They're the same
But I'm not coding on 1.8
PacketPlayOutPlayerListHeaderFooter Doesn't work for me
What should I use then?
Tablists xd
I mean how do I make a tablist without packets
a reminder to not write code as messily as him
you can't
afaik
teeeechnically you can't do anything without packets
considering that bukkit is just a wrapper for them
technically
I assume the setPlayerListHeader/Footer are not around in 1.12?
I really wanna know why I can't import the IChatBaseComponent and ChatSerializer
It's only for 1.13 and above
Is there anyway to do something like add build path on Intellij?
I think you can get away with just using
new ChatComponentText("...");
Anyone had any luck with getting inventory name? Using inventory click event and need to check the name
event.getView.getTitle
Hey I have an error,
Could not pass event InventoryClickEvent to WolfPVPMain v1.0
org.bukkit.event.EventException: null
i have no idea how to fix this, even went through an entire tutorial again to watch how he fixed the error but that fix didn't work. Anyway here is the code
public class gameSelectorListener implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (event.getView().getTitle().equals(ChatColor.DARK_GREEN + "Select a game!")) {
event.setCancelled(true);
if (event.getCurrentItem() == null) {
return;
}else if (event.getCurrentItem().getType().equals(Material.STICK)) {
player.teleport(Bukkit.getWorld("knockbackArena").getSpawnLocation());
player.closeInventory();
}
}
}
}
If anyone knows how to fix this please tell me
Bukkit.getWorld("knockbackArena")
is probably null?
your error w ill tell you class & line
if (e.getCurrentItem() != null && e.getCurrentItem().getItemMeta() != null && !e.getCurrentItem().getItemMeta().hasDisplayName()) {
return;
}
Made sure that was the world name, it is
I'll try this
It doesn't work, still throws the same error
Thats not going to work, but its close
Hm ok
I added this
knockbackArena
whoops
wait there
new WorldCreator("knockbackArena").environment(World.Environment.NORMAL).createWorld();
throws more errors lmao
The process cannot access the file because another process has locked a portion of the file
if (e.getCurrentItem() == null) return;
if (e.getCurrentItem().getItemMeta() == null) return;
if (!e.getCurrentItem().getItemMeta().hasDisplayName()) return;```
Ok i'll try this
you can make that one if statement using || but separate is cleaner to learn.
Now its throwing no errors, but its not working lamo
lmao*
This is the code atm
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (event.getView().getTitle().equals(ChatColor.DARK_GREEN + "Select a game!")) {
event.setCancelled(true);
if (event.getCurrentItem() == null) return;
if (event.getCurrentItem().getItemMeta() == null) return;
if (!event.getCurrentItem().getItemMeta().hasDisplayName()) return;
} else if (event.getCurrentItem().getType().equals(Material.STICK)) {
new WorldCreator("knockbackArena").environment(World.Environment.NORMAL).createWorld();
player.teleport(Bukkit.getWorld("knockbackArena").getSpawnLocation());
player.closeInventory();
}
}
}
Hello !
What do you want to achieve ?
I want it so when the user clicks on a stick inside my UI, it teleports the player to a different world
You are trying to click your "Select a game" inventory, and it's not working right ?
Yeah
Yeah that's what your code is saying if i'm right
if the menu name matches it has no code to run other than testign to see if it needs to return
Because you check if it's the right inventory, if it is, the "else if" does not run
You should remove your else if, and instead just put an if, but inside your first condition
I think
^ correct
Ok that makes sense
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (event.getView().getTitle().equals(ChatColor.DARK_GREEN + "Select a game!")) {
event.setCancelled(true);
if (event.getCurrentItem() == null) return;
if (event.getCurrentItem().getItemMeta() == null) return;
if (!event.getCurrentItem().getItemMeta().hasDisplayName()) return;
if (event.getCurrentItem().getType().equals(Material.STICK)) {
new WorldCreator("knockbackArena").environment(World.Environment.NORMAL).createWorld();
player.teleport(Bukkit.getWorld("knockbackArena").getSpawnLocation());
player.closeInventory();
}
}
}
}```
Like so
Ok imma try it
Its giving me two erros
lemme send
Could not pass event InventoryClickEvent to WolfPVPMain v1.0
org.bukkit.event.EventException: null
The process cannot access the file because another process has locked a portion of the file
I had a question too, I might just don't know something about boolean expressions, but this condition is never checked right ? Because of the false && (so that it's never true, so not checked)
if (false && applyPhysics && getData() instanceof Attachable)```
no, thats an and conditional. It depends on BOTH
use || if you want it to fail progressively
Both need to be true right (to execute the code inside the statement) ?
yes
It's extracted from craftbukkit source code
So since there is a false sitting here, it's never true, and never checked right ?
so yes, your statement is correct, that code would never pass
That's what I thought
I have a problem for one of my plugin, glad I found the source of it x)
What is the point of this ?? xD
Your world is already created. You shoudl check first before trying to create it again
too small can;t read
Doesn't throw that error anymore
oh sorry