#help-development
1 messages · Page 228 of 1
sometimes the ide shows false positives, manually make sure that you avert all the edge cases
json was just the first thing that came to mind
huh- why would you do that
?
well
why would you broadcast a message no one will ever be able to see
Hmm
?pdc
I tried with object output stream but didn't work
onEnable happens when /reload happens right??
Also how would I save a hash map? I use a hashmap to keep track of variables etc and the plugin would lose its purpose if the server crashed/restarted
iirc you can also just do getLogger() in the main class
Ok, imma take a look
true
i think there's an onreload method but don't quote me on that
one sec
people still reload shit?
i do at least
i thought we left that in 2016
well you shouldn't
it's a bad practice
if you do, make a plugin command
like /myplugin reload
and handle your reload there as you wish
from what i know, /reload cold stops and starts all the plugins
thanks for your help btw!
go for it, its unnecessary effort cos most plugins wont do it
yeah, just the /reload is bad
a lot of plugins will break
I think the consensus is that /reload is fine for development purposes, but to never use it in production.
^
i dont think /reload is bad if youre willing to support it
i do use it in dev because i handled the edge cases sometimes
the reason its bad is because most plugins dont support it
well, since people should not reload, it's pointless to just support it
better off creating a plugin command to only reload itself
like the reload idea is good
but spigot can't read the plugin's mind
to know what will break and what won't
How can I save a hashmap when the server stops the plugin (Bascially when onDisable is called I want to save a hashmap, and then when onEnable is called I want to load a hashmap)
uh
?pdc or file storage
load it to a file
cheers
supprting /reload is a bad idea because its far too much effort to get perfect and it most likely wont be used at all since most plugins will break if you do /reload
yeah just make your own /plug reload
oh and also most likely you dont need to reload the entire plugin
I dont think that is what I am looking for
it kinda is, you can bind a pdc to a chunk i think
and then load it on start
files are cool but bad users might just delete them
but just wondering, why do you want to save a hashmap?
so it's dangerous
yeah but i think you should give that option to server owners
cos saving a hashmap seems kind of.. weird
if the dev aims to persist data between restarts why would you break it
My plugin uses a hashmap to store which users need to have a gui shown to them (It is a Freeze plugin), but if the server restarts than ofc the hashmap is wiped and it is pointless. Idk why I feel this is necessary but yeah? If it crashes that is just my worry
well if you aim to persist data between restarts
that data must be increasing somewhere
pdc
so youshould give the option to server owners to delete that data
yeah... it's not exactly how it works i don't think lmao
if the plugin needs that data why would you delete it
like
i see
oka
one option you have is to store that in the players pdc itself
imagine i'm developing a plugin and i need to save some data for the plugin to be launched properly the next time
and some owner deletes it because they have the option to
that would be kinda
uh
not cool
It isn't needed though
granted, that's a design flaw, but my point is the same
then of course do not use a file
i would say youre a bad developer
I guess it isn't the end of the world
chopkeys
If they lose it
then don't save it at all?
Yeah it was just a QoL thing at the end of the day
since it will allow the server owner to get rid of the plugin easier without having left over data
just use a file
ye
the pdc values are binded to plugins, so it won't interfere if the plugin is deleted, and i imagine that saving a couple itemstacks or whatever to pdc wouldn't hurt the storage too much
its binded to the plugin?
isnt it binded to players nbt file?
you can use NamespacedKey().minecraft() but it's a bad idea
well yeah and so does it for items
i mean that the address of the pdc is binded to the plugin
it will remain but it won't be used
but the nbt persists even if you remove the plugin
if the plugin is deleted
is it.. bad?
kind of
in what way
youre practically leaving trash behind
or..
easy to edit if you know what you are doing, easy to get rid of, no trash left behind
because if it were to be editable, there would be no need to save it separately from just saving player data
the easiest way i can think of (if you dont wanna mess w databases) is having a yaml file
bruh
mate, theyre making a fucking freeze plugin
i doubt they have any other data to store
how is this beef
yeah i'm stressed and sweating
ong
Yeah it is literally a persons UUID and then a Boolean
if you are british i won't talk to you anymore, but anyways, if this is a talk of saving player data, you can just save it in pdc and not worry ever. what the plugin can do to optimize it is delete the pdc data after it's been used, and then the only case when the data is left unused is when the plugin is deleted and somebody is frozen
see thats major beef
k
im heart broken
are you... bri'ish?
who knows
nah i agree with lol for plugins you distribute, use file storage, not pdc for the reasons they already stated
lord have mercy
if you are gonna store large amounts of data, sure
i dont really like pdc anyways
no its an opinion
the argument was, devs would leave behind data if a plugin was deleted. seems good enough for me
i mean, yeah, you are right, the data will be left behind, but why is it a problem if the amount of data is insignificant
the only way you can access it is if you hard view the nbt files, and if it's basically inaccessible, it's basically gone, no?
but if you install the plugin again, it can reuse the data, which is good
what if you deleted the plugin by mistake with some worthy data, and all of it was stored in files?
many people don't do that
many people do actually
i know a lot of server maintainers who never did backups until i advised them to
it's kinda fucked up
who the fuck deletes the plugin AND its folder from the server folder and the trash bin by accident
trash bin?????
idfk everyone calls it smth different
i thought literally everyone used ftp and a vds and not a local server to host a minecraft server
what
if you've found a way to manipulate the vds' trash bin with ftp and you find it reasonable, you've achieved a higher plane of existence
sdfgiefjgkl
anyways i dont think ive seen anyone accidentally delete the plugin folder
people are clumsy
ah yes
xd
"so my hand fell and i selected the plugin folder, went across the screen clicked the delete button, and then my mouse also went to the confirm button and pressed it"

