#help-development
1 messages ยท Page 1674 of 1
and be happy https://paste.md-5.net/yafovomuge.java
people hate pinging them
if he wants to see it maybe?
it's after a coversation we had
imagine i'd ping an admin everytime i want help from them
do you scroll up every single channel soo see if somebody sent something to you after getting on dc?
sometimes
well
im in about 20 servers
probs at least 100 channel
s
cant say I have the time for that and I woudn't think any body else does eather
i'm on like 50 servers
active on maybe 3
Send code
Listen, pinging someone is dependent on that person's mood and whether or not they want to be pinged. You can't just plainly say "Everyone hates pings" because sometimes I don't :p
why's that second one end in .kotlin? it's not Kotlin
I'mma just blame Hastebin for that
Is there a means of calling a loot table in a plugin?
when you spawn an entity in your event handler it runs the listener again
that's why you're getting an overflow error
i'm not sure, but what i did is check the spawn reason in your listener
you can test if a plugin spawned it, or commands, natural spawning, etc.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html
declaration: package: org.bukkit.event.entity, class: CreatureSpawnEvent, enum: SpawnReason
yep
fun
Just toggle a boolean before and after you actually spawn it
if a library doesn't provide a (maven) repo but provides the dependency, what do I do?
install
wdym?
if its a maven project you can just run mvn install and it will add it to you rlocal repository
oh, idk what the heck i was doing. it resolved the dependency
just need to shade it in
has anyone ever pulled off a per player message logger in mysql? or is some other database that isn't strictly tables and columns like mongodb required, without of course encoding/decoding base64 to hold data types not viable in mysql, seems that my database choice has been a downfall and a waste of time due to my endeavor
depends how you do it
but I'd probs say redis
how would I send a message to a player that has multiple lines from the config
like say
//Config.yml
sendmsg:
1: ''
2: ''
3: ''
//etc in number order or whatever
getStringList
hes right
how would I send the message then?
sendMessage( getString(key) )
and then have a public void above that for the getconfig stuff
I also saw this somewhere
for (String line : getConfig().getStringList("helptext")) {
player.sendMessage(line);
}
would that work?
if you decide to define it as a list, then yes
Hey there guys, how can I prevent a player from clicking inside an inventory that gets opened? I want them to be able to hover over items but not take them out or interact with them.
?eventapi
event.setCancelled(true)
InventoryClickEvent
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
//Config
//When a player has no permission show this message.
nopermissionmessage: |
&4&lALERT!
&c&lYou do not have permission to send:
could I do this?
try it
ok
its 2 spaces
Refactoring someones plugin, anyway to simplify this?
https://hastebin.com/apeboyojef.properties
Someone mentioned guard clauses, but, these if statements are building on each other and not returning values based on anything else until the very end
So I'm not quite sure how to implement guard clauses in this situation
Jesus christ
In .yml comments #
# Config
# When a player has no permission show this message.
nopermissionmessage: |-
&4&lALERT!
&c&lYou do not have permission to send
gotten that twice in 5 minutes.. so funny..
then why dont you change it?
lmao
theres a reason why we send that
Because I was looking for recommendations. As said, someone mentioned guard clauses, which I'm interested in implementing. However I'm asking how, due to the if statements building on each other and not return one after another.
But thanks for your input.
guard clauses are only ideal for use cases that are extremely common. In fact, they are like utility methods
you should not use them if you are only going to use them once for one particular thing
this.getConfig().options().copyDefaults();
saveDefaultConfig();
private String noperms = "";
for the private string noperms, how would I get it from the config
nopermissionmessage: |-
&4&lALERT!
&c&lYou do not have permission to send
as that defeats the purpose of creating the clause the first place
Is there a method to check if an inventory is open or not, or will I just have to make a variable?
@unreal quartz or @quaint mantle
it wouldnt be a string tho because its multi lined right?
//stuff
this.getConfig().options().copyDefaults();
saveDefaultConfig();
private String noperms = this.getConfig().getString("nopermissionmessage");
would this work if its multiple lines??
# Config
# When a player has no permission show this message.
nopermissionmessage: |-
&4&lALERT!
&c&lYou do not have permission to send
hello?
what would I use for a persistentdatatype if I want a boolean?
didnt work
when I do my /cmd
and I deopd myself
player.sendMessage(noperms);
so I should get this
hello?
anyone on?
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. Create a thread in case the help channel you are using is already in use!
?paste
send code
what are you trying to do?
why are you extending JavaPlugin in your Command class...?
send this to the player
# Config
# When a player has no permission show this message.
nopermissionmessage: |-
&4&lALERT!
&c&lYou do not have permission to send
because I need to ready the config
thats what the main class is for
I can't believe persistentdatatype doesnt contain boolean as native...
right Zoi?
classes, methods and the such should always be public
and void means no type
package com.nik.warcentercmd;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
System.out.println("War Center Commands by Nikplayz has Loaded!");
this.getConfig().options().copyDefaults();
saveDefaultConfig();
System.out.println("War Center Commands Config Locked and Loaded!");
//Commands
getCommand("discord").setExecutor(new DiscordCommand());
}
}
this is my main class
ok
also why is your DiscordCommand class extending JavaPlugin?
I already said that
whoops
public string noperms = this.getConfig().getString("nopermissionmessage");
yeah
I put it under the savedefault thing
what would I do then?
Messages.NO_PERMISSSION
?
if you used an enum you would only have to do that instead
I thought thats what you asked
@Getter
public class Messages implements ConfigFile {
@ConfigPath("responses")
private final String helloWorld = "Hello, world!";
@Override
public String getName() {
return "messages.yml";
}
}

