#help-development
1 messages · Page 1980 of 1
You could probably set player metadata, or use a database
ok
If it's for testing purposes, you could also just use true in whatever if statement you're using
k
What would be the best way of doing something like this in a config file:
kits:
- kit1:
permission: "kits.kit.kit1"
cooldown: "3d"
its fine I parse that a different way
Could you elaborate further?
This is already in YAML
Like how can I make the kits configurable so you can add more
but still access permissions and cooldown
kits:
- kit1:
permission: "kits.kit.kit1"
cooldown: "3d"
- kit2:
permission: "kits.kit.kit2"
cooldown: "3d"
I was looping through the "kits" StringList but it didn't seem to work
maybe I was doing it wrong if that looks correct
This is a dictionary, not an array
You need to loop through the keys, and then recurse into each
hm ok
I will further look into it
yes that's what I had
but I can't seem to loop through it like I wanted
private static String getCooldownType(KitsPlugin plugin, Player player) {
List<String> kits = plugin.config.getStringList("kits");
for (String kit : kits) {
String permission = plugin.config.getString("kits." + kit + ".permission");
if (permission == null) continue;
if (player.hasPermission(permission)) {
String duration = plugin.config.getString("ranks." + kit + ".cooldown");
if (duration.contains("s")) {
return "s";
} else if (duration.contains("m")) {
return "m";
} else if (duration.contains("hr")) {
return "hr";
} else if (duration.contains("d")) {
return "d";
} else {
continue;
}
}
}
return "";
}
that is just getting the cooldown type
here is getting the cooldown duration
private static int getBanDuration(AppleLifesteal plugin, Player player) {
List<String> kits = plugin.config.getStringList("kits");
for (String kit : kits) {
String permission = plugin.config.getString("kits." + kit+ ".permission");
String durationType = null;
if (permission == null) continue;
if (player.hasPermission(permission)) {
String duration = plugin.config.getString("kits." + kit+ ".duration");
if (duration.contains("s")) {
durationType = "s";
} else if (duration.contains("m")) {
durationType = "m";
} else if (duration.contains("hr")) {
durationType = "hr";
} else if (duration.contains("d")) {
durationType = "d";
} else {
continue;
}
try {
return Integer.parseInt("duration".replace(durationType, ""));
} catch (NumberFormatException exc) {
return 0;
}
}
}
return 0;
}
always returns 0
There’s also getMapList
can I make the block a player is looking at clickable? (ie makes the client play the hand animation)
I mean, you are probably looking for getKeys
like if someone were to try and click on an iron door
You can use the interact event and swingMainHand
Or swingOffHand
i wanted to keep the animation going as long as the player is right clicking
okay thanks
imagine eating
i was getting help in a diffrent server
so this is not my clip/video
but is this a bug
We can’t see your code
From the looks of it you have plenty of cheats active, so doubt it
So we have no idea what’s going on
@EventHandler
public void onSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
Bukkit.broadcastMessage("Sneaking: " + player.isSneaking());
}
how do i have alot of cheats active
also if i change the event to PlayerMoveEvent the output will chagne
Given to how most of these mods behave, they should be classified as hacks/cheats
Lol?
All of them
I see a clock, a compass, and an arrow counter
Yes, that is an unfair advantage and nullifies the reason to have a clock
Who uses clocks
all of which can be accessed in vanilla. just through more annoying means
what about player move
What about it
You could just flip the boolean to get the state after the sneaking, it's not that hard to do that
Probably better
on player move its the oppasite
also how to i use player.getNearByEntitys
getNearbyEntities(double x, double y, double z)
how would i make it a 30 block radius
read
15 to each
i did
1/2???
so 15, 15, 15
yes, if you want it in every axis
and it will output all the entities to the console?
No? It will give you a list of entities, as it says
No it’ll return them in a list
how do i send the list?
?learnjava
?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.
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.
LOL, not sure if thats just on my side but both of those bot messages are in one for me
why does intellij warn me about using optionals as a field?
is there any reason why i should not?
any one can explane me how would I get heads with skins for players which never playerd before
to generate base64
code
should I get texture from mojang server
some one could point me to some spigot tutorial
because I got in problems gui opening to long because heads can't be loaded from mojang data base
is it safe to blind cast a HumanEntity to Player?
Afaik, yes
it should be, but if some plugin implements humanentity for any reason, you might get some troubles
i'd suggest putting an instanceof check
alr
is there anyway i can sort the list of configuration values without making the them objects?
so like
the x value has price in it
and i want to sort the values by the price value in the configuration
anyone know wtf just happened and why there are a ton of invisible falling blocks
btw is there a way to get the blocks in a spherical radius (while im getting help for this lol)
with some maths
int radius = 5;
List<Location> sphere = new ArrayList<>();
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {
for (int z = -radius; z <= radius; z++) {
Location blockPos = origin.clone().add(new Vector(x, y, z));
if (!blockPos.getBlock().getType().isAir() && origin.distance(blockPos) <= radius) {
sphere.add(blockPos);
}
}
}
}
You can compare the distanceSquard from the block to the center
this is the maths
thx
Ew .distance
Fight me
Yeah, use distanceSquared
😉
so why is this doing this
this is the error
and https://paste.md-5.net/iwadavoqew.java is the code
i dont understand why its getting an infinite number
and where
MiscManager line 52
That’s what the error says
huh
Make sure the code you are running is up to date
it is
Then the error wouldn't point to count++
ik xD
ok its probably my shitty vector code
multiplying
entity.setVelocity(block.getLocation().toVector().subtract(entity.getLocation().toVector()).multiply(1/(10 - power)).normalize());
I mean normalizing the vector should prevent this ?
ye
so why this not working lol
btw if it helps, the power im using is 5
so its multiplied by 0.2
so why is it freaking out and making invisible falling blocks
and erroring
the invisible blocks seem to be client side
lol
i need help
Granted multiplying by 0 still shouldn’t be an issue
im making killstreaks and i want to send a chain of messages 1 by 1
with 1s of delay between messages
cuz
if i do
?scheduling
thanks
k so
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("Mooooo!");
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay /, 20L * 5L /<-- the interval */);
if i want to send 3 messages
i need to put the same code
with different text?
Make a queue of the messages and then poll from the queue each time
how?
When the queue is empty, cancel the task
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("Mooooo!");
Bukkit.broadcastMessage("Mooooo!");
Bukkit.broadcastMessage("Mooooo!");
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay /, 20L * 5L /<-- the interval */);
like that?
why
lol
idk im asking
No, poll
how? :c
Poll is the method to retrieve an element from a queue
oh
how can I use poll
?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.
bro I know about java
Specifically, learn about queues
but not, spigot
Queues are not a spigot concept
I mean I guess you could use an array too
And just increment the index each iteration
new BukkitRunnable() {
int count = 0;
@Override
public void run() {
Bukkit.broadcastMessage(listofmsgs.get(count));
count++;
if(count > listofmsgs.size()) {
this.cancel();
}
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay /, 20L * 5L /<-- the interval */);
idk
lol
*>=
@cobalt tinsel
that might not work but try it ig
lol
but
the problem is
i don't need to cancel
cuz my runnable it's inside of a switch
so I just need to send the messages with delay
You still need to cancel it
btw listofmsgs is new ArrayList<>() and add stuff
1s between message
Otherwise it’ll go on forever
Ikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Im just saying
that cancelling it, it's not the problem
or Arrays.asList
same thing
is there any way to call EntityLiving.heal using the API?
no
to heal a player with a cause, event call, etc.
as if it actually happened
entityliving.heal does that
oh, well make an if
no like
using a regain reason, everything like that
just everything that the server does
any example?
oh
what ide is that
intellij idea
intellij
with gradianto natural theme
you can tell by looking at it
lol green theme
how do i export my mc plugins from eclipse into minecraft?
i made my own server which is hosted on my wifi network but i dont know how to export plugins into the server
can someone help me
thought so
export them as jars and put them in the plugins folder
i tried that
and then when i go into server and do /pl to see plugins, i cant see the one i created
so...
You’re probably better off just copying that code
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage(CC.translate(Arrays.asList(
"",
ChatColor.YELLOW + "[☢] A Tactical Nuke is coming!"),
ChatColor.YELLOW + "10 seconds until explotion",
ChatColor.YELLOW + "9 seconds until explotion",
ChatColor.YELLOW + "8 seconds until explotion",
ChatColor.YELLOW + "7 seconds until explotion",
ChatColor.YELLOW + "6 seconds until explotion",
ChatColor.YELLOW + "5 seconds until explotion",
ChatColor.YELLOW + "4 seconds until explotion",
ChatColor.YELLOW + "3 seconds until explotion",
ChatColor.YELLOW + "2 seconds until explotion",
ChatColor.YELLOW + "1 seconds until explotion"
));
this.cancel();
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
all of that messages will
be
insta sent
ahh my eyes i just changed my theme to a different one and now its stuck in light theem
lol one dark theme be like
how can I add a delay on tht
well dont send them all at once.
how
runnable
oh wait
nvm
that's a runnable
when ur logger.info is on line 69
Bukkit.broadcastMessage("[☢] A Tactical Nuke is coming!");
new BukkitRunnable() {
int count = 10;
@Override
public void run() {
Bukkit.broadcastMessage(count+" seconds until explotion");
if (count <= 1) {
this.cancel();
return;
}
count--;
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
this could be a way to do it yea
Explotion
@Override
public void run() {
Bukkit.broadcastMessage(count + " seconds until explotion");
count-=10;
if i do that
isntead of count--
it will be better right?
that will subtract 10 from count
yea
idk if you want that
yea it's fine
well then do that
bc
how do I use the map from the config maplist
adding a chain of messages will be harder
It’s a List of maps
I believe it’s specifically List<Map<String, Object>>
but when I use config.getmaplist, the maps I get in the list are Map<?,?>
just to make sure, casting is (object to cast to(value)), right?
Map<String, Object> newMap = (Map<String, Object>) map
Your ide can add the cast for you if you just define the type
thanks!
last question
So I'm using Jackson to save data and at any point in time when I try to save data I can but as soon as I go to stop my server it says this. My onDisable function contains the same function call that saves data as the command so it's not that, but I think it's smth to do with how I shaded it?
Here's my pom.xml: https://www.toptal.com/developers/hastebin/runozeteda.xml
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Keep in mind this error only happens sometimes, it's more often than not but it's not all the time
I've tried so many different solutions and have been trying to fix this for weeks
It doesn't say how it works with an ArrayList<ItemStack>
Inside of an object
Because obj.addproperty only works with string number and boolean
Notice the class in question is com/uhmily/scovilleplugin/shaded/com/fasterxml/jackson/databind/ObjectWriter so I would follow the normal solution of removing a corrupted jar from my local repository but..when I run mvn -X package it sees and processes it just fine
Ran mvn clean as well?
Yep
I'm trying deleting just jackson-databind from my local repository and ig we'll see if it errors at all again
?jd
declaration: package: org.bukkit.entity, interface: Entity
oh thakns
alr did it
Nearby entities is cleaner just use it
k
like this?
for (Player p : Bukkit.getOnlinePlayers()) {
List<Entity> nearbyentities=player.getNearbyEntities(10, 10, 10);
if(nearbyentities instanceof Player) {
double health=((Player) nearbyentities).getHealth();
((Player) nearbyentities).setHealth(health - 10.0);
}
}
I suppose if the goal is to make it so that every player within the defined radius takes 10 points of damage
Yes
It should work right?
What is the cause of this problem? It is quite occasional, does not leave any additional information apart from a NPE in the server console (nothing client log)
I did some research but in vain
does it only happen when you disconnect?
as in you quit the game
It doesn't happen when I log out, I think it's because of my scoreboard packets, however, I'm not sure what I'm saying because there is no problem with the score packets I send when the player logs in for the first time, maybe a packet that the decoder can't decode It doesn't happen when I log out, I think it's because of my scoreboard packets, however, I'm not sure what I'm saying because there is no problem with the score packets I send when the player logs in for the first time, maybe a packet that the decoder can't decode
DO NOT USE PACKETS FOR SCOREBOARDS
lol
it avoids flashing! Bukkit does too many things, it doesn't go straight to the point! And, I don't really think that's the problem, it's more the decoder of the player's channel that does shit in my opinion
Lol you can avoid flashing with prefixes and suffixes
That's not the problem, the flashing is more due to the fact that by passing through bukkit, there are more things done to the scoreboard, things that are sometimes useless in some cases of use, and this extra processing causes flashing
That’s
Not how things work
But yes bukkit does make sure to send all your scoreboard data off to China
Even you admit that xd
So, packets are very good in this case to send directly what we want
You do realize it doesn’t matter how much processing Bukkit does to the scoreboard
If you make a new scoreboard every tick then you'll get flashing.
In the end it’s still just sending a packet
Bukkit could piss around with the scoreboard for a half hour and that still wouldn’t cause flashing
Fortunately for me, I don't do it every time I tick
I mean technically you can do everything with packets if you really wanted, doesn't mean it is the best way. However, just like the server when a player joins the client is also initiatlizing stuff too and sending things too early causes issues on both sides.
Just a half hour delay
It only flashes if you make a new one. Updating an existing scoreboard shouldn't
Changing entries can cause it to flash on slower connections
Probably because the remove packet for the old entry and the add packet for the new one get split up
Yes but, the things that I send and that obviously crash a client / 3 in a random way are not sent at all at the beginning even rather in the middle
But you can just use prefix and suffix for that
my scoreboard doesn't flash
Plenty of non flashing scoreboards have been made with the API
well you have your answer in what the issue is, and that is sending scoreboards via packets
either just accept that packets can get mangled
But it’s faster!!!1
This is not the problem in my opinion, as I said earlier there was no problem before with the same system
obviously there is a problem if you are complaining about clients being disconnected and the issue being related to your scoreboard
Yes there is a problem but I doubt it is related to the scoreboard
Most IO problems occur because of someone messing with packets. Unless you are sending packets directly for everything else as well, the only thing you stated you directly send packets for is the scoreboard
You can disagree what everyone else is saying in what the problem is, doesn't mean that isn't the problem. Especially when the owner of Spigot even stated that you shouldn't send scoreboard stuff via packets directly.
I mean we’ve had an API for many years
So either you know better then everyone else here, which wouldn't make sense because you came here for help or everyone else here is correct on what the issue is
if you don't want to change how you are doing scoreboards that is fine no one is forcing you to do anything, just that you need to accept that clients getting disconnected is just a thing that will happen every now and then
Is it bad to decompile a premium plugin just so I can work out how to use the api if they don't give documentation? Like I won't share code I just wanna work out what's going on
no, this is just wrong
the API is literally a wrapper around packets
do what you do with packets with the api and the result is the same
You, sir, can do whatever you'd like on your own computer.
I mean I gotta try and add support for a plugin but the dev won't even give api docs... 😔
He even heavily obfuscated the api
The dev will be informed and you will be collected by the men in black within 13 minutes
Who tf obfuscates an API
The dev who charges $20 per plugin and you need all 5 or 6 of them to work together
$35 my bad
Yeah it is mcm kids are a different breed
Mcm moment
also spigot doesn't allow premium plugins to require addons to work either
TE?
Thermal expansion?
Something enchants. Can't remember the first part
Really, most enchantment plugins are guilty of that practice
but that plugin was before our rule change, so ye
isn't this a forge mod?
That's the one. Token
Grandfathering is evil
Maybe
well such things could end with another ToS update lol
Or an execution
Excuse me, my intention was not to hurt you, I was just giving a different hypothesis so that we all have as many elements as possible to again issue new hypotheses of why and how these events occur
I am not hurt, just many people come here for help but then refuse that help or instead refuse to accept what everyone is saying as true, which is counter intuitive to the purpose they come here to begin with.
frostalf is always hurt
You seem angry all the same, my intention was not bad, I just wanted to make several hypotheses in order to determine all the causes that could have caused this event.
Did you shade Jackson yourself
Did you relocate
Changing the package to avoid conflicts
Maven or gradle?
You should
relocating is part of shading. It helps to avoid conflicts when there is multiple versions because the package path is the path that gets put on the classpath. If there is multiple versions, the version that gets used is which ever gets loaded/registered first.
it should be standard practice when shading that you relocate dependencies you actually need even more so if its version dependent
here is an example of how to do relocating
https://github.com/frostalf/ServerTutorial/blob/master/ServerTutorial/pom.xml#L157-L204
also shows how to exclude transitive dependencies from shading too
had a problem at one point with things wanting to get shaded in that I didn't specify so I forced maven to not shade those things in lmao
Holy exclude batman
I never fixed the duplicate bukkit ones lmao
I did that out of frustration if I remember right because bukkit kept getting shaded in XD
was really annoying, but all those excludes were the dependencies shaded into bukkit
that means the dependency was compiled with a higher version of java then what you are compiling with
either use a higher java version, or use a dependency that supports the java version you are compiling with
hey i am trying to encode a textcomponent with gson but i got this error
java.lang.reflect.InaccessibleObjectException: Unable to make field int java.awt.Color.value accessible: module java.desktop does not "opens java.awt" to unnamed module @3444d69d
any idea?
You’ll need a custom serializer
public byte[] encode(T message) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {
this.gson.toJson(message, this.type.getType(), writer);
} catch (IOException e) {
e.printStackTrace();
}
return out.toByteArray();
}
i found https://github.com/ATLauncher/ATLauncher/commit/1d5f4377fe888bf0d257a0e8d444c06b5d74d55e and tried it but it just make the error bigger and incomprehensible
maven compiler plugin has source and target section you can change it
and project structure > project > project sdk if needed
?paste
That’s an example adapter for Location
Color should be much simpler
Huh, I have a typo in that :p
yes but im not just trying to encode a color
i am trying to encode a textcomponent
which has color in itself
i mean ChatColor has Color*
Yes, making an encoder for that should work
Otherwise you need to make one for ChatColor
Or possibly one for component
You can’t use gson.toJson in your encoder
That’s kind of the point of the encoder, to tell that method how to store something
Is there any reason bukkit doesnt send plugin message to client
My client isnt receiving it
Did you register the outgoing channel?
Yes
public void onEnable() {
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "testclient:main");
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
getServer().getScheduler().runTaskLater(this, () -> {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("moduledisable");
out.writeUTF("{\"modules\":[\"packet-canceller\"]}");
e.getPlayer().sendPluginMessage(this, "testclient:main", out.toByteArray());
}, 5);
}
(i register the event listener i just removed the line)
what's the best way of storing something like a hashmap in a .yml with the ability to freely add and remove from it
It’s set
As long as the keys and values are configuration serializable
What does "configuration serializable" mean?
@ancient planki've never done anything, i've been downloading the sace plugin from spigotmc, but i'm banned i can't get into the ip ban for no reason why i'm banned
pls help
@tender forge
off
yes but
can you open my account the site i created on the minecraft server wants a vpn because please i didn't know
i think this method does not work that way
bungeecord has a method for that but i dont think spigot has one
the method you currently use is for plugin messaging
a
idk how related this is to development but i feel this chat is the best place to put it. So im using a windows PC with intelij to code spigot plugins when I try to compile the plugin my anti virus (mcafee which came pre-installed) says "we have stopped something malicious" i cant exactly remember the message but it was saying something about "fileless threats" does anyone know why this is happening?
FYI its not too big of a problem as the file does compile into a .jar but i just want to know why its happening and should i be concerned
It's probably happening because McAfee is terrible. Just uninstall it. Having only Windows Defender is the best option. Any other anti virus software will just potentially interfere with it. You don't really need a custom anti virus anymore nowadays unless you click on every ad you can spot online.
so you think its just a false alarm basically?
Yes. You get countless of them with anti viruses like these.
ok ty!
does this look bad when run in a live server? its a runnable that run every 3 ticks
executed spark for 5 minutes for that profile
what exactly does the runnable do
Its like a guardian mob beside you, literally floating the right side
It will target any entities that damaged the player
I'm not using nms for that
Pretty much yes
The one that will bork the timings
Unless teleportation can be done in another thread which is not possible ig
- What is the fastest way to clone an array?
- How can I reverse an array, fast
System.arraycopy
hmm okay what about the reverse/
you could make something like this
Collections.reverse(Arrays.asList(array))
i think it will work
oh never mind
Cannot invoke "net.minecraft.nbt.NBTBase.getTypeId()" because "var1" is null
what does this mean
Var1 is null
send code please
i'm saving a PlayerHead itemStack to a file
this builds the item
and this is an example of an item
please help
are u able to retrieve your itemstack from the file properly
i can't even save it, i didn't made the retrieve part yet
u using yml for it?
the first one should do it ig, as long as the file is being written properly and aint blank after executing the save method
i don't have any file because whenever it tries to save the item it throws an error
and it doesn't save anything
also i think its a problem with player head data because as you can see in the error it says something about SkullMeta
.
have you made a method where it makes the yml and loads/save it #onEnable()
so basicallly there is a problem creating the file?
if it doesn't exist in the first place and you're trying to save to it then might be it
what does saveResource method do?
backpacks.yml here is packaged default
gets the embedded yml file and saves it in the plugin's parent folder along with its contents if it has
create the needed yml file in your resources folder/package
i can't. The whole point of this is that it does everything automatically, saving every CustomItems enum value (builded with the ItemBuilder) into a yml file in the plugin folder
i have like 100 custom items values
i can't make 100 files in the package folder
so you can't save those in a single yml file in its contents?
i'd prefer having multiple files but i can try thart
you can retrieve those as list then to itemstack array
maybe you can get an idea from this, I'm about to go out
ty bye
btw my problem is that i can't save a PlayerHead SkullMeta
the creation part now is working fine
but thats not a thing i made, thats a NBTBase class var
I'm not familiar with nbt's unfortunately, hopefully others can help you with that
ty
private void registerFile() {
file = new File(getDataFolder(), "messages.yml");
fileConfig = YamlConfiguration.loadConfiguration(file);
saveFile();
}
public void saveFile() {
try {
fileConfig.save(file);
} catch (IOException e) {
}
}
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;```
I am very new to plugin development so please forgive me if the error is very simple or solve and I just look very dumb here
All I want to do is create a messages.yml file alongside the normal config.yml file so I can store the messages stuff there and let the user edit all sorts of messages in the plugin
What would be the bast way to save player skins data to file
and when I should update it
should I go with yml file
or json
and put all data to one file
if you are expecting to save data for a ton of players, maybe use different json files for each player and name the json files to the player's uuid
works every time
The best way would be to store it inside a database
I already got yml files where i store there balance
yeah well that works too
I was thinkin of mysql
but no sure when should I update it
in case skin changes
you are limited on 600 request per 10 min
you want players to not be able to change their skins?
to mojange servers
player heads problems
I got gui which laggs
No need request
Store skins in a db, then check when player join ?
If you are, decompile some existing ones and see if the issue can be resolved without saving skin data.
Right, maybe you could just cache skin data instead of storing it in a db
halp
is there a function for 1.7, 1.1, 1 -> 2
Is there an alternative to the PlayerChatTabCompleteEvent, since it is deprecated ?
Might just need to use TabCompleteEvent and check manually
Oh that works perfectly for my needs, neat
You mean a function f(x) where f(1.7) = f(1.1) = f(1) = 2?
There are several.
When I'm running my command from file CreateCompany.java code: package `com.biolegs.company;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CreateCompany implements CommandExecutor {
private Company plugin;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
plugin.eco.depositPlayer(player, 10);
return false;
}
} it shows to me this error in the console: Caused by:java.lang.NullPointerException: Cannot read field "eco" because "this.plugin" is null ` I can't show full message because its too long how can I fix it?
Sure you can fix it. Make sure "this.plugin" is not null when you call the command...
but how
I mean on the top I'm writing to create a private variable called plugin oh and this
"Company" its the name of main class
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
pliz halp
. this might help you ig, get idea from it
?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.
thanks, I will have a look into it
removing a value from a persistent data container - that change is effectively saved, right?
Yes
Hello, does anyone know how to get the hand item location of a small armour stand? If you could help it would be much appreciated.
Thats quite complicated. Needs quite a bit of math.
You can try and modify this a bit for smaller heights:
https://gist.github.com/Flo0/d06ca41842632e10253092e42935d25a
Thanks I'll have a look at this
hello
got a question
is any way to cancel pvp near some coordinates, like i get spawn coordinates and near it, nobody can fight
@EventHandler
public void onChestExit(InventoryCloseEvent e) {
if (e.getView().getTitle().contains("LOOTCHEST")) {
e.getInventory().getLocation().getBlock().setType(Material.AIR);
}
}
The chest doesnt deletes, why?
Yes. Several. Do you want a box or a radial distance estimate?
radial
cuz cancelling entitydamagebyentity wouldn't be that professional hahaha (with an equals on locations)
Just use distanceSqared to the spawn location
And cancel the EntityDamageByEntityEvent if the radiusSqared is smaller than N * N
kk
ok so that worked perfectly, now if I wanna make multiple custom files, do I just duplicate that code?
Did you register the listener?
lol
Happens to everyone
you can create a config manager
what is a config manager
works thanks i love you
the spawn location is stored in the World object
i need to put an uuid value on there
or an String
should i put "World"?
Get the world the player is currently standing in
k
if i set a permission to 'default: false' does someone with '*' still have it?
yes. Yes they do.
depends
if your perms plugin understands *, and the perm is registered in your plugin.yml
craftbukkit apparantly understands '*' as 'everything'
on a different note, player.setMaxHealth(double) is deprecated, would player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(double); work the same?
y
k
hey so I have a file which is config.yml and I have a file which is messages.yml
How do i specify in the code when I want to take data from which file
hey after appalyign new metadata to item stack which is in player inventory do I need to set new itemstack or current one will be changed ?
google it, spigot and bukkit forums has ton of these answered
Setting the ItemMeta will change the actual ItemStack in his Inventory.
then I did something wrong
I am settign skin on head
async
and it is not taking effect
and now I am thinking
do I need to set dam stack again
You cant interact with any spigot api from another thread. Even if it sometimes looks like it.
brain freez
so i should call set meta from main thread again
what dependency should i add in order to have access to this class?
proper version
insted of spigot-api
you add dependancy of spigot
what do you mean?
for example
I think minecraft-server will return mojang mappings(Classes are named with original names of majang )
I also have spigot
on screen shoot you got spigot-api
which event is the one that lets you throw things
that can access only spigot api
So i also need to have spigot?
playerinteractevent?
change spigot-api to spigot
like on my screen shoot up
but you will need to build it with BuildTools
Okay
to your maven repository
hey
which event is the one that lets you throw things
Item drop Event
PlayerDropItemEvent
possible
I'm opening a custom inventory, how can I check if a closed inventory is the corresponding inventory? InventoryView is an interface, and the title can be changed by players afaik
Save the view to a set
thanks
also i found this
i see people using a list in places where they could use a set
I'm trying to mimimize my code so that image is pretty useful for me
is there a way so that when my plugin generates its config.yml in the folder, it keeps the comments
Like this -
##### GENERAL CONFIG #####
spawnonjoin: false
spawnondeath: false
##### MESSAGES CONFIG #####
prefix: "&7[&cPlugin&7]&r "
But when the file generates, it removes the comments, I dont want that
hey
it's fixed in newer versions iirc
how much staruation should i put if i want to fill their steaks
Modern versions of 1.18.1 preserve comments
1.17 is also doing it afaik
player.setSaturation(20.0F);
Saturation is not hunger
It’s the hidden value behind hunger
its 20 points, half a bar each. Saturation is a 'second' hunger bar that drains first
and how can I change hunger
the reason golden food is so good is because it's saturation is higher than it's hunger
setFoodLevel iirc
it can fill up both bars
oh
I dont use snakeyaml
or how is it called
I use this
That’s SnakeYaml
who's on mc rn that can help me testing
sure, what version?
1.8
but i can start my launcher
or 1.7
oh god 1.8
ye ol 1.8
og minecrafter
1.2.5 is OG minecraft without singleplayer chat
you misspelled old
yea
wait
tell me too
sussy
you don't know ngrok?
I dont
where is the ok button lol
does isBlockPowered() work on non redstone blocks? (stone, grass blocks...)
oh lol its not visible on my screen
Yes
stupid 2nd screen
does it also work on translucent blocks?
so on blocks like glass it would not work
wouldnt it throw back false then
Probably
aight i'll test, thank you
private Plugin plugin = Main.getPlugin(Main.class);
public void customRecipe() {
ItemStack item1 = new ItemStack(Material.WOOD_PICKAXE, 1);
ItemMeta meta = item1.getItemMeta();
meta.setDisplayName(ChatColor.GRAY + "Wooden Hammer");
ArrayList<String> lore = new ArrayList<>();
lore.add("hammer!");
meta.setLore(lore);
item1.setItemMeta(meta);
@SuppressWarnings("deprecation")
ShapedRecipe f = new ShapedRecipe(item1);
f.shape(" # "," $#","$ ");
f.setIngredient('#', Material.WOOD);
f.setIngredient('$', Material.STICK);
plugin.getServer().addRecipe(f);
}
someone help please idk what i wrong but i can't craft my hammer
someone help please
(You need a namespaced key)
how to use this
?jd-s
thank i have find how to use thank you
we have an even shorter command for the spigot javadocs now?
Is there a for(ItemStack i: p.getInventory().getAllItems()){}?
or something like that
.getContents
thx
or just for (ItemStack i : p.getInventory())
Oh yeah inventory is iteratable
Can you set itemmeta to final ItemStack ?
Yes
well my item meta is not getting set
How check if Player on ground in PlayerMoveEvent?
if the vertical speed is 0 that's a pretty good bet but i think there's a method for that
you can use player.isOnBlock, but that can be changed by the client and is therefore deprecated
how do i get the paper api from buildtools
You don’t
can a record have an abstract method?
what
Paper doesn’t use buildtools
it says not allowed
Go talk to paper
try if(e.getPlayer().getVelocity().getY() == 0), im not sure if itll work
hmm I can try
one morme thing
you need to check if the player's actual y component ends on .000, or they could be swimming up into a block
also getVelocity() returns the vector the player is moving in
if they're on the ground they're not moving
on a completely different topic, can i somehow serialize ItemStack[] into a string instead of a map?
what do yall think about this idea to handle subcommands?
its a little small lemme paste it too
Why a set
then i just extend that class to make a command and have methods with the signature CommandResult doSomething() which i add as subcommands
and don't work
And not a map so you don’t have to stream and check name
mye i was thinking about that too
How I can check if Player inGround in PlayerMoveEvent?
if the player is in a block?
The deprecated onGround method still works
As long as you are aware it can be spoofed
if the player is in a block? 😅
ah because you said "in ground"
and I am not asking about this method 😅
Hi i have one question.
If there are tutorial on OpendJDK 16.0.2 and i have OpenJDK 17. is it a huge different in coding ?
no
java JDK 17 have more functions
yes
for example
Not if you are using maven though
im using maven
But gradle and spigot do get a heart attack if you use future java versions
java 17 work with minecraft 1.17 and 1.18 (idk how with older versions but 1.16.5 should work)
you must check it 😅
ok thx
1.16 only supports J16 at most
1.17.x works with jdk16 too
oke I can say onGround 😅
@tardy delta and you can answer me this question? 😅
grass water lava etc?
oh that still exists too
but if you just check if the type != Material.AIR it would work i guess
not wanting to use this method has quite a few drawbacks
why?
dude github copilot is just so op
!Material.isAir() 
owo
is the code for how the ender chest saves stuff avaliable somewhere?
When using the .dropItem method the item flops around, is there a way to make it just appear/drop without flopping around?
What do you mean by "flops around"? Gif or video pls.
World#dropItem instead of World#dropItemNaturally?
i've heard that there isnt really a big difference
I have it spawning directory 1.5 blocks above the lapis block but when it drops it flops around
I could try it
which one are you using now?
world#dropItem
This item looks weird... do you have a plugin that changed vanilla item behavior?
Not tmk
show a gif or video pls
could be a resourcepack too
Ok
I don't have one
Clientside mod
Or just a client
What event do I need to use to not make tnt ignite other tnts? And what even to prevent the exploded blocks from dropping items?
please does anyone has a boolean simplifying cheatsheet?
Yeah, Item Physics was doing that
EntityExplodeEvent -> remove tnt blocks from the block list
thank you
not sure if !a && !b is the same as !(a || b)
You can simplify boolean statements by bringing them in a conjunctive normal form or disjunctive normal form
and then apply a reduction using a Karnaugh-Veitch map.
You should take a looks at boolean algebra.
Yeah I've gotta say, that's a bunch of nonsense to me too 
boolean = true or false

kek
Hey uhm, I wanted to ask how the effect is called that grants knockback resistance
turtle master does but thats not the only thing it does
if you just want knockback resistance i think you have to manipulate attributes
Its an attribute and its called knockback resistance.
ah ty
and what's the default value?
0
turtle master is not an own effect, but ty
great ty
Hm?
do you know if its possible to (easy-ish) serialize a itemStack into a string?
I've been ripping out my hair trying to save a item to a player's PDC for a while now
or more specific a itemStack[] array with length 9
you can turn it into a base64 string
wait how can I change the vaule of that attribute?
or @smoky oak maybe you know
its something along the lines of 'Player.getAttribute(Attribute.KNOCKBAKC_RESISTANCE).set(double)'
There are several ways of (de)serializing an ItemStack to/from a String.
What method you use depends on what dependencies you want to have
on your classpath.
I like the one that uses version agnostic bukkit methods.
This is for just one ItemStack:
public static String itemStackToBase64(final ItemStack item) {
try {
@Cleanup final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@Cleanup final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeObject(item);
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static ItemStack itemStackFromBase64(String base64) {
try {
@Cleanup final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(base64));
@Cleanup final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
return (ItemStack) dataInput.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
ty
ah 7smile7 with an example for base64 way
i mean if it works
the annoying part is that i know there's a internal method that does almost exactly what i want
but i cant find it
@Cleanup kekw
yes MC/bukkit has an internal method that utilizes base64 serializing, however why depend on the server jar, when 7smile7 gave you perfectly working code
This is an example on how to do an array of ItemStacks:
https://gist.github.com/Flo0/deb4ca074a00593349df30e20aec5773
I think it looks cleaner than a bunch of nested "try with resource" or "try catch finally" blocks
does the compiler changes it to a try with resources or what?
I think it compiles to a try catch finally block
Wait... i think it does a bit more even
7smile?
that second code block is dependent on another class
It analyses the code flow and closes the resources on the right position
On several
oeh sick
no like one i dont have access to
and i dont know enough about serialization to reverse engineer that one
Its from snakeyaml. Should be on the craftbukkit classpath i believe
If not then use some other encoder
But im away for now. Gonna get some water supplies because russia just put their nuclear deterrent force at high alert -.-
lol
dumb question probalby not belonging here, but this
https://www.source-code.biz/base64coder/java/Base64Coder.java.txt
which the class is 7smiler's methods use, specifies that it 'may be used under the terms of the following license', does that mean that part of the code (the class) or the entire software has to fall under that license?
ah wait
copyright already ran out
nevermind
hey so I have this array
private ArrayList<String> IsMuted = new ArrayList<>();
then in a different file, I try to access that array
else if (IsMuted.contains(player.getName())) {}
but it says Cannot resolve symbol 'IsMuted'
am I doing something wrong?
its private in that class so ye obviously you cant access it in another class
either set it as public or write a setter/getter method for the array
Super important to strongly encapsulate collections. So dont make it public pls.
^^
so what da HECC do i do
So:
Not public
No setter
No getter
;-;
mutator
wut do me do den
make some method isMuted(UUID) or something
dunno why you're using player names instead of uuid
private final Set<UUID> mutedPlayers = new HashSet<>();
public boolean isMuted(UUID playerID) {
return this.mutedPlayers.contains(playerID);
}
public void setAsMuted(UUID playerID) {
this.mutedPlayers.add(playerID);
}
public void unsetAsMuted(UUID playerID) {
this.mutedPlayers.remove(playerID);
}
Example
can someone tell me a good plugin for login 1.8
online-mode=true
1.8 support was dropped years ago.
Go and search in old forum posts.
ok thanks, I will try that
yeah
mute and unmute would be better names
its still the same issue but now with Cannot resolve method IsPlayerMuted
well is that the method?
You my friend, skipped learning the very basics of java.
Spigot is not beginner friendly.
?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.
yeah
obviously not
No offense. Actual advise.
I actually did learn the basics, I just have very very really very bad memory
at least we have a command for it
We also need ?npe tho