#help-development
1 messages · Page 1896 of 1
Nope
homes:<UUID>
i have something that loads from the database every 100 ms, but only if a request is made
and saves to the database every 200 ms when a write is made to the runtime data
Ah, so it’s just assumed to be playerData if it has a uuid
Not really.
Data bound to worlds
worlddatamanager:<UUID>
i was thinking of doing like an accumulative iteration that it goes like foo and then foo.bar and then foo.bar.amogus, which then stores the values for those nodes if they define any behaviour (set any permission value for themselves or their children, or define content)
Depends how you structure your data. I personally have every player bound data in one class PlayerData
So i will also just have one file per player.
But you can also have multiple Manager classes like
HomeManager containing a Map<UUID, HomesDomain>
or
QuestManager containing a Map<UUID, QuestDomain>
Then you will either have them all in one File:
homemanager:data
or one file per player:
homes:<UUID>
Heyo, wasn't there a way to reset the current special formatting in a CompontentBuilder - such as hover/click events etc so that when I call append() on it again, none of the previous formatting applies?
ah nvm reset() it is lol
How would I make a player glow with NMS in 1.18
why would you want to use nms for that
So I could do it for specific players
You can tho
yea, you can
How
Really?
player#setGlowing
No, only 1/12th of the time, it's a prank by spigot
?
It's a joke, it does work lol
i think he meant to show glowing for specific players only
oh
Yeah nah best of luck
Send a metadata packet with glowing flag then
hmm
And listen to outgoing metadata packets
We need server.sendEntityChange
EntityMeta packet
Ah alright
Guys, I have someone who sais that UUID's won't exist below 1.7. Is that true?
Pls ping me
@lost matrix @blazing scarab
public void setGlowing(Player player, Player... players) {
Entity handle = ((CraftPlayer) player).getHandle();
DataWatcher dw = new DataWatcher(handle);
dw.a(new DataWatcherObject<>(0, DataWatcherRegistry.a), (byte)0x40);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(player.getEntityId(), dw, true);
for (Player glow: players) {
((CraftPlayer) glow).getHandle().b.a(packet);
}
}``` In theory this would work?
I believe so, yes
I did decompile 1.5, and I saw a method Entity.getUniqueId()
For lower versions it would look like
public void setGlowing(Player player, Player... players) {
Entity handle = ((CraftPlayer) player).getHandle();
DataWatcher dw = handle.getDataWatcher();
dw.set(new DataWatcherObject<>(0, DataWatcherRegistry.a), (byte)0x40);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(player.getEntityId(), dw, true);
for (Player glow: players) {
((CraftPlayer) glow).getHandle().playerConnection.sendPacket(packet);
}
}```
Hi. I am coming across this issue where:
-
I write something to my custom config file. If I open it with a text reader app, everything is there as expected.
-
When a player types a command /getinformation, I use FileConfiguration#get(path) and send it to a player's chat. However, the message sent to the player says "null" where there should be values from the config.
-
Interestingly, when I "/reload confirm" the server, and the player runs /getinformation again, the player receives the values they are supposed to receive.
Why does it say null for the values, and what about /reload confirm fixes it?
getString not get, or the respective object type getInt getDouble etc.
or you are doing something wrong about the config
thank you!!!
Unfortunately, it's still not working. Is there some function I must call before calling getString in order to "load" the proper config file?
Im not sure why it says null when I can literally open the config file using a text editor to see that everything is there as expected
And on top of that, /reload confirm somehow fixes the issue
Dont read configs on runtime.
Read them once the server starts and store the content in properly named variables.
You can add null checks right there to make sure the config is valid
Never use the reload command. Its unsupported and often causes unexpected behavior.
You can also just read them from the YamlConfiguration instance
Make a reload() method which you can then call to store the necessary information in fields, preferably in an easy to use class, a simple example:
public class MyConfiguration {
public static String a;
public static int b;
// ...
public static void load(FileConfiguration config) {
config
a = config.getString("a");
b = config.getInt ("b");
}
public static void save(FileConfiguration config) {
config.setString("a", a);
config.setInt ("b", b);
}
}
and then in your plugin class call MyConfiguration.load(this.getConfig()) and MyConfiguration.save(this.getConfig())
when you need them to load and save
i forgot to add save() to save
Public fields!!!!
Use a library like DazzleConf if you want type-safe configs
all you have to do in order to have a config for your plugin is add config.yml in the resources folder of your project and add getConfig().options().copyDefaults(true); saveConfig();
to your onEnable method
true
but you may want to store data from the configuration into fields
especially with more complex objects
you might want to 'compile' them into java objects
yo guys, i was making a rtp function for my plugin, but i need a cooldown for it
i tried, but it doesnt work properly
public RandomTpEvent(me.takao.twcore.TWCore TWCore) {
this.TWCore = TWCore;
}
ArrayList<String> rtpCooldown = new ArrayList<>();
@EventHandler
public void onMove(PlayerMoveEvent e){
Player p = e.getPlayer();
if(rtpCooldown.contains(p.getName())){
p.sendMessage("on cooldown");
}else{
if(playerOnRTPRegion(p)){
randomTP(p);
rtpCooldown.add(p.getName());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TWCore, new BukkitRunnable() {
@Override
public void run() {
rtpCooldown.remove(p.getName());
}
}, 100);
}
}
}```
yes alright nice i know
you want them to teleport to a random location when they move?
no so, i made a region
and when they go in that region, they get teleported to a random location
looks too complicated and not needed
super simple and lightweight
Idk i hate string keys spaghetti
/**
* The delay you want to have in milliseconds.
*/
final static long delayMs = 1000; // 1s
/**
* Stores the last teleport time of all players.
*/
final static HashMap<UUID, Long> times = new HashMap<>();
/* Some method, in your case `onMove` */ {
// check if the time between the last teleport and now
// is greater than the delay (has enough time passed)
if (System.currentTimeMillis() - times.getOrDefault(p.getUniqueId(), 0) < delayMs) {
// they are on a cooldown
} else {
// put their new time
times.put(p.getUniqueId(), System.currentTimeMillis());
}
}
@frigid rock
i added comments
read them
dazzeconf is quite cool yeah
yeah i fixed that
wdym?
Hello! Is there a way for a plugin to detect which part players get hit in? For example like what leg, what arm etc.
ray tracing
Your map does not contain a value for this key.
Which means it returns a
Long with the value null
unboxing this to a long results in a NPE
still not working :/
got it thanks
Hmm. But how would I still detect what part of the other player the raytrace hits?
the "timer" doesnt end
Vector math
Show me the code again
okk
final static long delayMs = 1000;
final static HashMap<String, Long> times = new HashMap<>();
@EventHandler
public void onMove(PlayerMoveEvent e){
Player p = e.getPlayer();
if(System.currentTimeMillis() - times.getOrDefault(p.getName(), 0L) < delayMs){
p.sendMessage("on cooldown");
} else{
if(playerOnRTPRegion(p)) {
randomTP(p);
}
times.put(p.getName(), System.currentTimeMillis());
}
If they aren’t in the map that default of 0 will cause issues
You need to put the player only if they are in the region
Listeners should be singletons which means the Map can be non-static.
Dont use getOrDefault. Use computeIfAbsent
Doesn’t computeIfAbsent add to the map
Move the times.put inside the if(playerInRegion) { ... }
final static long delayMs = 1000;
final static HashMap<String, Long> times = new HashMap<>();
@EventHandler
public void onMove(PlayerMoveEvent e){
Player p = e.getPlayer();
if(playerOnRTPRegion(p)){
if(System.currentTimeMillis() - times.computeIfAbsent(p.getName(), 0L) < delayMs){
p.sendMessage("on cooldown");
} else{
randomTP(p);
}
times.put(p.getName(), System.currentTimeMillis());
}
}```
like this?
That’s not how computeIfAbsent works
No, go back to the previous version
yeah hang on
And all you have to do is put the times.put(...) command inside of the if statement checking if they are in the region
Because otherwise the cooldown reset whenever they move, even if they are not in the region
Yeah
private static final long TP_COOL_DOWN = 1000;
private final Map<UUID, Long> lastTeleportTimestamps = new HashMap<>();
@EventHandler
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!isInRegion(player)) {
return;
}
UUID playerID = player.getUniqueId();
long lastTeleport = lastTeleportTimestamps.getOrDefault(playerID, 0L);
long timePassedSinceLastTeleport = System.currentTimeMillis() - lastTeleport;
if (timePassedSinceLastTeleport < TP_COOL_DOWN) {
return;
}
tpPlayer(player);
}
The very first check should be if a player is in a region.
In your tpPlayer() method you should put
lastTeleportTimestamps.put(playerID, System.currentTimeMillis());
Mhm
Ok I know why I haven't got into any issues without knowing that
I always use merge :p
hey why doesnt it detect my tab completer?
The file exists, ive never had this issue before
invalidate caches and restart
how can I load a world from a different folder than the main directory?
i am working on a plugin that requires maps and i have a folder for the maps but i can't find a way to load worlds from the maps folder
Thank you, that fixed it. Is there any reason why that would happen?
ahh okay, glad that I know about it now and that you knew how to fix it
thank you so much
Eclipse has teh exact same issue, but not as often
ah that mightve been the issue I was having then, I ended up switching to intelij cuz of that issue. I didnt ask about it
but never the less im happy with intelij
I never had that with eclipse in the 5 years I've been using that
it's quite common with intellij tho
I have, but its extremely rare with Eclipse
Any of you guys know a way to save a list of blockstates to a file and then read them from that file?
?
the command where you type learn java which brings up some links
i forgot the prefix
its ?
!help
?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.
ah thnx
np
Is this for me
they wanted to get them links
anythings serializable if you break it hard enough
just punch at it till it works
There seems to be a "getAsString" method which is defined as a serialized string
lol
@restive mango this might help, you can store the serialized strings in a list then reconstruct the blockdata using the method linked in this method I posed
Is there something I can make that can catch and "IndexOutOfBoundsException" issues?
check the length of arrays list you use (?
just dont
Ew blanket error handling
catch(Throwable ignored) {} 😳
Best error handling
am I being dumb? A new player object should be created every time someone relogs, right?
yes
oh bruh I think it's because I disabled online mode for my local server when the auth servers went down
ty
I have a class that takes inventories. If I make an instance of the class, and create the inventory with the instance, and set the boolean in the class that stores whether you can close the inventory to false, how can I then in a listener (which is in another class ) access this boolean and check if it is this instance that I used to create the inventory?
i have created isClosable() but when i want to get the bool how i make sure, that is it of that instance i created it?
Anyone know what could be causing this error:
Caused by: java.lang.IllegalStateException: Entity EntityWitherSkull['Wither Skull'/1741, uuid='9b25fe78-a9cb-42e4-b5d8-f3e20cee011e', l='ServerLevel[world]', x=29988909.40, y=565.60, z=29943732.44, cpos=[1874306, 1871483], tl=0, v=false] is not in the region
Looks like a corrupted entity
?paste send full error
//spigot code
//player.spigot().sendMessage()
/** @deprecated */
@Deprecated
public void sendMessage(@NotNull BaseComponent... components) {
throw new UnsupportedOperationException("Not supported yet.");
}
please tell me what to replace it with? and will it work on 1.17?
why and where do you use this ?
Not deprecated in Spigot
hmmm i saw an problem like this already .... what is the maxY of your world ?
for an awesome chat with graphic avatars in the chat . In combination with Click-Event and Hover-Event
the witherskull is at y=565 which may cause this
you could try to update your server version
so your editing the server jar ?
Thank God. You don't have to rewrite the plugin. I just saw such an intelij decompiler and panicked a little :
Its deprecated in Paper because they want you to use Adventure components
paper moment
no, chat avatars are just a plugin. In general, yes - I injected it into the Paper Spring framework by fan
Already on 1.18
Not sure. Let me ask the owner.
there are multiple 1.18.1 versions O.o you should always update to the newest
the Paper collector is so moody .. it is easier to manually replace classes.
@ancient plank I think I might have already tried this, but I’ll double check. I don’t think it’s serializable but default, so I was wondering if there’s like… some kind of constructor that we know of which can do it
this bug i saw was caused by using BlockPopulators ...
colorful gigachad
That's too logical for people to be doing that
i accidentally turned mention off
That's too good of an idea.
Thanks for the explanation. Can you tell me the name of the class, please?
public class InventoryPermissionManager {
private static final Map<Inventory, Boolean> INVENTORIES = new HashMap<>();
/*
Default: true
*/
public static boolean canClose(Inventory i) {
return Optional.ofNullable(INVENTORIES.get(i)).orElse(true);
}
public static void setCanClose(Inventory i, boolean canClose) {
INVENTORIES.put(i, canClose);
}
}
I don't use paper
Component smh
yeah if this doesn't work, I'm not certain if there's any in-built solutions. Might just have to serialize and de-serialize it yourself using something like json
I see. I'm going to Google
thanks
I'd suggest you to use a weak map
so inventories could be actually garbage collected with no worries ;p
yeah, It's pretty handy when you want to store your own metadata of objects without worrying of their references
java.util.WeakHashMap
🆘 STATIC MUTABLE STATE 🆘
i preferred if you created an inventorymanager class and just passed that into the listener class
Needless to say that map is not necessary here. Just use a set LoL
League of Legends
depends, i mean if they still want the inventory to be in the map and just have some sorta on/off mode for each one and they dont want to keep readding it
or smthing
"laughing out loud"
lol
Don't be aftaid of putting things into two or three lines, constructing a new Optional instance, only to throw it away a ns later, is a bad habit
or .getOrDefault
Or that
Kinda need help with Type Parameters...
if i have this interface and want T to be List<String>.... how would that look like if i dont want only T to be List :?
Wym?
interface KeysResult extends Result<List<String>> {}
<String> will not work
yes ^^
So what’s the issue?
^
I mean if I understood you correctly you might want a KeysResult<T> extends Result<List<T>> (so you can constructor any type of list later)
this doesnt work either
It does
do u have the right List imported?
what about List<Object>
List<Object> is just a type and then he wouldn’t be able to pass List<String> etc
(Not at compile time if List<Object> was passed)
List<?>
oh wait maybe fixed
glad u guys understood his issue cuz i dont
well i am just guessing too

kinda worked to use E instead of T
that part does not matter
I mean the name of a type parameter can be whatever you want ^
That one checkeframework annotation called T
🥲
yes
hmm

no shit that was really annoying with C annotation import while i did some generic stuff
Why the fuck checker framework needs an annotation to define temperature
p.setVelocity(p.getLocation().getDirection().multiply(3).setY(2)); i'm trying to bounce player in direction where he looks, i also want to player fly up - this code doesn't do this
Is there a way to check player's first join date using Spigot API?
is there a way, that the InventoryCloseEvent triggers only one and not a trillion times when closing an inventory
?
just register it only 1 time
i have it but when i close an inventory the listener calls the methon a bunch of times
Wdym it only fires once when and inventory closes?
an*
?jd for self
declaration: package: org.bukkit, interface: OfflinePlayer
ty
Are you checking to make sure it’s your inventory? Cause if not, the event will fire for every single inventory closing.
yes i have an if for the inventoryholder
I don’t think there is a built in method, so you’d have to keep track of that yourself. If you need the first join date of existing players, you could check the file creation date for a player in the world folder.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/OfflinePlayer.html#getFirstPlayed() as answered @buoyant viper
Well I’ll be.
might be a new-ish method
nvm i think i am just trippin
oh jeez its existed since 2011
Why does it throws me an java.util.ConcurrentModificationException?:
private void updateData() {
Iterator<FrienPassPlayer> iterator = cachedOnlinePlayers.iterator();
while (iterator.hasNext()) {
FrienPassPlayer entry = iterator.next(); // exception line
if(entry.getUuid().equals(uuid)) {
iterator.remove();
cachedOnlinePlayers.add(this);
}
}
}
whats cachedOnlinePlayers?
private static final List<FrienPassPlayer> cachedOnlinePlayers = new ArrayList<>();
use:
ListIterator<E> it = blah.listIterator();
then just
it.add(blah);
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/ListIterator.html here if you want a better reference
Is there any chance to pay at spigot using paysafecard tho?
Where has the dog gone @ivory sleet
sadly I don't have any pics of him on my new pc and phone is ded
same exception
have a good time
same 🙂
hmm
Anyone have any experience with LibsDisguises?
Or disguising an entity as a player skin
setDamage
@ivory sleet were you hacked or smth ? O.O
Yeah the no dog pfp is depressing
why is there a red profile image
oh well no not hacked
Hi there so I am doing some testing for backpack plugin
I am spawning armorstand
on top of player
and then using custom item model as head on that armorstand
so armorstand is passenger
question is would this be possible with packets
so it would be client side only
and will that armorstand ride player if it is spawned with packets only
I have a yml file that contains:
effects:
speed:
duration: 10
level: 2
jump:
duration: 10
level: 3
how can I get all properties (speed, jump) of the "effects"?
Can you get somewhere a list with all ItemStacks types in it?
yes of course
question is will that armorstand spawned as passenger thru packet follow player
or would I need to update it all the time
it should as long as it is the passengar it will automatically move
you maybe able to point me
to some tutorial
EntityArmorStand stand = new EntityArmorStand(s);
stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
stand.setCustomName(name);
stand.setCustomNameVisible(true);
stand.setGravity(true);
stand.setSmall(true);
stand.setInvisible(true);
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
I have found this on forum but that will create
so it already spawns ?
this code looks like it already should spawn an armorstand but with not special data ...
That is some example from forum
if you dont want to use packets and instead API you can also use
Player#hideEntity() for each player that should not see htis
well plan is for every one to see it
xd
then.... why use packets ?
preformance
and u don't deal with really entity
at least I was thinking so
but this example ```WorldServer s = ((CraftWorld)p.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
stand.setCustomName(name);
stand.setCustomNameVisible(true);
stand.setGravity(true);
stand.setSmall(true);
stand.setInvisible(true);```
still need to create
armor stand
so I am again I think in same position
hmmm you can set persist to false for bukkit entity and you dont have to deal with save/load things ....
using packets will break every update
and it might be fast very bad performance too
if you use Entity#setPersistent(false) or smth like that the entity will not remain in the world ...
like, the armoststand is, like, notging for the server
intresting
Yoy will not recieve a huge performance boost from packets
where can i find a guide on how to contribute to spigot? (spigot, bukkit & craftbukkit)
oh thanks
where can i find the CLA page
on jira
because i need that to get access to the repositories
i think
Is there any chance i could pay on spigot using paysafecard?
spigot is free O.o
i think they mean buying plugins on spigot
although they are in the wrong channel then
if i have a itemstack item and i want it to send a cmd everything someone hits a player with it, can i do that without raytracing?
EntityDamageByEntityEvent
does anyone has a kinda good chatchannel api?
im creating things on my own and i want to take a look at some examples
Does anyone know what jdbc connector spigot 1.8.8 uses?
Hexaoxide/Carbon
i'll take a look at that thanks
also another question, is there something better to save data in the player's metadata instead of the pdc?
It doesnt persist
i saw supervanish using it to save the vanished state for the player, but for what is it used?
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
is it possible to check if a class exists using just a string
(but searching in one package)
Class.forName
Then you're either not importing Class, or commandname isn't a String
whats the import for that
The method definitely does exist and has existed since the beginning of Java ;p
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html#forName(java.lang.String)
Your IDE should auto import it
Actually, it's even in java.lang. No need to import
?paste
Invalidate caches and restart
FeelsIJMan
https://paste.md-5.net/qufatatima.java does anyone know why the giant doesnt spawn in a -5x5 radius even though i have made it 100% chance every tick
Giants don't even render anymore, right?
Since like 1.12 or something?
Or am I misremembering
oh fr?
They do
Maybe that was a bug at one point 
private void addCmd(String commandname) {
this.getCommand(commandname).setExecutor(new Class.forName(commandname));
}
``` btw heres the full function thats supposed to handle it, it might make it clear whats wrong with full context
ohh
Though that won't work. You need an instance of that class, not the Class
You might as well just pass in the CommandExecutor instance 😛
i am just trying to make it more easy to add a new command here
what would i do to fix it
its not a good idea as you would also be breaking naming convention of classes
You’ll need to do some more reflection stuff to make that work
so yeah giants still exist i just searched it up
Just give them AI
lol

ill just use the normal command adding method for now
but fr does anyone know why my code isnt making the giant spawn?
I have a yml file that contains:
effects:
speed:
duration: 10
level: 2
jump:
duration: 10
level: 3
how can I get all properties (speed, jump) of the "effects"?
for example in DeluxeMenus there are items: and It gets everything inside items: and adds them to menu
Tried a for loop and looping through the effects list?
@ancient plank yeah I’ve thought about Json but I’ve never used it before so I dunno how to build a constructor
I want to loop through these but is effects a list?
time to learn :)
how do i fix this and do i need to? Unboxing of 'data.get(new NamespacedKey(Main.instance, "key"), PersistentDataType.INTEGER)' may produce 'NullPointerException'
@ancient plank imma just use world edit roflmao
xd
I am already using world edit for it
It’s just that I want a more elegant system instead of defining a cube
Like… I wish there was a way to define a precise set of coordinates for worldedit
Oh well
//set <x,y,z>?
@balmy gale can you do that with the worldedit Java interface Lul
It doesn’t have any docs that are good
ok
😔
It makes me sad
me too
Make your own library call it "world edit but if it was actually good"
Whats the problem with we?
Know any good documentation for it?
Yeah thats what the page leads to
Did you want to do something that isnt documented there?
Question if this design pattern makes sense for developers.
I am planning to work on a quest plugin system essentially where players have quests. I was planning to do the following:
Have a QuestManager for each player so if certain events happen it can manage that users quest, if a quest is complete, etc.
In the quest manager have a List of Quests from an interface so new quests can be made. IQuest then for example KillPlayerQuest.
Then was going to have like a Reward for each quest. (e.g. Money, Rank)
So like Maybe i should make a IQuestReward? And have like RewardMoney, RewardRank, etc?
Are there any design methods I should look into for this? Am i on the right track? Any Suggestions
I mean that just sounds like architecture planning, like if we talk design patterns you might wanna look into the structural ones
Yeah im aware of factory etc
Anyways I rarely plan ahead, since it’s really hard to write the most suitable clean code architecture before you get it to work
Usually the semantic refactors are done post getting something to work
I was just thinking of the properties of what it needs before i write it
so i don't have like a god class
appreciate it thx
Anyways I have become very dependent on facade patterns
So you have one class which is the face for a very complex implementation (usually encapsulating several other components)
Yeah that was kinda the Idea
Have like a facade class called QuestManagerController that would make all the interacts for each player
Hmm yeah maybe
im just bouncing ideas in my head nothing serious lol
Anyways what can I say? Prefer composition to inheritance. And make it decoupled and modular (SoC)
Hi there 🙂 i'm trying to do a plugin (1.18.1) where i wan't to us the .serialize() method on an ItemStack. But right there is my problem so if this ItemStack have some enchantments it throws me a NotSerializeException.
I never worked bevore with this method and also didn't tried in a earlier version. Do somebody knows something about if this is a bug or should i do my own method to serialize ItemStacks with enchantments ?
@loud garden I have a sample Serializer i've used previously not long ago if u want a code snippet ill take a look about enchants though one moment.
@loud garden how are you serializing the data?
Well im using the .serialize method on the ItemStack its selfe wich gives mi a hashmap<String,Object>
this is a snippet of how you should serialize it
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(items.length);
for (ItemStack item : items) {
if (item != null) {
Bukkit.getLogger().info(item.toString());
dataOutput.writeObject(item.serialize());
} else {
dataOutput.writeObject(null);
}
}
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
i encoded it with like base64
Well i will try that tomorrow foe sure :) need to go to sleep 😂. Thanks for your advice and help ^-^
No problem i have a class that worked for serialization if u need 1
I will come back to it if i can't get it done 😁
hey how can I make is so that when a player in survival places down a spawner it turns into the give spawner name rather than a pig?
cast the blockState to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/CreatureSpawner.html
alright
Thank you. What if I want to 1. start the server 2. update the config 3. read from the config, in that order? Is this not possible?
what is the param type if i want to pass a class instance (like if i want to run a function like method(new Class(), "arg1", "arg2"))
If it is not possible, what other persistent data storage method is there? For instance, how does /sethome store and read the coordinates?
pretty sure you can serialize locations in yaml configs
Thank you. What does this mean?
it means you can pass a location object through the YamlConfiguration and end up with this in the config:
homeName:
location:
==: org.bukkit.Location
world: world
x: 100.0
y: 200.0
z: 300.0
pitch: 500.0
yaw: 400.0```
Oh wow thanks for that. I didnt know this and was storing everything in strings lol
if as 7smile7 said, you should never read from config at runtime?
i think you misunderstood this
or if what you're saying is true, he's wrong
how else would you grab data if you couldn't read from configs during runtime
unless they're just a fan of caching everything when the plugin loads
I wouldn’t load the file after startup
But once it’s loaded it’s just reading from a map
well
actually nvmd you right
if a file changes and you read data from a version of the file that was loaded when the server started up, will the data be updated?
Btw thanks for the help but it somehow got fixed!
Somehow, passing the Location through YAML fixed it. So I must've been doing the serializations wrong
Nothing automatically updates. If you want the data after a file is changed you need to read the config in again.
Once read a FileConfiguration exists in memory only.
so you would only load the file once, but load the YamlConfiguration anytime you need to call data from the file?
Also another question, for messages like
================================
Hello player, have a nice day
is there a way to determine how many = signs I need in order to perfectly fit into a player's chat width settings? so that they dont end up with a message like
=====
=====
Hello Pl
ayer, ha
ve a nice
day =======
i think there is a chat width thing
ty!
since you can grab it with skript
Usually you want to read the File into a YamlConfiguration once when the plugin is enabled.
Then store all data from this YamlConfiguration in proper data structures.
I recommend using my custom file handler
tldr, no
chat width is a client setting which doesnt get sent to the server
Here you have it
Wally
How do you do to appear your up time on discord?
On Mines intellij doesnt appear
IJ Plugin
Well you’re offline
can anyone help me setup my minecraft network? DM me if you can help? (I have servers just don't know how to use bungeecord)
Hey
any one could tell me how would I avoid
player hitting armor stand
which is passenger
problem is survival players can't brake block
because they have armorstand riding them
and
I am using armor stands
for custom backpack
I saw it on other server they use armorstand
but player can normally hit blocks
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Ok
Set the armorstand as a marker
well I got another one
on top of it
pa.setMarker(true);
when I do that
one from top falls down
so miny one will fall down dismount
this is problem which I got
there is no mounting point
if someone can help please ping me
off for today lost my head with this 😂 😭
hey guys- ik this isn't exactly spigot, but is there any way that I could delete a file that starts with the same name as another file up to a certain character? this might not be the best way to do it; i'm actually trying to replace an old version file automatically, as just downloading it won't work due to differing versions.
ex: downloading ultrasponge-1.10 would not replace ultrasponge-1.0
Any help?
i don't want to use hashes as that is tooo slow and the names are already pretty much the same
String#startsWith()?
shell file lmao, forgot to say that 🤦♂️
any api's to easily communicate between servers on a bungeecord network? (besides bungeecord messaging channels)
Redis
preferably without another program running
bungee messaging the best you got
alright
mysql messaging also works, idk if a mysql database is considered another program?
redis would probs be better though if its just messaging
yea redis isn't heavy on connections either
RadioScanner
I will have a look
You already asked in HelpChat? 
🥜 speed
If you are making string constants like prefixes for messages, is it better to store them in a class or enum?
ah ok
Is there anyway that I can make it so that a player can connect 2 fences together
So far I only got it to do this by putting in invisible bees, but is there an easier way to do it
change bees to bats 😎
You cant lead bats
You can probably force a lead onto them
Hey so I'm trying to put a lead on a slime, why does this not make the lead attach to me?
ah nevermind needed to delay it
of all the bad code habits that exist
i care the least about this one
You're asking in the wrong channel. Look at #help-server
Can I get player's Inventory with list?
What
Into a list? Sure just call arrays.asList on the getContents array
Do note that will make an immutable list tho
Its not immutable but yea
Fine, fixed sized
[ItemStack{SAND x 64}, ItemStack{DIRT x 4}, ItemStack{WOODEN_SWORD x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=29}}, ItemStack{BEEF x 4}, ItemStack{LEATHER x 2}, ItemStack{SPRUCE_LOG x 1}, ItemStack{GRASS_BLOCK x 64}, ItemStack{SPRUCE_PLANKS x 12}, ItemStack{SPRUCE_PLANKS x 64}, ItemStack{GRASS_BLOCK x 64}, ItemStack{GRASS_BLOCK x 64}, ItemStack{GRASS_BLOCK x 64}, ItemStack{GRASS_BLOCK x 64}, ItemStack{GRASS_BLOCK x 64}, ItemStack{GRASS_BLOCK x 16}, ItemStack{SAND x 41}, null, null, null, ItemStack{STICK x 3}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
Can I turn it to jsonArray
"item":"SAND",
"amount":"64"
},
{
"item":"GRASS_BLOCK",
"amount":"64"
}...```
oh wait how would you implement this?
wouldn't you have to keep spamming read requests against the redis server or is there some sort of stream method?
https://aws.amazon.com/redis/Redis_Streams/ that?
ItemStack[] itemStacks=event.getPlayer().getInventory().getContents();
JsonArray playerItem = new JsonArray();
for (ItemStack itemStack1 : itemStacks) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("Type", String.valueOf(itemStack1.getType()));
jsonObject.addProperty("Amount", itemStack1.getAmount());
playerItem.add(jsonObject);
}
System.out.println(playerItem);
This is error
Is it possible to make the piglins attract to a different block like Dried Kelp Block ig?
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "itemStack1" is null
I mean it tells you
itemstack is null do a null check for it and do something if its null
ItemStack[] itemStacks=event.getPlayer().getInventory().getContents();
JsonArray playerItem = new JsonArray();
for (ItemStack itemStack1 : itemStacks) {
if(itemStack1==null) return;
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("item",itemStack1.getType().name());
jsonObject.addProperty("amount", itemStack1.getAmount());
playerItem.add(jsonObject);
}
System.out.println(playerItem);
This didn't out print anything
GG
Paper 
Which event is the player crouching?
PlayerToggleSneakEvent
Thanks
Which event to use when the item on the player changes
hey is it possible to make it so that a crafting recipe will only care about every part of an item minus the name? So like it will care about a special tag, the lore, the enchant, but will only check if the name contains the important part
No
dam that sucks
Is it possible to only check if the item has the same namespace key and not care about the names of stuff? Just so I can make the recipe pop up in their recipe book as not red
Use the prepare craft item event
I got it to give me the item, I just didnt want it to be red in the crafting book
onlything would be packets or smt huh
no
is getting a value from a player's persistent data container a heavy operation?
Or idk
Maybe you'e have to do some hackery.. Resending recipes based on materials you have in inventory
no
it is efficiently cached
What would we do without maps
ok
be sad
crying in my bed
what args do i use with spawnparticle to prevent particle motion?
You can change speed
They have an extra double that normally controls speed
However the client may still disregard that
okay
are you saying that optifine doesnt hide the player?
That's right, only they can see it and others can't see it
you're sure it's not lunar doing it?
i tried using optifine and it's similar to lunar
Any one can tell me how to prevent armorstand which is passenger to block player interaction
If I make it marker
that helps
but I got one more armor stand on top of current one
and he falls down then
is I make frist armorstand marker
What are you making? @wary harness
like back pack plugin
And the back pack is visually on an armorstand, attached to a player?
yep
like there is 2 armorstands
custom item is on second one
on top
but I can hit first one
And currently those invisible armorstands interrupt player interaction (right & left-clicking)?
if I make first one passenger top one falls of
yep
first one is in player face
xd
let me show
sec
The solution is
armorStand.setMarker(true);
btw @wary harness
like I said there is 2 armor stand
on top of player
riding each other
Yeah?
if you make first one on top of player marker
top one will fall of
it wont stay
riding armor stand 1
A marker can't be a passenger?
But how can the first one work then?
Maybe try adding a delay in there?
Between making them markers
What?
armor stand as passinager a bit later
Schedule a runnable yeah
will give it a try
this is result
they are in side each other
now
Hello, I have a question real quick, is there a difference between Map<>() map = new HashMap<>(); and HashMap<>() map = new HashMap<>()?
Map is preferred
No need to explicitly bind map to implementation
Yep I use Map but I just wanna know the difference between them, why is it preferred?
Unless you need type specific methods
Basically it makes it easy to swap the implementation
Oh that makes sense, thank you
hey so
how can I strip colors
and have them inside the string?
so like ChatColor.GREEN would show as &2 or smth
You would need to manually replace them afaik
There is only a way to translate to color codes and remove them entirely
yeah but how do i get those values
i meant like
uh
yk uh
convert the display name to a string with colour codes
§ is the color character used
You can probably just replace it with & via string.replace
Did you set the meta back after
um sorry is there a way I can get the data type from a namespace key in a pdc
You can get them with just looping all persistendatatypes ... Or just guessing what it could be
Create an array of PersistentDataTypes
ohh
Or this one if you want to use it
im guessing it would return null if the data type is wrong?
Think sk
Don't tell md5
Heh
he doesnt, spigot requires it
you got a stacktrace for us?
I think it is not static ?
public *static* HanderList...
Did you look at some other classes?
he did everything right
That looks consistent with my event class
They have that as well
you need both. a non static and a static getter
yeah he has that too
he has one
Then that error should not happen
There isn't a way to set the size or title of Inventory-s without creating a new one, right?
no
at least i dont think so
Not really. You can play around with packets but its still sending a new container
not sure about that
Uh you sure the code is up to date with what you're running
but that will not modify the container
and as smile said its still sending a new one
How can I spawn a player using nms?
Packets
So I can't spawn a player as a mob?
No
what would be the best way of storing a mailbox for a player, so when they log in, they get sent all the messages in it (like buycraft package stuff or punishments), I was thinking of saving a db table with the uuid and a json serialized version of a basecomponent, but idk
You can just save strings if you don’t need any fancy formatting
does anyone has a usermanager class to load users from a database where i can take a look at?
@tardy delta what are you looking for in particular?
well my users are like player wrappers with additional data and i'm looking for a good way to save and load them from db
in an async way
save a list of strings with for example color codes?
the way I do it is when they join, I run the data-getting on async and fire a JoinEvent when the player gets in with that data, which means sometimes the player gets in before their data is loaded depending on your db solution. As for bans or vital login data, I get the data async but hold their login until I get a response, if it times out it lets them in anyway
are you looking for a description or methodology (code)
some of them have hover and click events ;-;
oh beh
I would load the data earlier
Maybe the async prelogin event
Which is even already async
Yes
Well, you can do the calls normally
It’s sync to that thread, but async to the main thread
Just be careful using the API from said thread
depends what data you're loading though and how much, if you've got something that blocks logins, you dont want it loading everything then it just disappearing but otherwise, the asyncplayerloginevent is better
i'm more looking for a design
what db solution are you using
mysql
things like this looked interesting to me buts thats json obviously
https://github.com/Hexaoxide/Carbon/blob/d7d560e14482b4ad9ae8f8b1ea3f88df3a6267d1/common/src/main/java/net/draycia/carbon/common/users/JSONUserManager.java#L124
ew, I can't really help you there not too sure if my method works with mysql
thats a yaml?
`The found tag instance cannot store String as it is a NBTTagDouble
its json
json, yaml, yml pAH
Well, you can use reflection to get the map..
reflection..
How can I add attributes in item with original attributes
What version
1.17.1
Welp, rip
yeah no clue how to do that
You’ll have to use NMS or keep a map of the default attributes
the default attributes are not show currently?
I can do it if I use nms?
Yes
how to
You need to manually add the default attribute and then add your custom ones
Oh
imma just surround it with a try/catch
isnt there a way to check the type?
Does anyone use the Spigot WebAPI to read out the buyers? Does anyone know or has an example code.
nop
I mean I only use 2 types so if its not one type it will throw an exception so it will just be the other type
I do not recommend using try catch as flow control
lmao someone wrote return()
return(return(return()))
well with an object in it
https://paste.md-5.net/uwufuyidok.xml POM.XML --> EntityPlayer is not found, what am I doing wrong here?
Did ya run buildtools with --remapped
yes
- did u run BuildTools
- i think spigot means u dont also need spigot-api
why cant you use #has(NamespacedKey, PersistentDataType<T, Z>)
@fervent gate Are you using intellij? You'll have to right click the project and maven -> reload project
oh wait isnt it ServerPlayer not EntityPlayer
Did that already.
Probably
EntityPlayer was the spigot mapping I assume
It should be ServerPlayer
Thx
U can check class names here https://nms.screamingsandals.org/
Quick question how can I remove smth from the ram
what
Java is a garbage language, deal with it

Ur a garbage language
wowowow
<3
it's true
^
u literally just pop up out of nowhere wtf
imagine having to deal with malloc and be a pro
i mean you did say garbage collected java
god i fucking hate malloc
every time i try to use it i still end up with garbled data even when im SURE i overwrote it
so i just use calloc instead
What the hell is a memory allocation
Is this something I’m too garbage collected to understand
hell
must use to get bragging rights
Use assembly if you want those
public void method() {
try {
//code go here
} catch (Throwable ignored) {
}
}```
how to do a code without bugs and erros
I’m making a spigot fork that wraps the entire server in that
by fixing it
fair
meant that
I know this is from 12 hours ago, but I prefer to use pub/static/final for constants that are just strings
if(exception) dont();
except the bugs will still be present, or even worse without a fallback haha
Make sure that there's no hard reference of your instance in the application
java will remove it automatically for you
Can you change the plugin version in intelliJ, is that just changing things in the POM?
plugin.yml should be the final say, but yea, you can reference the project's version via ${project.version} in plugin.yml to refer to the project's version you set in pom.xml
Using the $project.version in plugin.yml
I don't see the MC version in the pom.xml, what should I actually change there?
Yea, I can't seem to find that
?paste the Pom
🥴
<version>1.0-SNAPSHOT</version>
line 9
That is the plugin version, but not the MC version,
I want to change it from 1.12 to 1.17
api-version
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Change that too
Wrong message
Yea, ofc
bukkit api 
Ikr
changed it to spigot
Don’t forget to change org.bukkit as well
n the sad truth is that spigot isnt the baseline
ungodly people still using craftbukkit
I don't, just default generated
eh i meant servers
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Does anyone know how to fix this?
Its my own jda plugin