I havent learned yet to do multiple configs
@quaint mantle I'm trying to use persistentdatacontainers instead of lore like you said to do yesterday, but I am failing to see how it is better because for my soulbound plugin it seems easier just to check if lore contains soulbound, especially sense their isn't a persistentdatatype of boolean where I can set a namespacekey soulbound = true...
Can't you just use and int and set it to 1 if it's true and 0 if it's false?
bytes
ew
both work
okie, ill try, if you insist its better.
I learned enums from my tutorial and how would I use my confing with that?
how would I do this tho
its a library i made
can I just figure out how to use the public string noperms = this.getConfig().getString("nopermissionmessage");
for
# Config
# When a player has no permission show this message.
nopermissionmessage: |-
&4&lALERT!
&c&lYou do not have permission to send
dont use .
under getstring?
message:
nopermissionmessage: |-
Something
then config.getString("message.nopermissionmessage")
that fixed string
so just use an instance of your main class
.
?learnjava before trying to make plugins
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.
my intelij is saying 1 and 0 are ints not bytes ๐ฆ
Pls this is one thing I want to do for my test server
byte is 1-16 right?
pretty sure you have to cast to byte
public byte toByte(boolean b) {
return (byte) (b ? 1 : 0);
}
@median anvil
what should I do
okie i just used (byte) 0
fair enough
Illegal modifier for parameter noperms; only final is permitted
on public String noperms = this.getConfig().getString("message.nopermissionmessage");
are you putting that inside of a method
Bruh
Oh
@quaint mantle persistentdata is amazing thank you so much. ๐ฅฒ
idk why I never knew about nbt...
anyone familiar with ternary operators
getting variable expected error on mine
this.message = config.contains(path) ? config.getString(path) : this.message = "";
[20:36:47 ERROR]: Cannot load configuration from stream
org.bukkit.configuration.InvalidConfigurationException: while scanning an anchor
in 'string', line 5, column 5:
- &4&lALERT!
^
expected alphabetic or numeric character, but found &(38)
in 'string', line 5, column 7:
- &4&lALERT!
^
i did
nopermissionmessage:
- &4&lALERT!
- &c&lYou do not have permission to send
then
public class DiscordCommand extends JavaPlugin implements CommandExecutor {
//DiscordCommand
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
//Methods
if (cmd.getName().equals("discord")) {
if (player.hasPermission("warcentercmd.discord")) {
for (String line : getConfig().getStringList("nopermissionmessage")) {
player.sendMessage(line);
}
} else {
for (String line : getConfig().getStringList("nopermissionmessage")) {
player.sendMessage(line);
}
}
}
return false;
}
}
surround it in apostrophes or quotations?
ok
instead of this.message = "", it's just ""
no errors, when I do /discord, I get nothing
# Config
# When a player has no permission show this message.
nopermissionmessage:
- "&4&lALERT!"
- "&c&lYou do not have permission to send"
you register the command in your onEnable? id switch .equals to .equalsIgnoreCase
package com.nik.warcentercmd;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
System.out.println("War Center Commands by Nikplayz has Loaded!");
this.getConfig().options().copyDefaults();
saveDefaultConfig();
System.out.println("War Center Commands Config Locked and Loaded!");
//Methods
//Commands
getCommand("discord").setExecutor(new DiscordCommand());
}
}
thats my main class
and its also in your plugin.yml right
main: com.nik.warcentercmd.Main
name: WarCenterCMD
version: 1.0
author: Nikplayz
commands:
discord:
yep
is your configuration actually populated on the test server
?
# Config
# When a player has no permission show this message.
nopermissionmessage:
- "&4&lALERT!"
- "&c&lYou do not have permission to send"
thats whats there
hmm
Add print statements, try to debug where the code is failing.
also
[20:40:37 ERROR]: Error occurred while enabling WarCenterCMD v1.0 (Is it up to date?)
java.lang.IllegalArgumentException: Plugin already initialized!
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:183) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
this is in console
a public statement?
public String noperms {
for (String line : getConfig().getStringList("nopermissionmessage")) {
}
that errors
what should I do
how?
ooh
it goes above on enable??
I do this then
public OtherClass other;
public void onEnable() {
other = new OtherClass(this);
}
@hasty prawn ok now I have this
package com.nik.warcentercmd;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public NoPerms noperms;
@Override
public void onEnable() {
System.out.println("War Center Commands by Nikplayz has Loaded!");
this.getConfig().options().copyDefaults();
saveDefaultConfig();
System.out.println("War Center Commands Config Locked and Loaded!");
//Methods
noperms = new NoPerms();
//Commands
getCommand("discord").setExecutor(new DiscordCommand());
}
}
and a newly created class
is this all on intell or eclipse?
eclipse
ohk
and what is this code about?
to do /discord
You can pass this into the constructor for the NoPerms class now, and then use that instance to get the Configuration.
and a multilined message that is configurable gets sent to the player
oooooo
Wait, what is NoPerms...?
just using the thing
if you dont have perms
for the cmd
or there will be one more that you will have perms
can we set perms from luckperms?
ok
wait
just forget about no perms, how would I just have it if the player has perms a multilined message gets sent to them
I already have the command
You should probably just go with Method 2 from that link Nikplayz, it's generally the best way. (I know all the people in the thread say 3 is the best, it isn't.)
hey nik if you dont mind can you send me the jar file of the /discord command? plzzz
sure
can you dm methe file
?
package com.nik.warcentercmd;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class DiscordCommand implements CommandExecutor {
//DiscordCommand
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
//Methods
if (cmd.getName().equals("discord")) {
if (player.hasPermission("warcentercmd.discord")) {
} else {
}
}
return false;
}
}
how would I use method 2 on this
In your main class you need to create a private static final Main instance variable, and then onEnable(), set that to this. Then have a public static getter.
Then you can use that getter to access your plugin instance from another class, such as the DiscordCommand one.
package com.nik.warcentercmd;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
private static Main instance;
@Override
public void onEnable() {
System.out.println("War Center Commands by Nikplayz has Loaded!");
this.getConfig().options().copyDefaults();
saveDefaultConfig();
System.out.println("War Center Commands Config Locked and Loaded!");
//Methods
//Commands
getCommand("discord").setExecutor(new DiscordCommand());
instance = this;
}
public static Main getInstance() {
return instance;
}
}
I have this now
Im guesing I can now use Main()
instance = this; should be the first line in the onEnable
You can use Main.getInstance()
?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.
Recommend reading these too 
I will
but rn I just wanna finish this one cmd
Dessie
in main, where do I get the config just for the message
hello guys
Im trying to make Particle trails
and i want to store the Particle in my database
anyone can help me plz?
You're trying to store what?
the Particle of player
because if i do restart or reload
the Particle of this player will be remove
What do you mean by "The particle of player"
What particle effect they have enabled/equipped?
Coded a complete Particle GUI! Customize it how you please. There are a few different ways to spawn particles. One way is using packets the other is shown in this video! If you need help feel free to join the discord :D
Patreon:
https://www.patreon.com/codedred
Donate to me :)
https://www.paypal.me/CGMax
Join my discord:
https://discord.gg/z...
i don't have experience with database
so
but im trying to learn it
anyone can help me?
The fact that you're following a tutorial for a specific plugin isn't exactly encouraging
But if you're looking to learn about databases, then maybe start by looking up some sql tutorials
So, I've been trying to make Custom Enchantments (like the extra ones that are given with higher levels provided in an enchantment table), but haven't been able to find anything that can help. I'm pretty new to Minecraft Plugin Development (and Java as a whole), so I'd appreciate if you could redirect me to some resources I could use for this. Thank you!
So apparently the class doesn't exist but it does so I'm a bit confused here is where the class is being called```java
@Inject(method = "startGame", at = @At("RETURN"))
public void startGame(CallbackInfo callbackInfo) {
CowRunner.getInstance().init();
}
If you're new I cannot recommend making your own enchantment system
and if you really want the error here ```java
java.lang.NoClassDefFoundError: me/toy/runnitback/CowRunner
at net.minecraft.client.Minecraft.handler$startGame$zza000(Minecraft.java:3354)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:561)
at net.minecraft.client.Minecraft.run(Minecraft.java:362)
at net.minecraft.client.main.Main.main(Main.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)
Use a preexisting plugin and add your enchantments to it. I recommend EcoEnchants
Make sure class is in the jar
it is
I can understand that, but the reason I want to do it is to learn (even though I should probably focus more on other things). I'd like to have the know-how to create my own Enchantments Plugin, on the event that I need it in the future.
Custom enchants are complex and a bad starting point
I figured that was the case, but it's still something I want to do.
I have a feeling my project is just broken
Maybe
ima try to call another class
So what are you working with? Forge or Fabric
Mixins should be avoided when possible
How come
They can break compatability with other mods
Ah
MCP should be avoided
Aight
So I tested it with another class and same error
Yeah you would have to send the project or jar
ok
give me a sec to put it on github
Do you mind letting me know what your github name is?
Linked to my acc
Click on it to see
I sent you something
Yeah now what class is causing the issue
I have a question
Do "marker" blocks cause lag?
like 100000 Armour stands will cause lag
what about markers
So Mixins appears to be detecting your Client class as a mixin class
So it refuses to mixin it
Change the package to the folder where you want mixins in the mixins json
Also please follow naming conventions .-.
shhh
confused on this
can someone help? i deleted the folder with the config files and now i'm getting this error in startup:
[08:39:28 ERROR]: Error occurred while enabling Gamerules v1.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.set(String, Object)" because the return value of "ConfigManager.getMaterialsConfig()" is null
at ConfigManager.<init>(ConfigManager.java:35) ~[Gamerules.jar:?]
at Main.loadConfigManager(Main.java:20) ~[Gamerules.jar:?]
at Main.onEnable(Main.java:14) ~[Gamerules.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-224]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-224]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-224]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:535) ~[patched_1.17.1.jar:git-Paper-224]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:449) ~[patched_1.17.1.jar:git-Paper-224]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:654) ~[patched_1.17.1.jar:git-Paper-224]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:306) ~[patched_1.17.1.jar:git-Paper-224]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1141) ~[patched_1.17.1.jar:git-Paper-224]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[patched_1.17.1.jar:git-Paper-224]```
the code: https://paste.md-5.net/juyimufeye.cpp
it makes the materials.config file and sends the message that it created it, but it then sends this error and doesn't create the preset file
Have you considered: reading the exception
it says it's null
And also dear god are you using the default package
i already know that, i just don't know how to fix it
yep
i was told the com.whatever is unnessecary
I am appalled
It's not unnecessary
It's how you avoid namespace collision and it's how you know what is providing what
Use a goddamn package
alr sheesh
And if something is null
Trace it back to its source
Look at where ConfigManager.getMaterialsConfig() gets its return value
the package is right though?
And try to figure out why it is null
what config fike?
In your mixins json point it to the package only containing mixins
Instead of root package
?paste
didn't i send a message here
You should paste the error and send that link
it's a 10 line error wdym
I meant what I said
are you mad because you failed to steal my plugin
?
you are aren't ya
You have to stop being so paranoid and accuse everyone all the time.
probably never gets created again
the guys a schizophrenic
bro you literally asked for my whole plugin when the problem was in one class
the error was about that one class
do u know what github is
do you know what being nice is
its a place where people get their code stolen VOLUNATARILY
Yes but itโs generally harder to figure out errors if weโre not given the entire picture
shut up
i'm gonna take a guess and say you don't
has your code ever worked
that was the entire picture and more
yes lmao
why would i want to u use it if its so full of simple to fix bugs
why would i want to use it if its so full of simple to fix bugs
i didn't say you do, i said conclure does
4 lines of code?

i gave you two classes
Yes but you updated them, refactored something
do u kno how 2 fix
i edited 1 line of code each time, you can just imagine what i did since you told me what to do
not really. it should work. has this error yesterday too. createNewFile just didnt do a thing. try to work around
Anyways please behave appropriately, it is not nice to simply go around and accuse people here and there. For the record youโre being really ungrateful, wouldnโt be too bad with some appreciation.
im the one being not nice l m a o
probably j16 changed smth
dis is new code: https://paste.md-5.net/hubuqubixi.cpp
dis is new error: https://paste.md-5.net/wocuyizero.cs
try to use the Files class to create it
what are you even trying to make
gamerules gui plugin
does your datafolder exist? @lean gull
the one you are creating in your first constr. line
idk what u mean
if it's the folder that has all the config files then yes i have it
btw if i delete the folder then start it creates the materials.yml file with an error, then if i stop and start it creates the preset.yml file with an error, then if i stop and start it doesn't send an error and saves and loads the files
but it still doesn't set anything inside the folders
send the error
which
the ones coming up
the one i get after deleting the folder and then starting the server: https://paste.md-5.net/ijireborix.cs
the one i get after stopping the server after that ^ and then starting it again: https://paste.md-5.net/izipekuyiy.cs
ok well now your FileConfigurations are null. that would also explain why its not loading anything
wat dat mean
What do i have to insert in the line: 19 / 27 / 34
https://paste.md-5.net/ogugawetit.makefile
you use variables which has not been instatiated at that time
materials and preset is null until your last 2 lines
but you use it before
these?
materials = YamlConfiguration.loadConfiguration(materialsFile);
preset = YamlConfiguration.loadConfiguration(presetFile);```
yeah
ok, where do i put them
they're null until the end of the constructor but you are using them already before
right after your file instantiations
huh?
presetFile = new File...
preset = YamlConfg..
if(!presetFile.exist)
and also dont forget to save the config back to the file
otherwise your changes made will just be local
in an object thrown right away
am confusion
you refer your variables materials and preset at the end of the constructor to the respective FileConfiguration. until they're refered, they're null. you are using them before refering them. so you literally use null. you have to instantiate it before you use it to set your config values. that will fix the incoming NPE.
next step: saving the config back to the file.
currently you set the values into the config but not the config back to the file. so you change the variables local but never persist them.
seems like #help-server
if not: replace it since those are placeholders
error after deleting folder:
https://paste.md-5.net/afivovoyel.bash
it doesn't create materials.yml anymore
send your updated code
i didn't change anything in the code
^^^
yeah well so no wonder then
^^
so do your changes
i did however move the stuff you told me to before if(!materialsFile.exists())
Hey quick question: I'm trying to connect my plugin to a database and I'm following this tutorial: https://www.spigotmc.org/wiki/connecting-to-databases-mysql/
It says in one part that you should call the following method in your onEnable() method of the Main class and the returned data source should be cached in a private DataSource dataSource field. :
private DataSource initMySQLDataSource() throws SQLException {
MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();
File file = new File("my File Path");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
dataSource.setServerName(yamlConfiguration.getString("host"));
dataSource.setPortNumber(yamlConfiguration.getInt("port"));
dataSource.setDatabaseName(yamlConfiguration.getString("database"));
dataSource.setUser(yamlConfiguration.getString("user"));
dataSource.setPassword(yamlConfiguration.getString("password"));
testDataSource(dataSource);
return dataSource;```
However, I cannot call this method in my OnEnable method. My guess now would be that it doesn't work because my methods are private. That's why I'm confused, because in the tutorial private methods were also used. can anyone help me there?
Then I wanted to ask what exactly is meant by caching the returned DataSource in a `private DataSource dataSource` field. Does it mean that I should store it in a variable?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
can you check if there is an item/items with a specific pdc/nbt in players inventory and grab that item/items
making rainbow armor and want to be able to stop the task if player no longer has armor with rainbow nbt.
please pm or reply your answers cause I'm going to sleep now. thank you!
I just run a timer to check wether or not a player has a specific piece of armor in a specific slot. Basically I apply invis to the player every 4 seconds in case they have that armor on
hey I need to store custom nbt tags for itemstacks
so i used the PersistentData to store custom values!
PersistentDataContainer data = itemMeta.getPersistentDataContainer();
data.set(new NamespacedKey(this,"CustomModelData"), PersistentDataType.BYTE, (byte)1);
item.setMeta(itemMeta);
i used this code to set a custom nbt named "CustomModelData"! and it showed like this
Itemstack data
tag:{PublicBukkitValues:{"PLUGIN_NAME:custommodeldata":1b}}
but i need like this
Itemstack data
tag:{CustomModelData:1b}
ItemMeta#setCustomModelData?
ohh ok
thank you it worked
and what if i need to set some tags like something:1b
NMS
and there is no other ways to do that ?
but when using pdc i get like this
it shows like this when using the pdc for itemstack
tags:{ PublicBukkitValues:{"OUR_PLUGIN_NAME_HERE:something":1b} }
but i need like this
tags:{ something:1b }
are the player's datacontainer's entries the same on all worlds?
Channels a mess like always?
We have threads enabled, use them ๐
is it possible to create bossbar with a custom hex color?
i have like no fricking way how those threads work
See this button?
Click it then click "new"
why tf does this channel still exist then?
helps keep threads in one place, also because people don't even use threads lol
yeah because threads feel like whatsapp groups where you put in 20 people, and no one will ever answer you
you get that anyways because the channels a mess as soon as more than one person asks for help lol
so... for everything we should use threads now?
If you need to ask a question that's going to take a while to answer, yes. Whether or not threads will be enabled for the entire server, who knows
that was a simple yes/no question
lol
and that doesn't have to be a thread lol
then why do you tell me to
Just a general thing so they get used ๐คฃ
i see
People were like "Gib threads" now we have them and they don't get used ๐
i thought you were like hey, OpEn A TiCkEt FoR ThIs YeS/No QuEsTiOn
because people dont know they even exist
discord never informed me
idk if thats a me thing
If it's a yes/no question a thread's useless lol
at max it's two messages ๐คฃ
if it's like bug fixes or something, then a thread is more appropriate ๐
makes more sense
Yee
btw
if people really use them in future
enjoy deleting those threads
or no one will ever be able to answer them
Why's that?
like
now it has just 1 thread... thats nothing
but imagine there would be like 50
they get saved for 3 days
well, we'll figure something out lol
aka, you never thought of that? xd
more along the lines of I'd be surprised if that'll ever happen ๐
if what happens? 50 threads existing? lol
people actually using threads enough for it become an issue ๐
how many questions does this channel get a day?
hard to tell tbh
that can get a huge pain
create a thread for chatting about the thread lol
without some auto-remove
so basically what you get anyways when more than one person needs help anyways? ๐คฃ
can't disagree tbh
especially if they don't know that
?paste
exists
ofc not because it's true.
In this case no solution fixes the issue permanently, but threads at least make it a little better ๐
threads kinda just clears the chat more
questions won't get proper answered if they're not high-prio in the list
bc no one scrolls that damn list up lol
i think it says in chat if a thread was created? Could be wrong
can i delete my created threads?
๐คทโโ๏ธ
let's hope
does
that's fair
but can't delete it tho... that would help at least a bit if people could remove their own threads if their question got answered
Deletion would mean people can't look through the threads to see if their question got answered already though ๐
just like the forum
do people do that?
some blank it out lol
iirc blanking out a thread is against the rules too
the answer to the pdc would be yes btw xD idk if anyone answered
no no one did
thanks :)
they kinda just started yelling about those threads xd
optic, i feel like you have a good wallpaper for me?
i need one
I don't actually
sad
the wallpaper i have is of a vtuber though ๐คฃ
mine is just.... well
mine lol
:3
send me that lol
why not
fuck i don't have the original image ๐
I don't know where the file is stored then ๐คฃ
ty
in the comments there's 1080, 1440, and 4k ones
lol
https://twitter.com/ninomaeinanis/status/1395548337600827397 here's a link directly to the images then @sullen dome ๐
also, it's no longer dev related so #general would be better lol
why do i feel like i know what that "disclaimer" says
actually, it's a nice disclaimer.
basically a thank you and stating it's personal and non-commercial use only
What is org.bukkit.block.data.BlockData handling?
Hey quick question: I'm trying to connect my plugin to a database and I'm following this tutorial: https://www.spigotmc.org/wiki/connecting-to-databases-mysql/
It says in one part that you should call the following method in your onEnable() method of the Main class and the returned data source should be cached in a private DataSource dataSource field. :
private DataSource initMySQLDataSource() throws SQLException {
MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();
File file = new File("my File Path");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
dataSource.setServerName(yamlConfiguration.getString("host"));
dataSource.setPortNumber(yamlConfiguration.getInt("port"));
dataSource.setDatabaseName(yamlConfiguration.getString("database"));
dataSource.setUser(yamlConfiguration.getString("user"));
dataSource.setPassword(yamlConfiguration.getString("password"));
testDataSource(dataSource);
return dataSource;```
However, I cannot call this method in my OnEnable method. My guess now would be that it doesn't work because my methods are private. That's why I'm confused, because in the tutorial private methods were also used. can anyone help me there?
Then I wanted to ask what exactly is meant by caching the returned DataSource in a `private DataSource dataSource` field. Does it mean that I should store it in a variable?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yes the forge docs
And sources of other mods
Also just reading mojmapped code will get you far enough
Hiya, I'm working with PacketPlayOutWorldParticles in version 1.8.8/1.8.9 and it seems to me that instead of Red Green Blue the colour variables are Red Yellow Purple. Any ideas?
No
It encourages the use of IntelliJ lol
Thatโs bullshit
Itโs almost safe to say it support IntelliJ just as good if not better
It should be something like, Forge initially aimed to support Eclipse IDE, however the support for IntelliJ is a working pleasure. Or something
.
how can it only support eclipse if ive used it in notepad
Create a thread
how would i make a command that opens a book where people can write in? and then get the thing they wrote as a variable?
is there an API i can use??
its clientside afaik
so you would have to go with packets
How to re-code/Upgrade an 1.13 to 1.17 Plugin
well well well. no. dont do something someone else already did and specialised on. i mean if its bad, yeah, dont use it. but if its not, you are just doubling your work and probably make it even worse than the api author did
well. so recode the java api
api is api
we can also not exaggerate and you can start redoing spigot
if you are doing it in a team you wont learn everything
what i am saying is: dont redo something yourself someone else already did better
a fucking ton of C
its literally not
you should not redo something someone else already did. that leads to nothing and is very time consuming. if you want to learn it, you can ** try** to redo that or look at the implementation of the already done work.
why do you want to reinvent the wheel
okay. here a better one: if you want to make a shop plugin, would you create your own economy system, or use the already optimized vault one EVERYONE is using so your plugin is compatible with nearly every server?
i mean you could gain some experience by making your custom economy system. but what does it bring you
nothing than extra work
So i want to store the user or uuid of player who placed down chest ( I am a beginner to this )
BlockPlaceEvent#getPlayer
Hi, I have question about posting my first plugin.
I made plugin called OpAll and it is made for situation when someone beg for free premium plugin in chat. You will send him this plugin and when someone join the server and the plugin is on, the person will get op.
With this plugin my goal is to force people to follow spigot rules.
Last message : Can I post this plugin on the Spigot, because I dont want to break rules and get banned.
thats malware. so no, its not
Ok, I will respect it.
At least if the user doesn't know what the plugin actually does, right?
not sure about forceop which is clearly stated.
Itโs a malicious concept
@vagrant stratus
I mean, it doesn't really make sense but if you want a plugin that gives everyone OP and you as a user of the plugin clearly know what it does, why would it be malware then?
btw sorry for my English
i mean if the plugin is designed to punish others with forceop, its not allowed
Yea, in this case it is.
otherwise you could state it as a permission plugin
does anyone know how i might go about using custom player heads
I can already tell if this is the intention of your plugin itโs not going to be allowed.
Yeah SkullMeta and ensure the material of the ItemStack is a player head
ok thanks
I dont know, what do you mean by that, but this is it (just this)
Yes the problem isnโt the plugin itself as we concluded, itโs your intentions with it
My intentions are to punish people, who doesn't want to pay for premium plugins
Exactly
how do i get custom item tags off an item
Store the location and use a runnable to place fire
What other way did you expect?
does anyone know how to map a bukkit material to an item
Wdym?
EnumMap<Material, ItemStack>?
i used some reflection and called the NMS Items.registerItem(MinecraftKey a, Item b) method to inject an item
and some more reflection to add to $VALUES of enum org.bukkit.Material
and even more reflection to set the new material's key to the correct NamespacedKey to match the vanilla item of the material
but when i try to give the material to the player, it doesnt give anything
and when i try to getType of the new item injected in NMS, it returns AIR
so im wondering how to map the material to the item
You really shouldn't be doing that
Find a better way to handle your custom items
What you want requires you change the Spigot source directly with a patch
They had Mixins ๐
What the
Someone made a wrapper that launches the paper jar with mixins
i also tried looking into magma but its currently bugged and wont allow vanilla clients
Ah so not official
Why do you need to add a new item
@EventHandler
public void onDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
if (!player.getWorld().getName().equals("world") && player.getGameMode() != GameMode.CREATIVE) {
event.setCancelled(true);
}
}
@EventHandler
public void onMoveItem(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (!player.getWorld().getName().equals("world") && player.getGameMode() != GameMode.CREATIVE) {
event.setCancelled(true);
}
}
why is this not working...? I have other listeners in this class that are working fine
porting a plugin and also making a server
also its not limited to items, also blocks, oregen, etc (i havent tried those yet i just wanna get items working)
You want mods then
^
i want to allow vanilla clients though
You canโt then
and allow them to play by using protocollib to modify packets
You have to use a resourcepack then
Fabric?
Pretty sure you can
hold up
HWELP
check one block under the player
well it should work...
idk why you're so angry
then say that
Use a runnable?
use a runnable and the blockface
blockface
if(to.getBlock().getRelative(BlockFace.DOWN).getType() == material)
No. You will never have to "mess with nms shit" when calling API methods.
i still need help
?pdc
What version are you on?
1.17.1
Then the PersistentDataContainer you can get from the ItemMeta is your best choice.
Ive linked a guide above
wat dis ItemStack itemStack = ...;
what would be the best way to disable a command if a player is holding a specific item? Checking the commandpreprocess event and cancalling?
makes an itemstack
basically a minecraft item
ok
?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.
This means "Get your ItemStack from somewhere"
like ItemStack item = event.getItem()
so i can do whatever i want with it?
what-
Yes. Its not valid java code. Its just a note from the author to tell you "Get an ItemStack from somewhere"
i can make whatever itemstack i wnat here, right?
ok
No. Only pink wool. And it has to be named "Im Orange"
-_-
^^
just flame the post author ๐
Agree. I would PM him and flame him to learn java.