haven't seen a confirm button in ages, but btw, a while ago i used an explorer that, when alphabetically sorting, would mix files and folders together, so it was really easy to just select them together lmao
most explorers and ftp clients now separate them
but it's kinda bad
that it was possible
at that point you probably shouldnt run a server
juss sayin
leave server running to people above 8
i mean, on the server i'm developing, all the plugins are private so i micromanage every piece of shit
have you been to r/admincraft? people do the wildest shit there
i wouldn't be surprised if somebody reported this some time ago
oh if youre not gonna publish it sure use pdc however you want
i use mysql for convenience, but i used to use pdc before, because it was easy to manage everything
plugin files can be broken in a matter of seconds, but i haven't really seen people going into playerdata and messing with it
anyway
guess it's up to chopkeys anyway
been looking for somebody to help with #1043942626472230923 for a while
the only time im fine w pdc is with custom items
o sorry
So if that actually was what you wanted we got an issue
major beef
Whats wrong with being british?
when was meta.addItemFlags added
new AttributeModifier(String name, double amount, Operation operation) is the name just anything i want
It already existed with 1.8
damn is there a way to hide enchantments in 1.5
I am setting a format with this line:
event.setFormat("§8[§4§lOWNER§8] §f%s: %s");
how can I allow them to use color codes in this? I tried to use:
event.setFormat(ChatColor.translateAlternateColorCodes('&', "§8[§4§lOWNER§8] §f%s: %s"))
but it did not seem to work. How do I allow color codes with & for this?
that is a seriously old version to use bukkit with
i got a piece of code for that
public String colorize(String msg) {
return ChatColor.translateAlternateColorCodes('&', msg);
}```
eaglecraft plugin
And quite random too
it works like this
uh ok ill try this do I just use colorize("§8[§4§lOWNER§8] §f%s: %s")?
dear lord
please stop with what you are doing immediately
but with the & signs
what's wrong with this
well that msg will contain & signs cus the 2nd %s is the msg
this should not help
its the same thing
You must set the message, not the format
what's the %s for anyway
;-;
Calling event.setFormat(ChatColor.translateAlternateColorCodes('&', "§8[§4§lOWNER§8] §f%s: %s")) is identically to calliung
String var10001 = ChatColor.translateAlternateColorCodes('&', "§8[§4§lOWNER§8] §f%s: %s");
event.setFormat(var10001);
which is identical to calling
String var10001 = "§8[§4§lOWNER§8] §f%s: %s";
event.setFormat(var10001);
which is identical to calling
event.setFormat("§8[§4§lOWNER§8] §f%s: %s");
String#format
ah
in a chat format, %s first time is the players name and %s second time is name
You seem to confuse .setFormat with .setMessage
damn i do my chat things completely differently and probably wrong ;- ;
Oh, so many people do things completely wrong in bukkit world
but, how do I allow ppl to use chat colors
because it does not work to use &c or anything wiht translatealternatecolorcodes or anything else ive tried
?jd sigh
this is probably more wrong than anything tho
So basically evt.setMessage(ChatColor.translateAlternateColorcodes('&', evt.getMessage()))
new AttributeModifier(String name, double amount, Operation operation) is the name just anything i want
how would i go about making custom blocks with directions?
like for directionless ones i can use noteblocks
but i dont think using noteblocks for ones that have a direction would be a good idea since therres only about 1000~ block states for noteblocks
if it works it works
and each block would require 6 states just to function
how might you save/load a location to/from a string?
like i can do the x, y, z components easily but for the constructor how do i have the world argument
I prefer UUIDs
well you get a double from a String x,y,z
yeah but what does that do
Try it out and find out. Probably will break everything instantly though as it is meant for semi-loaded locations
what even is a World?? is it for the different dimensions?
Yeah
any ideas?
Can't you make up new blockstates these days?
dont think so
yes
oh what?
16 instruments * 25 pitches = 400 states
i did a spinning sign once
https://paste.md-5.net/ulojuzotet.java
Method invocation 'getDataFolder' will produce 'NullPointerException' (I dont know why it's erroring)
Line 20.
- 2 activated or not
oh
yeah but thats not a new block state is it
youre overriding another block state
get the blockstate
change the blockstate

plugin IS null
it shouldn't even compile to be exact
you cant do that tho..
You never assign anything to plugin and that assignment is run before the constructor
it needs to be a valid block state form minecrafts existing ones
yeah it is needs to be existing block ofc
Protip: Use JavaPlugin#getProvidingPlugin
ye so im trying to find another block that has. abunch of blockstates that is not noteblock
Mushrooms, but those are limited too
cant i just like change the nbt of the placed noteblock to a custom instrument like idk "hello"
imma try-
But can't you define more blocks through datapacks or does the client need to be aware of that too (i.e. resource packs aren't enough?)
pdc?
If PDC is the concern, just use chunk pdc as long as it isn't absurd amounts of data you need to store
new AttributeModifier(String name, double amount, Operation operation) is the name just anything i want bc theres nothing in the javadoc
Most likely
getCustomModelData?
that is for itemstacks
1 sec lemme search
ItemMeta meta = item.getItemMeta();
meta.getCustomModelData();
ye
ItemMeta meta = ItemStack#getItemMeta();
meta.setCustomModelData(Integer);
ItemStack#setItemMeta(meta);
gosh why does java have to have weird ass blockstate rules
that is mc
no but bedrock can just say "lets add custom_block_model_5843" and it does
Ah java edition you mean
redstone wire has a lot of statess
but since its not a full block and its insta brak
cant use it
alr im just gonna make a script for it
Hi, how is called the thing thatis use by faction plugins to display the regions/areas corners? I try to look for them via Map view but its nothing to do with that i expect
Looks like that constructor doesn't exist
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
My guess is that your version doesn't have that one
What version of spigot are you depending on
Your parameters are one the one expected on the method
1.5.2
UUID.randomUUID().toString()
LOL
1.5.2 is dinosaur
i mean clearly it does
it shows up and everything
It doesn't
Also why legacy versions?
Not in 1.5.2
Does anyone know some decent (J8-style) javadoc page for legacy versions?
Spigot support only +1.16 up
and it works without the Equipment slot thing
I think he is using 1.15.2 but said 1.5.2
Does the attributeModifier class event exist in 1.5.2?
Oh he def. knows what to use
for me somehow it does
no i'm literally using 1.5.2
Strange, https://helpch.at/docs/1.5/ does not mention it (nor it's package) existing
Probably has something to do with 1.5 vs 1.5.2. Ugh
I mean spigot must ban 1.16 under because its really annoying to help them
so I can't use the Equipment slot thing
it's in this image
Yeah, the screenshot explains enough
(For reference eaglercraft is EoL though as fra s I know)
totally agree
Or rather said the repos were meant to be taken down
bruh I just discovered that the AttributeModifier is a thing but YOU CAN'T ACTULLY USE IT
most of them aint even solid blocks
i mean
i guess i could always go with the good old armor stand way
What exactly are you using anyways?
how do you do file io? i tried to read/write to a file but it's not finding it despite it being in the same directory
Are you sure that it is in the same dir?
wdym
i.e. did you do any typos or anything?
Like what artifact are you binding into?
it's in the plugin directory
aha, cb
What exactly are the two paths?
@EventHandler
public void onArmorEquip(ArmorEquipEvent e) {
Player p = e.getPlayer();
if (e.getOldArmorPiece().getItemMeta().equals(itemManager.ultimateHelmet().getItemMeta())) {
p.setMaxHealth(p.getMaxHealth()+5);
}
}```
like I have this code
<root server>/plugins/MninPlugin.jar and <root server>/plugins/mnin_data.json
nvm it just decided to work for some reason
nvm again it broke
goes without explaination that those are two different paths
yes because they are the plugin and the file it is trying to access
What is the READ path and what is the WRITE path?
Havent used spigot in a million years and my 1.8(i know please dont shout at me) import is not working and yes i have my repos imported:
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
they are both <root server>/plugins/mnin_data.json
ugh, it is nearly impossible to obtain any decent javadocs for legacy CB
then what is the exception?
why are you tryna find it anyway
is there anything else i could do instead of ```java
if (something) {
if (othersomething) {
}else {
}
}else{
}```?
FileNotFoundException arghghghg
based on the logs
Okay, funny
i eman if ur nesting if loops u can use if(!xyz) { }
I meant stacktrace when I said "exception"
which makes it easier to read
That also is bukkit, not CB
oh wait I found the class for the attribute thing
Unless there really is no "AtrributeModifier" class, which would mean that you have some random atrifact adding that class on the compile classpath even though you do not want to
[15:51:29 ERROR]: Error occurred while disabling MninPlugin v1.0 (Is it up to date?)
java.lang.NoClassDefFoundError: org/json/JSONObject
at mnin.DataSaver.saveData(DataSaver.java:29) ~[?:?]
at mnin.MninPlugin.onDisable(MninPlugin.java:25) ~[?:?]
``` i am in pain
No, not without doing something like if (cond1 && cond2) {} else if (cond1) {} else {}
check the paste thing
that is WAI, nothing you can do about that
what's WAI?
is this real? if(!x y z) { }
???? how do i fix it then?
i don't think I have a random artifact adding it but i in fact don't see the actual class even though it shows up
As I said, play the classloader - that is load all classes that you need in your onDisable block before running onDisable
but i am loading them
i'm importing them
Loading != importing
package mnin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.util.logging.Level;
import org.bukkit.command.*;
public class MninPlugin extends JavaPlugin {
CommandRunner runner = CommandRunner.getInstance();
DataSaver dataSaver = DataSaver.getInstance();
// Fired when plugin is first enabled
@Override
public void onEnable() {
try {
dataSaver.loadData();
} catch (FileNotFoundException e) {
getLogger().log(Level.WARNING, "Save data file not found (" + dataSaver.getSaveFilename() + ")");
}
}
// Fired when plugin is disabled
@Override
public void onDisable() {
try {
dataSaver.saveData();
} catch (IOException e) {
getLogger().log(Level.SEVERE, "Could not write to save data file");
}
}
// Fired on command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return runner.runCommand(sender, command, label, args);
}
}
Java will load classes as late as possible
But because spigot is spigot it will pseudo-close the classloader and thus refuse to load the classes when the plugin is disabled (which is the case when running onDisable)
It's really annoying behaviour, but unfortunately intended
(the classes being loaded/initialized late is very useful behaviour though)
package mnin;
import java.io.*;
import java.util.*;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.json.*;
final class DataSaver {
private static DataSaver instance = null;
private static final String filename = "mnin_data.json";
private JSONObject savedData;
private DataSaver() {
}
public String getSaveFilename() {return filename;}
public void loadData() throws FileNotFoundException {
File f = new File(filename);
Scanner sc = new Scanner(f);
ArrayList<String> lines = new ArrayList<>();
while (sc.hasNextLine())
lines.add(sc.nextLine());
sc.close();
String strData = String.join("\n", lines);
savedData = new JSONObject(strData);
}
public void saveData() throws IOException {
String strData = savedData.toString(4);
FileWriter f = new FileWriter(filename);
f.write(strData);
f.close();
}
public JSONObject getSavedData(Player player) {
return savedData.getJSONObject(player.getUniqueId().toString());
}
public void setSavedValue(Player player, SavedDataKey key, Object value) {
if (value instanceof Location) {
Location loc = (Location) value;
double[] locData = new double[] {
loc.getX(),
loc.getY(),
loc.getZ(),
loc.getPitch(),
loc.getYaw()
};
JSONArray arr = new JSONArray(locData);
getSavedData(player).put(key.toString(), arr);
} else {
getSavedData(player).put(key.toString(), value);
}
}
public boolean savedDataHas(Player player, SavedDataKey key) {
return getSavedData(player).has(key.toString());
}
// Snip
public static DataSaver getInstance() {
if (instance == null)
instance = new DataSaver();
return instance;
}
}
DataSaver.java (sorry for the text wall)
saveData is where the error occurs
because it can't find JSONObject
Is there a better method to use for broadcasting than broadcastMessage()?
Do JSONObject.class.toString(); in your onEnable() to fix it
Then do the same for any other class that will throw similar exceptions
It sounds stupid, but it works
will it still work if i put that inside DataSaver's constructor? (it's called when MninPlugin is initialized)
okay hold on, that class should be loaded when constructing that class
Did you shade that class?
?
Better in what sense? What’s missing from broadcastMessage?
And what other stacktraces do you see? NoClassDefFoundException is usually not alone
As in did you include that class in your jar. Or in layman's terms: Gib jar
yes
it's in src/mnin which is included since MninPlugin which is also in there is included
Yeah, I really want to see that jar now
what like the file?
I guess you accidentally jar-in-jar'd (JIJ) org.json:json as I doubt you included the org.json:json source code in your plugin's source code folder
the compiled plugin jar
i did
should i just extract that jar?
Really, give me the compiled jar, I can only do a guessing game without that jar
sent
(alternative give a screenshot of the project folder, but what is the fun in that - plus it wouldn't affirm nor deny my current suspicion of accidental JIJ-ing)
okay, thanks to you using eclipse I already know how the project folder looks like
nice
I hate to break it to you, but you got to decide: Maven or gradle?
(There is also Ant and other fringe build tools such as slbrachyura, but we shouldn't go that route, should we?)
i honestly don't know; i'm just using export > jar > select the stuff in my project to export lmao
Just that that does not work in your case
Unless you copy over the contents of org.json:json's source code to your source folder or the content's org.json:json's compiled .class files to your resource folder
which uhm, would be cursed AF
you know what, idc about cursed. i might just do that tbh
You'll thank yourself if you learn maven or gradle 🙂
maven >
For eclipse maven is better. Gradle's eclipse integration leaves much to be desired
(I know, technically it is an eclipse plugin providing gradle support, but whatever)
I'm surprised there are still people using Eclipse tbh
It's what I started off using but I quickly moved to IntelliJ
Does anyone know an alternative way to this function that is not working anymore?
entity.damage(1, player);
I wouldn't be able to make the switch - especially not nowadays as most of my stack would rely on IJ's eclipse project support
Anyway, either Maven or Gradle will make it much easier for you to build your software both now and in the future. I think Maven is probably a bit more well-known/supported, especially in the MC world. Afaik there's nothing you'd want to do that Maven can't do
it looks like that function still exists/works: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Damageable.html#damage(double,org.bukkit.entity.Entity)
Why do you think it doesn't?
yeah the cursed "solution" wasn't working; i'll switch to maven
it definitely does, you need to unzip the jar first though
I mean it doesn't work anymore!
What doesn't work about it?
Yeah it should still work
Are there errors in the console? Does it work on a server without any other plugins?
i tried but i couldn't figure out how to proceed so i reverted it
as for changing the project type to maven: what does that do for me?
Maven will take care of all of the steps needed to build your project, such as including any dependencies you bring in
Also, if you're interested in becoming more serious about writing software it's generally better to use tools like Maven rather than relying on your IDE to build your project
good idea
The Damage it showed was only because it was close only melee damage
There's a short tutorial here that looks like it covers the basics: https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
But, basically, Maven will expect your project to be structured in a certain way, e.g. your source code will bein src/main/java, other files that go in your .jar are in src/main/resources. When you run the maven command in your terminal Maven will read a file called pom.xml and compile your project which produces your .jar file
A basic pom.xml will look like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Your Java package</groupId>
<artifactId>Your Plugin Name</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Your Plugin Name</name>
<description></description>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
This tells Maven that you're using the Spigot API, so when you compile your code it can check that the function you're calling actually exist, you're calling them correctly, etc.
Do note that they also want to shade org.json:json
Now, for your JSON dependency you'd add it in the <dependencies> block. This tells Maven you're using that library. You can then tell Maven to include the code from the JSON dependency in your .jar, which will let Spigot load it when your plugin executes. This is called shading a jar, or producing a fat jar
Im sorry for asking probably stupid question here again... But Im kinda lost. Is there way how to you TextComponent.formLegacyText in BaseComponent[]? I tried this but is not working Im getting error.``` BaseComponent[] testBuild = new ComponentBuilder(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&eLOOOOL"))).create();
This is the Maven page for that JSON dependency: https://mvnrepository.com/artifact/org.json/json/20220924
Notice the XML block -- you copy that block into the dependencies block. That will let it compile. Then you have to tell Maven to create a shaded .jar
?jd
It looks like TextComponent.fromLegacyText returns a BaseComponent[], butComponentBuilderonly has a constructor for BaseComponent.
BaseComponent is basically an abstract class for all what you want
Could you use an empty string as the base and call this append method which accepts BaseComponent[] https://javadoc.io/doc/net.md-5/bungeecord-chat/latest/net/md_5/bungee/api/chat/ComponentBuilder.html#append-net.md_5.bungee.api.chat.BaseComponent:A-
why it isn't is beyond me
Oh lol, I may be stupid there
Although I'd still get rid of the whole new ComponentBuilder step and use .fromLegacyText from the get-go
I tried this and not getting error. Looks like, that works. Gona testit thanks.
I want to use BaseComponent bcs I want to have multiple messages on one line (some of them clickable). I know, I can makeit true TextComponent.addnext but someone told me here to use BaseComponent bcs its easier. Idk...
Im just new in java idk what is best option to use.
I am changing the player's swim speed using the code from this thread, and something strange is happening that I do not understand. https://www.spigotmc.org/threads/how-to-increase-player-swimming-speed.547842/ When the multiplier is set to something like 0.825, the player swims faster than normal. If I am multiplying a vector by a decimal, shouldn't it make the player slower? Does this have something to do with the normal movement speed being 0.2?
When the multiplier is below 0.2, the player swims slower than normal.
Is it because the normal walking speed is the multiplier?
And by changing the multiplier, I am changing that...
The multiply operation adds one first, then multiplies
So you should be adding a modifier that multiplies the value 0.825 - 1
Oh, sorry, you're using vectors, not attributes. That's what I get for not reading the thread you linked
@sterile token I'll let you know I'm recoding my entire menu system and all the concepts you're stealing from me are obsolete :)
LOL
Anyone know how to properly cancel InventoryClickEvent with ClickType SWAP_OFF_HAND?
If I cancel it the clicked item doesn't move but rather duplicates into the off hand slot
size()
💀
1.5.2 💀
tf
What's the type of getOnlinePlayers()?
so
Okay on an array it should be length
yeah but size() doesn't exist 💀
Which symbol could it not find?
it just takes me to the bukkit.getOnlinePlayers
I see no error there
Anyone know about this?
Are you sure it's actually duplicated? It might just be some desync between the client and server. Usually clicking on the item in your inventory will refresh your state and the item will be removed.
what's an alternative to
Bukkit.broadcastMessage```
since it's deprecated
hello everyone !
who helpe me please ?
Location loc = new Location(block.getWorld(), x1,y1,z);
if( block.getWorld().getNearbyEntities(loc,1,1,1,(entity -> entity.getType() == EntityType.ITEM_FRAME))){
block.breakNaturally();
System.out.println("Breack");
}else{
System.out.println("Erreur");
}
```
i go in get ITEM_FRAME for locality
ps: sorry i am french ^^
yeah I'm having a hard time tryna understand what you mean by this "i go in get ITEM_FRAME for locality"
?? It's not deprecated.
It is on Paper. Likely what they're using
Best to ask for support with Paper API in the Paper Discord
alr ok
I am trying to check if an item frame is placed to coordinate
whats the site to find spigot mappings to mojang mappings?
thank you
how can I make this available everywhere like I put this in the main class and it works in all of em
You can use static, I'd recommend moving it to a util class though
alr thanks
No problem
ik ik i'm just using it for this one thing
also bruh
[18:03:05 ERROR]: Error occurred while enabling ServerThings v0.1 (Is it up to date?)
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?]
at me.darklife12345.serverthings.ServerThings.onEnable(ServerThings.java:24) ~[ServerThings-0.1.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-279]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-279]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.reload(CraftServer.java:1025) ~[paper-1.19.2.jar:git-Paper-279]
at org.bukkit.Bukkit.reload(Bukkit.java:930) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:916) ~[paper-1.19.2.jar:git-Paper-279]
at org.bukkit.craftbukkit.v1_19_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.2.jar:git-Paper-279]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.2.jar:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:305) ~[?:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:289) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2294) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.2.jar:git-Paper-279]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.2.jar:git-Paper-279]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:185) ~[paper-1.19.2.jar:git-Paper-279]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.2.jar:git-Paper-279]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.2.jar:git-Paper-279]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1289) ~[paper-1.19.2.jar:git-Paper-279]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1177) ~[paper-1.19.2.jar:git-Paper-279]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-279]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
public void onEnable() {
//Config shit
this.getConfig().options().copyDefaults();
this.saveDefaultConfig();
//Command Shit
Objects.requireNonNull(this.getCommand("heal")).setExecutor(new Health(this));
Objects.requireNonNull(this.getCommand("feed")).setExecutor(new Health(this));
Objects.requireNonNull(this.getCommand("starve")).setExecutor(new Health(this));
Objects.requireNonNull(this.getCommand("suicide")).setExecutor(new Health(this));
Objects.requireNonNull(this.getCommand("multisummon")).setExecutor(new MS(this));
Objects.requireNonNull(this.getCommand("unenchant")).setExecutor(new UnEnchant(this));
Objects.requireNonNull(this.getCommand("online")).setExecutor(new Online(this));
//Event Shit
//Tab-completer Shit
}```
i have no idea what this means other than something is wrong with my onEnable thing
I'm going to assume you didn't register commands in your plugin.yml
Also, Objects.requireNonNull will still throw an error, if you don't want an error thrown you have to use an actual null check
they're registered
Can you send your plugin.yml?
#Health Commands
heal:
usage: /<command>
description: Heals you or another player
feed:
usage: /<command>
description: Feeds you or another player
starve:
usage: /<command>
description: Starves you or another player
suicide:
usage: /<command>
description: Kills you or another player
shit i'm stupid
Also did you use /reload?
I was thinking about the health commands
yes very much so
I am to lazy to restart a server
Just don't ever use it in production
alr
fps go brrr
yeah about that is this just paper
That will suppress any other null warnings though
bc i'm starting to think paper is doing some weird things
I would recommend moving your command registration to another method
Especially if you do this
like what?
// call this in onEnable()
private void registerCommands() {
// register commands here
}
Yeah
I'll edit it
you're
@SuppressWarnings("ConstantConditions")```
is being really annoying now
it's highlighting it
You didn't move the commands into the new method
ok that fixed it
Don't forgot to call registerCommands() in your onEnable()
If you're going to use code from YouTube make sure you understand it
i know it gets the config and the options and then saves it
can I do events the same way
You can do one of two things, both of which do different things
this.getConfig().options().copyDefaults();
this.saveConfig();
// OR
this.saveDefaultConfig();```
The former copies the default keys and values from the config.yml in your plugin, then re-saves the config with those default values in your plugin config directory. The latter basically copy/pastes the config.yml from your plugin into your plugin config directory if it doesn't exist yet
OR
this.getConfig().options();
this.saveDefaultConfig();
``` because it's what I used and i know
and it works
Yes, you can make a method called registerEvents
I usually do something like
List.of(/*events here*/).forEach(this::registerEvent);
The first line in your snippet does literally nothing. Nor does getConfig().options().saveDefaults() UNLESS you call saveConfig() after
You can just have saveDefaultConfig(); That's it. All you need
so I copied this and it made this
alr thanks
Make sure you know what it does first
Not necessarily. Consider this situation.
# This file is in your /plugins/MyPlugin/config.yml
FirstValue: 69
# This file is in your plugin's default config.yml file (the one you export with your plugin)
FirstValue: 69
SecondValue: 420```
Running `getConfig().options().copyDefaults()` and `saveConfig()` will copy `SecondValue: 420` into the config.yml in your server files, whereas running `saveDefaultConfig()` will not because the file already exists on disk
i don't which is which I skipped doing it
The values in the config.yml exported with your plugin are also defined as defaults
It's basically automatically doing addDefault() for you
alr now i'm confused to I keep the default thing or no
bruh I forgot verifying changed my name 💀
ye
Yeah I need to change my name at some point lol
alr masterofthefish
If you end up doing that, give me an @ and link me your Spigot profile, I'll update it on Discord. We have to do it manually
I will thank you
I'm gonna change it to darklife12345
Welllll do it after you've changed your forum name lol
You have to donate $10 I think it is
once I figure out how to do it
where exactly am I supposed to find this setting
@undone kernel
well damn
i guess i'm stuck with this name for now
I mean i didnt steal tho because if you explain me how it works they are not stealed at all
Wait you’re the 1.5 person from HelpChat
i am
also i've decided to stop with 1.5.2 i'm going back to 1.19
Nice
Hi I'm making a sword that shoots cobwebs and I wanna either delete or explode a cobweb after it's been placed. Is there a good way of doing this?
Here's what I'm currently doing
if (customItemId.equals("spider_sword")) {
World world = player.getWorld();
FallingBlock cobweb = (FallingBlock) world.spawnFallingBlock(player.getLocation().add(0, 1, 0), Material.COBWEB.createBlockData());
cobweb.setDropItem(false);
cobweb.setVelocity(player.getLocation().getDirection().multiply(0.8));
}
also what's the thing to use custom items in recipes
EntityChangeBlockEvent I think
Thanks!
I'm new to Java could you give me some advice on organizing my project?
I was trying to take a screenshot but it's not working for some reason
Must verify to send images
Seems fine
Should I make a separate class to for all entity related events?
honestly wouldent think thats a structure of someone new to java
like, thats better than most lol
You could have a class that handles all events related to the cobweb sword
Generally when it comes to listeners, I create classes based on what the event is going to be used for. Example I would have any listeners related to a certain aspect of the game in one class
oooof
Oops wrong channel
lol
Ok thanks!
alr so I have this sword code
public ItemStack ultimateSword() {
ItemStack ultimateSword = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta meta = ultimateSword.getItemMeta();
meta.setDisplayName("§4§kscary§1Ultimate Sword§4§kscary");
meta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
meta.addEnchant(Enchantment.KNOCKBACK, 10, true);
meta.addEnchant(Enchantment.FIRE_ASPECT, 10, true);
meta.addEnchant(Enchantment.DURABILITY, 10, true);
AttributeModifier dmg = new AttributeModifier(UUID.randomUUID(), "generic.attackDamage", 70.0, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, dmg);
ultimateSword.setItemMeta(meta);
return ultimateSword;
}```
and whenever I try to add an attribute it breaks my event to explode on right click
```java
if (e.getItem().getItemMeta().equals(itemManager.ultimateSword().getItemMeta())) {
if (!cooldown.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldown.get(p.getUniqueId()) > 5000) {
cooldown.put(p.getUniqueId(), System.currentTimeMillis());
p.sendMessage(colorize("&aYou've used the Ultimate Ability!"));
p.getWorld().createExplosion(p.getLocation(), 15f);
} else {
p.sendMessage(colorize("&4You can't use this for another &e" + (5000 - (System.currentTimeMillis() - cooldown.get(p.getUniqueId()))) / 1000 + " &4seconds!"));
}
}```
anyone got any idea why this is happening
When you change an attribute the item stops exploding on right click?
Are you grabbing a new ultimateSword in mc after making the change in code?
no it's when I added it
when I added the attribute for more damage the event stopped working
Did you get a new sword in minecraft?
i mean technically I have the sword
Yes but the new sword has a different meta
when you're checking if the item the player using is the sword in the event it's comparing the meta including the new attribute
yeah
that's what it should do
to make sure the sword is authentic
yes
but if you don't get a new sword in minecraft after making a change to it in the code it won't detect is as the correct sword
your old sword isn't authentic anymore
i have no idea what you're trying to say
it's just one sword
OH do you mean like I get the sword with the updated code?
yeah
because yes I've done that and no it doesn't work
Ah ok
I don't have much spigot knowledge so I don't think I can help but I'm curious what attribute you're adding
damage
the sword without the attribute works but the one with it won't
How are you getting the sword?
did you not see me run the command in the video
so whenever I run that command it should give me the updated sword
This question is extremely related to what I have made in the past (and am currently refactoring) lol
How are you determining if your item is the sword in the event code?
nvm i see now
Its because when you add the attribute its metadata changes
so your conditional will always return false if anything is added.
You need to find a different way to verify the item
anyone know if you can force change a mob's texture to something else like protocallib's disguise
for texture, yes
okie
and can you like
give a mob a tag
and apply custom texture to mobs with tags only
i did it with items before
iirc, no
wait wait then how does nametags work on mobs
like the rainbow sheep
and cat
is it something you can change with texture packs?
i think each mobs have their own texture
texture packs override right?
How can I change the hardness of a block?
AFAIK you can't I'm pretty sure all those values are locked in nms
I doubt you find something but I'd suggest digging around nms
you cant directly but if you want to change mine speed time you can either use nms to send block break animations at specific times or mining fatigue 1000 then time it
hm oh yea
I could add mining fatigue if they are targeting it
wait is there an event for someone starting to break a block or is that just like interact event?
whats the abort event for
if they abort breaking it
whats that
ima just use mining fatigue for now xd
wait... is there a way I can add mining fatigue but not make their hand move super slow
there must be cus hypixel does it
Packets probably
There's no avoiding nms 😈
😱
do I need any extra repositories/dependencies for nms to work cus I cant seem to get it to work.
?bt
also remove the -api on the dep
I dont see a dependency/repo on this page
how do I use that
?pdc
can you make a zombie attack? like play the attack animation with no target in mind
Feel free to take a look at this: https://github.com/Fisher2911/CustomBlockMining some stuff needs to be fixed because I transferred it over to my plugin that I used for my server, but it should give you a pretty good idea of how to start
I used PacketEvents which is a very nice library
There’s a bug where it doesn’t get called if they switch blocks though
you build spigot then you can use all of spigot in ur plugin
is there a way to change the hit velocity of a player so for example i listen for a playerHitEvent and then make it so that their knockback is decreased by 25%?
hey, could anyone help with #1043942626472230923 ?
Can you save a list of ItemStack inside an ItemStack, with pdc perhaps?
it doesn't seem that itemstack has pdc unfortunately
nbt maybe?
https://www.spigotmc.org/threads/tutorial-storing-custom-data-on-itemstacks-in-1-13-2.354283/ this looks interesting too
yes
just use base 64 encoding
so itemstack does have pdc?
yes
strange, didn't see that in the docs
wait wdym does have pdc
So save it as a string, technically?
yes a string, but its encoded
..persistent data container?
It's from ItemMeta.
ItemStack does'nt
Alright, thank you.
forgot it was a thing 😄
i have a gist if you want to see how
What is list of event please (i check item frame place but i dont have évent)
should be BlockPlaceEvent
Item frame is a entity non AT block
probs HangingPlaceEvent
I loock this but i loock Système.out.printer("évent") but 0 log is get
How can I make an item given to myself when I join without giving me multiple times? Like I got the item then when I rejoin I get it again, is there a way I can update the item instead of giving me over and over?
you cant put custom characters and use Bukkit.getLogger.info()
I am trying to figure out how can I check if it's not null?(https://prnt.sc/7NN_0PC3MVxm) this is my code (https://prnt.sc/FDKHbcLBKLlw)
when I try to move any other item rather than my sword it gives the error
use pdc
or
pdc?
spinnenballe
?
@alpine herald
?pdc
ah
so I try to check the custom data will it not be null when I move other items?
I'm trying to cancel the move and drop event of my custom item but other items can move
oh okay
@drowsy helm any comment on this code? https://paste.md-5.net/ilucevetuy.php
Im not buoobuoo but maybe try-with-resources
why does my scoreboard flicker?
it looks like its only there for one tick
im using the bukkit api, i made a class to assist me
builder class: https://paste.md-5.net/wozilamago.java
code:
private void updateScoreboardFor(Player player) {
ScoreboardBuilder builder = ScoreboardBuilder.newBoard("kitpvp");
builder.title(kitPvpScoreboardTitle).displayAt(DisplaySlot.SIDEBAR);
final String prefixLine = ChatColor.GOLD + "" + ChatColor.BOLD + "| " + ChatColor.WHITE;
if (scoreBoardTick % 12 * 5 == 0) /* current session */ {
builder.addLines(ChatColor.GOLD + "" + ChatColor.BOLD + "» " + ChatColor.WHITE + "Session");
builder.addLines(prefixLine + "Kills: " + ChatColor.RED + "69");
} else /* total */ {
}
builder.update().show(player);
}
i call this code every tick with a runTaskTimer
for each player
oh wait
i bet its switching to the empty liens
Why are you creating a new scoreboard every tick
ill optimize it later
i just want to get something working
its still flickering tho
probably cause u change it every tick
how would i clear the objective
what is an entry
the player name i imagine
Hey, is the "ProxyServer" Class the replacement for the "BungeeCord" Class?
i cant just replace the old objective
oh nvm i can unregister the old one
Is there a way to make a dropped item despawn faster or increase its age? I want to make an item I spawn in the world despawn quickly without changing the global value
with nms you could edit the NBT tag
hey, could somebody help with #1043942626472230923?
@sterile token opinions?
very A tbh
there's a lot more to it
Lmao
Button is the simplest menu element that just represents an item with an optional click handler
I have multiswitches that let you cycle between options and all
Who is tagging me!
Nice job bro
me
Oh ilusdionvjro
Lmao
hand it over
Sorry i just seen the photo
I'm wondering how I'll animate it
Discord is working for thetrush
this will be retrocompatible
I'll add some api methods that get the items from the pattern mask
the old system was way too simple and things like toggle switches are a pain to make
as it was made for static menus
Yo bois and girls
Any ideas how to force the server to send an update of a custom entity to the client?
why you want to do that
Because FallingBlocks do not get updated every tick
And therefore the clients are doing weird precitions which lets the fallingblocks look like fucking skyrockets
you're tryna spawn a stationary one?
Oh I have done that already
client does predictions, you gotta send velocity packets each tick
Now that sucks
and maybe teleport it once in a while
check radius
Still kind of annoying isn't it
(They also have a blueprint system attached and are getting saved and loaded via json)
hm i dont think having the scoreboard constantly updating on another thread really helped the flickering
server crshed
<:
bros scoreboard doing nasa trajectory computations
Don't mind my business, only like 30 hours of work in total
Eh more like 40
I know why
You’ve got to allow for the molecules to combine and photo synthesise which then activates a chain reaction to the quantum nexus particles
That’s your problem right there
You can thank me later
the easiest way to solve that problem is turn your monitor off
cant flicker is you cant see it
Ebic did you think anyone is dumb enough to spawn stationary MULTI-Fallingblocks?
tf is a multi fallingblock
Just what the name tells you
multiple?
this
Yeah
Have not found anything online so I began writing that by myself =(
And I lost my mind multiple times, while reading through Server internals
Why not just set gravity to 0?
that's not how it works
^
Why not?
just try and see
fallingblocks are special
and I just prefer to mount them on armorstands because fr they painful
- The Entity will despawn after 400 ticks
- The Entity despawns when hitting a ground instantly
- The client predicts movements so it will look like a skyrocket into the ground
ok now scoreboard only updates when marked needed
Yeah one thing, I gotta have collision and so on lol
than deal with the bukkit impl
flickering fixed
I was just looking at their code a couple days ago and I swear they have a check for it but maybe I’m not remembering correctly
you gotta write your own boundingbox with rotation n all
because like
hell naw
just make a combined boundingbox
to be real the code is 95% nms 5% Bukkit
I know
I do funky nms shit sometimes
I've been messing with so many fake blocks lately
making a full client-sided prison system
Thats a lot of "fun"
i love when my brain decides its time to go smooth
Yeah who doesn't?
normal people
ItemStack baseItem = null;
for (String s : dataConfig.getConfigurationSection("auto-pickup.drop-swap").getKeys(false)) {
if (block.getType().toString().equals(s)) {
baseItem = new ItemBuilder(Material.valueOf(dataConfig.getString("auto-pickup.drop-swap." + s))).amount(1).build();
} else {
baseItem = new ItemBuilder(block.getType()).amount(1).build();
}
}
``` can anyone see any reason for baseItem to be more than one