plugin instance is red, how do i get the plugin instance
๐ฅบ
What is a title entity?
the entity provider of a certain block/ entity?
Ah. No. Well... Let me think.
idk
Maybe. But it would be hacky af.
Play around with the piston events and check if they are fired even if the block doesnt extend.
If not you will have to look at the redstone events.
Or asm
player.kickPlayer...
[05:10:15 INFO]: tvhee lost connection: The game is finished, goodbye!
[05:10:15 INFO]: tvhee left the game
BUT instead I get this (Translated: "The external host disconnected")
Hey I was wondering how you can place down a chest and everyone can open it but its like an enderchest so everyone has their own inventory in there? :)
dutch
๐ฅฐ
Yep
are you dutch?
Yes ofcourse
oh me too
Nice that is why you knew that
it has error
help pls
Modifer 'private' not allowed here
where
on private
Then you are in a method
you can only use it on class level
Remove it, it is already private
k thx
Because it's YOUR method ๐
its mine
Also I get java.lang.NoClassDefFoundError at random moments in onDisable from my external (self-written) library
Looks like classes already started unloading or smth?
Even other classes in THE SAME package have no problems, it's always random
is checking if a player is null after getting it by Bukkit.getPlayer(args)
the same as checking if the online players does not contains the player?
why is that so difficult
If I try to kick everyone in onDisable, nobody gets kicked. (basic for loop). Even trying like this will still kick nobody
while(Bukkit.getOnlinePlayers().isEmpty())
{
for(Player player : Bukkit.getOnlinePlayers())
player.kickPlayer(new Component("&aThe game is finished, goodbye!").toLegacyText());
}
The method gets called, I am sure
the while is totally redundant. it will loop one time. just replace it with an if statement.
also you probably want to negate your isEmpty statement. otherwise how would you kick the players if there are none. this new Component thing is redundant as well. just use a string.
dont spam
Ok that Component is my own class
Maybe toggle a boolean whenever you send that message and it itโs true, donโt run any commands
And if itโs*
block commands in command pre process event
?
do what elgar said
Learn bukkit - When something happens inside Bukkit, an Event is called so every plugin can decide what to do whenever something happens.An Event is called...
How can the ChatComponent API be used to display an itemstack on hover like the image below?
The api mentions it but does not go into detail on how to actually utilize it.
https://www.spigotmc.org/wiki/the-chat-component-api/
Several forum posts kind of show how to do it but they eventually devolve into "just use NMS" or convert the item to JSON and store it in an Item
Looked into the adventure API for hover stuff but their documentation on hover events is incomplete and apparently itemstack hovers are not implemented yet.
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, <<itemstack here>>));```
Suggestions?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
getCommand("plugins").setExecutor(new PluginsCommand());
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PluginsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)){ return true; }
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("plugins")){
player.sendMessage("NICE TRY!!");
}
return true;
}
}
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.superfalcon.supersmp.Main.getCommand(String)" is null
at me.superfalcon.supersmp.Main.onEnable(Main.java:13) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:293) ~[patched_1.16.5.jar:git-Purpur-1171]
at java.lang.Thread.run(Thread.java:831) [?:?]```
ohh sry
command is not in plugin.yml
wll it is
nope
main:me.superfalcon.supersmp.Main
version:1.0
author: superfalcon
commands:
heal:
description: doesnt allow players to use plugins
usage: /<command>
aliases: plugin
ohh wait
wtf
i copid it from another file lmaoo
sry
I'm never wrong, except for when I am ๐
๐คฃ
main:me.superfalcon.supersmp.Main
version:1.0
author: superfalcon
commands:
plugins:
description: doesnt allow players to use plugins
usage: /<command>
aliases: plugin
at me.superfalcon.supersmp.Main.onEnable(Main.java:13) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:293) ~[patched_1.16.5.jar:git-Purpur-1171]
at java.lang.Thread.run(Thread.java:831) [?:?]```
sadly
didnt fix
command is still not in plugin.yml
it is right?
I'm going to guess one of two things. You never actually updated the jar on your server correctly, or you tried to update it with the server running
didnt fix lol
tried 2 times even repackage
doesnt "/<command>" literally prints it out?
open the jar with 7zip and examine the plugin.yml that is inside the jar
ok
version: '1.0-SNAPSHOT'
main: me.superfalcon.supersmp.Main
api-version: 1.16
load: STARTUP
authors: [ superfalcon ]
description: supersmp.ml
website: superfalcon.tk
why isnt it there?
even with a fresh build
Does anyone have a system to remove certain entities in unloaded chunks?
since currently it needs a player to be in that area to run the code since it doesn't find any entities in that chunk
Uhm. I have an API that can execute methods for all chunks that are generated in the world.
But this implies a design issue. What are you trying to do?
hey guys, just wondering if there is a gradle command to run to build the dependencies for the spigot plugins or if i can just import the spigot 1.17.1 jar
Do you build with maven?
yup
Where is your plugin.yml located? In the resources folder?
I'm trying to remove certain entities on startup, I think I have made a solution 2s.
If the plugin reloades I can't access some of my classes (java.lang.NoClassDefFoundError). If the plugin shuts down (EXACTLY same piece of code) it works fine
The spigot api is a maven dependency. You can include that into your gradle pipeline.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thank you!
- Dont use/support reloads
- Full stack trace pls.
Ok wait a moment
It is premium, and I want to support reloads
Am I getting crazy or smth? It just dissappeared
You should handle those things when minecraft handles them. On ChunkUnload and WorldUnload
Make sure all your dependencies are either depend or softdepend.
Ok but the library is not a plugin, it comes with the plugin as compiled set of classes
And I can't depend my own library in my own library
That's what my work around was
I've now made it trigger on ChunkLoadEvent
Just need to stress test it and make sure it doesn't affect performance
hey y'all, stupid question here, but when using a # while giving snippets of code, what does that mean? never seen it before.
Class#method() <- Instance method
Class.method() <- Static method
ahh ok, thank you
is there a means of accessing files stored within default minecraft in plugins? like if i wanted to pull from a loot table, how would I go about that?
Spigot has a loot table API
You have a turing complete programming language at your disposal. You do whatever you want.
But i think you should use the Spigot API for the loot tables instead
so what is the relation between maven and gradle?
are they the same concept just two different implementations of dependency building?
Both are just dependency managers. You pretty much can do everything with both. Maven has a much bigger audience.
Oh hell no.
๐คจ
haha
??
I prefer maven
thx for that
i was just haha-ing the "oh hell no" to gradle benig faster
There was a time where i tried really hard getting into gradle. At this time gradle just crashed with java 16 for several months so
i stayed away from it ever since.
i mean the spigot example uses gradle
It literally didnt support an LTS java version
Almost all spigot examples are done with maven
Gradle is a bit of a niche
oh oof, can u send me a link to the maven build dependency tutorial then
i just built it with gradle
But play around with both. They are both viable options.
https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
then I go use anything that isn't spigot and its all gradle
BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
http.disconnect();
System.out.println(http.getResponseCode() + " " + http.getResponseMessage());
System.out.println(content.toString());
how do i get the json object now? so i can do stuff like .get
Lul. I only encounter maven outside of spigot to be honest. Especially in enterprise.
idk man everywhere I look its just gradle gradle gradle
Gson (:
Gradle is becoming more popular tho, just cuz of how much better
Pipe the String into Gson
like this?
Gson gson = new Gson();
String json = gson.toJson(content.toString());
Google says no
i love the dip in searches for both in january
What are you even doing? Accessing a rest endpoint?
hmm.. so my plugin.. at least in its most basic form will not necesarily need any commands... but it will interact with the console logger. any pointers to the appropriate classes would be cool
So mavens just losing percent and gradles not gaining. I love it :3
You can get the main logger of your Plugin from your JavaPlugin instance by just calling
this.getLogger() for example.
Ant comeback? ๐
can't wait for ant !!!
And I canโt forget that xml is just aids
I've been reading the Loot Table stuff on the JavaDoc and I can't really seem to understand how to implement a loot table.
The commands are mostly to modify and implement an already existing table, but I don't understand where they get the table from.
And def not considering it uses xml
okay looked for another example and idk what im doing, didnt expect https requests to be such pain in java
Example REST -> JsonObject via Gson
Gson gson = new GsonBuilder().create();
final URL url = new URL("https://reqbin.com/echo/get/json");
final HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestProperty("Accept", "application/json");
int responseCode = http.getResponseCode();
// Do some safety with responseCode
String jsonContent = http.getResponseMessage();
http.disconnect();
JsonObject jsonObject = gson.fromJson(jsonContent, JsonObject.class);
jsonContent contains the raw json String
lemme delete everything and try this...
which package is the logger in
Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive
System.out.println(jsonObject.get("data"));
hmm did i do anything wrong?
as in accessing the details from the main log that is output by the spigot jar... not creating my own logger
import java.util.logging.Logger;
public void onEnable() {
Logger logger = this.getLogger();
Your IUE should auto import stuff like that
Print out the content.
Its not a full JsonObject but only some JsonPrimitve like info: 10
tbh yeah it did. it auto generated this
java @Override public Logger getLogger() { return super.getLogger(); }
how do i change explosionPower of a firecharge that is launched from a dispenser ?
how do i access then data?
Its a String. You already have the response.
Just print it.
And then we'll see
so like in the "mixins"[] part I should just have MixinMinecraft
okay wait
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/ProjectileLaunchEvent.html
Check if shooter is a dispenser. Access the Entity. Check if its instanceof Fireball. Cast. Set explosion strength (yield).
declaration: package: org.bukkit.event.entity, class: ProjectileLaunchEvent
JsonObject jsonObject = gson.fromJson(jsonContent, JsonObject.class);
System.out.println("test");
System.out.println(jsonContent);
System.out.println(jsonObject);
} catch (Exception e) {
System.out.println(e.getMessage());
}
[14:56:43 INFO]: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive
will be back in 30mins got food, please ping me !
not even test "test" got printed
Can you pleas just print out the raw json String before throwing it into other methods? ...
-.-
First all plugin jars are loaded. Then the enabling is done by calling the onEnable() method of each.
After that a plugin is enabled.
hi there are their any way to add servers to bungeecord without restart
Yes
how to
There is a plugin
How can the ChatComponent API be used to display an itemstack on hover like the image below?
The api mentions it but does not go into detail on how to actually utilize it.
https://www.spigotmc.org/wiki/the-chat-component-api/
Several forum posts kind of show how to do it but they eventually devolve into "just use NMS" or convert the item to JSON and store it in an Item. Neither of these options are optimal.
Looked into the adventure API for hover stuff but their documentation on hover events is incomplete and apparently itemstack hovers are not implemented yet.
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, <<itemstack here hopefully>>));```
Suggestions?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
getProxy().constructServerInfo once you have done that you need to add it to getProxy().getServers().put
When I use ItemStack#getEnchantmentLevel to get a custom enchantment level it returns 0 (Which is not for sure) But if I do ItemStack#getEnchantments and print the enchantments in this map, My custom enchantment is there...
What is going on ๐ค
kk thx
[15:13:11 INFO]: OK
try {
String my_uuid = System.getenv("P_SERVER_UUID");
System.out.println(my_uuid);
Gson gson = new GsonBuilder().create();
final URL url = new URL("https://mc.thechemicalworkshop.com/api/client?filter[uuid]=" + my_uuid);
final HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestMethod("GET");
http.setRequestProperty("Accept", "Application/vnd.pterodactyl.v1+json");
http.setRequestProperty("Content-Type", "application/json");
http.setRequestProperty("Authorization", "Bearer REDACTED");
int responseCode = http.getResponseCode();
// Do some safety with responseCode
String jsonContent = http.getResponseMessage();
System.out.println(jsonContent);
http.disconnect();
i know the endpoint works, tested with curl
might reset toke just to doube check
-> System.out.println(jsonContent); What does that print?
it prints OK
Any idea?? Why does not ItemStack#getEnchantmentLevel work?
so at the top of my command, I have this private static Main instance; How would I get something from it? Main().teststring?
System.out.println("jsonContent");
System.out.println(jsonContent);
System.out.println("jsonContent");
[15:16:52 INFO]: jsonContent
[15:16:52 INFO]: OK
[15:16:52 INFO]: jsonContent
Ah wait. thats not the playload
trying my old script..
URL url = new URL("https://mc.thechemicalworkshop.com/api/client?filter[uuid]=" + my_uuid);
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestMethod("GET");
http.setRequestProperty("Accept", "Application/vnd.pterodactyl.v1+json");
http.setRequestProperty("Content-Type", "application/json");
http.setRequestProperty("Authorization", "Bearer REDACTED");
// only use user api, server api gives error, todo
BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
http.disconnect();
System.out.println(http.getResponseCode() + " " + http.getResponseMessage());
System.out.println(content.toString());
this old script works fine
[15:19:05 INFO]: {"object":"list","data":[{"object":"server","attributes":{"server_owner":true,"identifier":"f0c00026","internal_id":19,"uuid":"f0c00026-feaa-4cfb-999f-85a1a9ac82d3","name":"testing","node":"Las Node 3core 18gb","sftp_details":{"ip":"REDACTED","port":2022},"description":"descruidescru
this is the output, well part of it
i want to access data.description and data.internal_id
I even looked up in the source code of spigot and clearly both are almost using same method
public int getEnchantLevel(Enchantment ench) {
Validate.notNull(ench, "Enchantment cannot be null");
Integer level = this.hasEnchants() ? (Integer)this.enchantments.get(ench) : null;
return level == null ? 0 : level;
}
public Map<Enchantment, Integer> getEnchants() {
return this.hasEnchants() ? ImmutableMap.copyOf(this.enchantments) : ImmutableMap.of();
}
But my custom enchantment level is 0 when I use first one but it is not in second one ๐ญ
you dont need to close the input stream and disconnect the connection. one is enough. also closing/disconnecting should be done in the final clause.
int level = ItemStack.hasEnchantment(Enchant) ? ItemStack.getEnchantmentLevel(Enchant) : 0;
And if I'm not wrong I think getEnchantmentLevel returns 0 if the enchant isn't on the item.
So you might be able to do just
int level = ItemStack.getEnchantmentLevel(Enchant);
my final clause will be, delete the server this script is running on... oh well
anyways how do i access desctiption and id?
https://gyazo.com/33db663712017c179a75123e3461d288
ok so I got it to work, but I want it a multilined message, not this
I supposed it has too do so, But it returns 0 while the item has the level 5 on it.
But if I use ItemStack#getEnchants() and get the enchantment level from there it will return 5...
public class DiscordCommand implements CommandExecutor {
//DiscordCommand
private Main mainClass = Main.getInstance();
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
//Methods
final String discocmd = mainClass.getConfig().getString("discordmessage");
//-----------------------------------------------------------
if (cmd.getName().equals("discord")) {
if (player.hasPermission("warcentercmd.discord")) {
player.sendMessage(discocmd);
} else {
}
}
return false;
}
}
thats the Command
If you are running the latest version I recommend reporting it to spigot.
# Config
# When a player has no permission show this message.
nopermissionmessage:
- "&4&lALERT!"
- "&c&lYou do not have permission to send"
discordmessage:
- "Discord is"
- "stuff"
thats the config
How should I do that?
is it possible to boost a player flying with elytra like the firework rockets do ?
you could check if they jump
You can give a velocity to them ๐คท
thanks
player.sendMessage(String) sends a string not a string list.
You need to do
for(String s : List) {
player.sendMessage(s);
}
No clue lol I don't report anything
Its pseudo code copy in your code.
Neither did I, But this is getting annoying with my plugin
Spigot doesnt have such a method. There is a Spigot fork that does.
?
how do i set velocity ?
for(String s : getConfig().getStringList("discordmessage")) {
player.sendMessage(s);
}
If you add velocity to them while they are flying it will do same effect
oh
Show your whole code. Chances are high that you just dont have an enchantment on the ItemStack you are currently checking.
But calculating the exact velocity is a bit of a hustle
I did lots of checks, The item, the map it returns, the level it returns
anyone know why this isn't making the recipe and just gives me a normal crafting table?
MobleCraftingTable.java - https://paste.md-5.net/turanocovu.java
in main: MobileCraftingTable mobleCraftingTable = new MobileCraftingTable();
tysm that fixed my problem ๐
๐
Its a simple java syntax error. Paste the code.
I use this method https://git.agmdev.xyz/AGMEnchants/blob/master/src/main/java/me/ashenguard/agmenchants/enchants/CustomEnchant.java#L72
Which will end up here
https://git.agmdev.xyz/AGMEnchants/blob/master/src/main/java/me/ashenguard/agmenchants/managers/EnchantManager.java#L146 and it returns 0
But at the same time I used https://git.agmdev.xyz/AGMEnchants/blob/master/src/main/java/me/ashenguard/agmenchants/managers/EnchantManager.java#L132 and tried to get level from the map it returns which returned 5
Try adding or deleting brackets?
Just tested the code.
This returns Lvl: 5
final ItemStack itemStack = new ItemStack(Material.IRON_SWORD);
final ItemMeta meta = itemStack.getItemMeta();
meta.addEnchant(Enchantment.ARROW_DAMAGE, 5, true);
itemStack.setItemMeta(meta);
final int lvl = itemStack.containsEnchantment(Enchantment.ARROW_DAMAGE) ? itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) : 0;
System.out.println("Lvl: " + lvl);
It doesn't work with custom enchantments ๐ซ
Aaah. Thats something else.
No errors just returns 0
Oh no...
You cant declare methods inside other methods
This strongly suggests that you didnt take the time to learn at least the java basics before jumping into spigot development.
My enchants does implement enchantment class, And I followed the source and I don't get why it is not working...
What precisely?
how do i set a shaped recipe's ingredient to a custom item
i'm doing this but i'm supposed to input a material, not an itemstack:
sr.setIngredient('W', oakPlanksItem);
Use a new RecipeCoice.ExactChoice()
how do i used that
ShapedRecipe recipe = ...;
ItemStack itemStack = ...;
RecipeChoice exactIngredient = new ExactChoice(itemStack);
recipe.setIngredient('X', exactIngredient);
If you dont learn at least the basics then you wont be able to write any spigot plugins at all.
i did dis instead
sr.setIngredient('W', new RecipeChoice.ExactChoice(oakPlanksItem));
Its not. This is the cleanest way.
We had this discussion before.
this works
System.out.println(jsonObject.get("data"));
but how do i do multiple .get methods?
I see that you didnt follow my suggestion to watch the youtube speech of Robert C. Martin about clean code.
What do you mean by that?
i have list inside list and elements and stuff
https://pastebin.com/yE3aizAq
i want to access data.description and data.internal_id
data will always return 1 entry
Here are some examples:
JsonObject jsonObject = ...;
JsonObject subObject = jsonObject.get("data").getAsJsonObject();
JsonArray someArray = subObject.get("nameList").getAsJsonArray();
String someKey = subObject.get("coolKey").getAsString();
for (JsonElement element : someArray) {
int value = element.getAsInt();
}
So you will go:
mainJson -> JsonArray elements = get("data").getAsJsonArray()
unless it's faster
any connectors between my plugin and a database
