#help-development
1 messages · Page 399 of 1
Just because it works does not mean it's a good way of doing it
Because extending Enchantment and using 2 lines of reflection is too hard
you guys didnt say it wasnt the best, you said it is the worst thing u can do
One of the issues Is that you simple emulate that custom ítem by getting the same ítem and adding Lore
wha
With PDC doing custom items has never been easier
yea i learned abt that like last week
You can literally use PDC for your entire plugin
If you are able to data manage efficiently, that is
anyway, ehm, you know what I needa fix?
Unrelated tip:
java
https://paste.md-5.net/ifevugukuq.cs
repeats itself at least 3 times in a singular method. That must be optimized
Bukkit.broadcastMessage(ChatColor.WHITE + "[" + ChatColor.DARK_RED + "Loup Garou" + ChatColor.WHITE + "]" + "Le père des loups se réveille !");
String config_p = plugin.getConfig().getString("roles.loup-pere");
if (config_p != null && !config_p.equals("None")) {
Player p = Bukkit.getPlayer(config_p);
if (p != null) {GiveTime(p);}
}
Bukkit.broadcastMessage(ChatColor.WHITE + "[" + ChatColor.DARK_RED + "Loup Garou" + ChatColor.WHITE + "]" + "Le père des loups s'endort !");
Why the second Bukkit sent just after the first Bukkit.broadcastMessage() ?
?paste
What you mean? What are you trying to do
"GiveTime" is a function which show a timer on level of the player, but why the second Bukkit... has been sent before the GiveTime finished?
Show giveTime
private void GiveTime(Player plr) {
plr.removePotionEffect(PotionEffectType.BLINDNESS);
plr.setLevel(16);
Bukkit.getScheduler().runTaskTimer(plugin, (task) -> {
if (plr.getLevel() > 0) {
plr.setLevel(plr.getLevel() - 1);
}
if (plr.getLevel() == 0) {
plr.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 3));
task.cancel();
}
}, 0L, 20L);
}
I know why but I don't know how to explain it without messing it something so just wait for someone else to answer
I will move the bukkit into this func and ask the arg to give the sentence.
Is there an equivalent of persistent data containers for blocks? I want to store some "data" inside a block that I place. Specifically an identifier to say "this is my plugins block".
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Enjoy
Are u still using plain bukkit?
??
Idk how people can till code plugins with native Bukkit
What are you talking about
?
.
runTaskTimer doesn't stop the flow of your code
Oh lmao i thought he was using plain bukkit api
Hence reason why second thing just broadcasts
can someone help me
https://www.spigotmc.org/threads/plugin-error.594694/
Ok
Lets read this together
[16:29:11] [Server thread/ERROR]: Could not load 'plugins/spawnpl.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: main class `com.arcanhaven.spawnplugin.SpawnPlugin' does not extend JavaPlugin
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-1.16.5.jar:3096a-Spigot-9fb885e-af1a232]
Line 2
Literally says
main class `com.arcanhaven.spawnplugin.SpawnPlugin' does not extend JavaPlugin
So in your SpawnPlugin.java
Make sure it says
public class SpawnPlugin extends JavaPlugin {
//Your stuff here, onEnable(), onDisable()
}
Guys for a simple skyblock plugin, is the best way to do it to have every island be on the same world far away, or each island be its own world
Same world, separated by maxIslandSize
My thoughts would be it's more efficient for it so to be on the same world too
Is the most optimized
Do the same world if you aren't a psychopath 😉
Lool
But if you don't care about optimization and getting as much performance as you want. Just separate them by 500 blocks or so. Empty chunks don't take pretty much any memory
True also gotta prepare for future in case more island expansions are wanted
that's what it says
Send your class
^
Also, whole class pls
That's why usually you make the "island paste" adaptable. So it gets pasted at X distance blocks as in x config
Oh jesus christ
Wow
?paste @earnest vapor
Delete that
So do I gotta make a way for islands to be moved around if size needs to me changed
That is pretty advanced cause that means storing the island data each time everyone leaves and then loading it back in
yes it's the most efficient and defo really cool
But for now I would recommend, hard max limit to 500 blocks diameter
And call it a day
No one ever gonna make bigger than 500 block diameter
I was just thinking nbt parser read blocks at offset then shift them
Start at X and upgrade
Well, imagine you have stacking islands
It's a lot
But the real question is: if client never asks for that should I waste my time lol
All they asked for was a skyblock island creation plugin that lets u do /is create
Then hard set the max island limit to 1000 ( never gonna even get near that ) and stack islands 1000 blocks away
Lol
Structure API
Isn't it really outdated?
Then u just make them spiral out from middle I suppose
Oh that one
Yeah, it's the easy aproach
Are you saying they made world edit API useless
No
(Use FAWE anyways if you need WE )
But some really big plugins which do that like PMines use FAWE to paste copies of the PMine around
fast async world exception
Yeah I just make my own because I like to waste time like that
fawe is just a bad idea imo
How
it causes world corruption
i used it once on a server and it cause large areas of missing land in oceans
Maybe you just pasted wrong
I see pretty much every server use it way more than WE and you get the typical issues you get when you have such a massively used plugin
most servers can support normal worldedit with a bit of lag up to about a million blocks
if you have a lower gen server, just get async world edit
How works internally? Does it use a work distrubuitor?
idk I still see people use fawe more
Let's optimize world edit to do 100 million blocks without lag then
it just changes the block changes to async iirc
Async world edit is so slow
Thats the perfect example of why things are not updated to newer technologies
Fawe should literally just split the workload up over multiple ticks, not actually async
not really
It has a queue system
This is what it does
i would rather spend longer to do something than have the chance to cause world corruption
What if the server crashes mid world edit and now it's all messed up
thats an edge case
world corruptin can happen with anything that modifies the world, just some plugins or usecases make the change higher
Surely that's a common edge case when you're pasting things large enough to actually need fawe
The problem here its the fucking new versions, they are optimized for a potato, because not ever having a Xeon of 16 cores, 32 threads with 2,50 to 3,0 Ghz you can run a server with decent spawns, plugins and having around 250 players without tps going brr
Since 1.12 up they get fucked
Also the problem is caused specially to its shity single thread, because i can run it with 124gb of ram (max ram that i can add on me dedicated server) and the issue is the same
Did you mean the newer versions require having a god tier PC to run
Newer versions require resources which no processor can support them, because they dont really use those approch caused of single threaded
Yeah newer versions suck!
They actually do, xD. I noticed how massively faster older "legacy" versions were while booting up when I tested a plugin on them. You can notice how it just got worse over time. It's bloatware.
Im not sure if im explaning what i mean
@knotty ember Send your .jar file here
Oh thanks man, atleast one which agree with me
Mincraft newever versions have beeing destroyed in term of resources
No no, the problem is not the ram
The limitations are specially to single threaded
Minecraft is getting bloated overall. I mean, look at the new fancy modern launcher. It takes forever to come up and plays this funny animation, while in the good old days it was just instant. Software just gets worse, nobody cares, everything has to be out the door by tomorrow...
Yeah but they do go harder on ram than older ones
As i said i tested with 124gb of ram and 32gb, same machine, and the benchmarks doesnt change in case of ram
Like your ram is just perma maxed if you buy a cheap VPS to host modern version server
In my case i did actually test using home dedicated machine
Well 4+ GB of RAM is enough but cheap VPS be coming with like 1-2 which is sufficient for 1.12 and lower, not 1.13+
I have a 32 cores, 64 threads, 128gb ram machine, and the benchmarks in terms of memory doesnt improvee the whole issue is related to the cpu usage. Meaning that minecraft needs more resource which the better processor can give
I mean that wont really fix a lot
The whole issue is related to shity Minecraft design, which works on single threaded
Minestom is completely redesigned from scratch to better support multiple cores where it can
Yes i hered about it, but that is not the best option
Its a temporary fix let say
Best option: create your own insanely optimized Minecraft server in asm
minestom is not ideal for any normal server. Nor is that the goal of minestom
Yeah minestone is not designed for production enviroments if im not wrong
I wouldn't go that far
Minestom is production ready 💀
but its not designed for your every day server
Lol I know all about minestom, I use it so I already understand this Verano
Just hook into spigot server world gen and then code every functionality for the server you need and easy done
I do like the idea of minestom it seems very useful
Yes minestom lets me run 5x more minigames on the same machine
Minestom def would work well for large networks
you just need to do all the impl yourself
which can be useful since you can hyper optimize where needed
oh right
I get mixed my bad
Minestoms is not good for daily usage unless you have a big network
what it isn't ideal for is small servers since it would cost a ton to pay developers to implement everything you want
unless ofc you are a developer as the owner
there is the Vanilla impl, but it isn't complete
For minigames it's so ideal, takes less time to implement what you need than disable the 1000 things you don't
not for small servers...
🤷🏽♂️ depends what you want
For any size server minigames
for minigames I'd say it works well for everyone involved
When im talking about im refering benchmarks caring up to 5000 of users
Im talking about large networks
as someone who developed many minigames for work over summer 😭 I agree
Lol large networks do not put 5000 people on the same server tho
Thats what im saying
They split them on many instances
😂
Which minestom benefits from
You can literally run a minestom instance with 50mb of ram
lobby's would go crazy with minestom
Is there any benchmark im really interested
no but you can literally try it yourself
Nope just some guy tested it and posted his results
public void onClick(InventoryClickEvent event) {
Inventory inv = event.getInventory();
Player p = (Player) event.getWhoClicked();
ItemStack item_current = event.getCurrentItem();
if (item_current == null) { return; }
else if () {
} else {
return;
}
}
``` How can I check if it's the good inventory? 🤔
y2k bro, what you think about Velocity? A client insists its better
JVM overhead adds more ram usage but the actual instance itself can be as low as 50mb
Cuberite is the move anyways
don't blindly cast to Player with inventory's
?
I thought cuberite was stuck in 1.12
?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.
never used
Ah
its just another one of paper's things though so I have no specific interest
Velocity is good
Also I might be wrong but I'm pretty sure minestom is optimized better than cuberite overall
But I dont like that they enforce guice
Conclure i need arguments bro, im really interest
Because i having problems with a client
Sounds like a hassle
Bro what are you talking about?
Could've sworn cuberite server was taking more memory than minestom when I tested
its morally expected you have an understanding of java before you get help
But you cant compare testing over machines which are not yours, because they are no real components while testing
I mean its pretty bad measurement to do a comparison raw like that, cause given certain jvm flags, you can probably make either two use minimal ram
I tested them on my machine
its more like casting the player is irrelevant to what he was asking is it not?
Like putting serial gc for instance
Okay but it's still C++ vs Java
I always directly the getWhoClicked() to Player and never get a cast exception, maybe yes while working with holders
@EventHandler
public void onClick(InventoryClickEvent event) {
Inventory inv = event.getInventory();
Player p = (Player) event.getWhoClicked();
ItemStack item_current = event.getCurrentItem();
if (item_current == null) { return; }
else if (item_current.hasItemMeta() && item_current.getItemMeta().getDisplayName().equalsIgnoreCase("")) {
} else {
return;
}
}
``` How can I check the name of the inventory? Like in the constructor of the inventory with `Bukkit.createInventory(null, 9, "Title");`.
don't blindly cast to player and If you want to make a modern inventory system Highly recommend this thread https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
yeah me neither
Never use names for comparing!!
Myea true
I wouldn't reccomend using name for comparison
Java still has a massive jvm overhead of like 200mb ram too
Also the JVM have an issue, which im not sure if it has been fixed
also follow java conventions please
Yes but as said you can if needed reduce that overhead
using minestom for minigame servers sounds very nice
For instance enforce total string deduplication, but it makes the jvm slower
If needed u can completely remove the overhead but it'll run slower
I cant know find the amazon link where they explain they issue caused of JVM, how it internally keep pointers references. Because they where having a 20% of machines fasters
What did he not follow can't tell I'm on phone
Then it technically isnt overhead
var names camel case is what you are supposed to use
If it provides beneficence somehow
Oh the underscore lo
also the one line if statements in the beginning with an else if right after which makes it super annoying to read
I say as long as he's consistent with it
consistently bad is still bad
Don't hate on a man who learned python before java
python was my first lang too :P
generally dont hate at all, preferably :D
Lol
if its php, it may be overlooked
Lol
PHP should be against the law
The worst thinh about minestom is they make you use GitHub discussions for help...
Well the reasoning is that it's easier for others to find your issue and get help in the future
Instead of asking the same questions repeatedly on disx
they do have a discord server, no?
What build method should i use for maven?
i got jar:jar
but i get JAR will be empty - no content was marked for inclusion!
clean install
Yes they do but not for help
does no one use the search bar in discord or am I just weird
My technique is to just ask for help repeatedly and someone will eventually help u
i have clean:clean and install
Eclipse be like: 💀
not clean install or smth similar
Discord search bar kinda bad tho
That's a feature?
I've used it maybe 5 times.
i use it all time, when i ask a question and have to go out, so them i can find the answers to that question i hv done
I do lol
I use it in help channels like this generally
helps you find an answer to your question
a lot of times if its simple
I do the same
Also too see who tagged me
Because discord tags get bug some tims
If you know exactly what you're looking for its simple
its only simple once you found it
There are a lot of ways to word a question
so it can be hard to find
but that goes for any search function.
I used to use the plugin Skript to basically customize stuff on my server but now I use plugins.. if anyone else has used Skript a lot there is a push <player> <direction> <speed> thing u can use, how would I do that with a plugin
Skript 💀
yep
it was way easier for me
I was like 7 years old so I would not have understood java
In my case i see about it, but moved forward to java
Because Java was robust and not a shity scripting lang, i dont enjoy coding script lang
Like Lua, etc
how would I loop through all the items under the uuid when my file looks something like this?
fools:
6c***1d0-3**5-4fed-8c4e-c9828***c890:
'0':
==: org.bukkit.inventory.ItemStack
v: 3120
type: PACKED_MUD
'1':
==: org.bukkit.inventory.ItemStack
v: 3120
type: DIRT
I tried this, but it says I can't convert MemorySection to Integer[] but I don't know how to loop through a MemorySection
for(Integer i : (Integer[]) Objects.requireNonNull(configSaveFoh.get("fools." + s))) {
Bukkit.getConsoleSender().sendMessage(i + "");
}
Uuid doesnt look like that?
I woudl suggest using sections is the best option here
for (String key : config.getConfiguraitonSection("fools." + uuid.toString()).getKeys(false))
I just censored it for privacy reasons, testing this with a friend and he said he didn't want me showing his uuid
ohh right, now make sense haha
you can get the keys with getKeys though i don't entirely understand what ur trying to do
And I should use what?
getKeys(false) in your case
ok, thx
getKeys(false) -> will return only the paths from the section you are giving
getKeys(true) -> will return all the paths inside the section, including sections inside of sections
**Example:
**
Root:
key: "value"
section:
section-1:
key: "value"
section-2:
key: "value"
getKeys(false) over Root -> key and section
getKeys(true) over Root -> key, section, section.section-1, section.section-2, section.section-1.key, etc
can someone dm me if they can tell me how to make a plugin
Oh no bruh, you must learn plain java first
python seems so much easier
do u know any easy plugin making platforms
I wish minecraft used something like it xd
no really ugly
Python syntax is really undfriendly
its syntax looks like a shity script lang
do u know of any easy plugin making platforms
i think everything besides java looks like that for u
I dont like none highly typed langs
So mainly only Java, C# and TypeScript
yea
Then all syntax looks like shity scripting langs
ive heard of C# ppl say its a lot easier than java too
anyone?
no
an easy plugin making platform
wdym? like ide?
what that?
I cant even translate it to my native lang
is there not like a easy platform for making plugins and mods
Yeah java
uh just code in intellij
Java
im gonna get bullied for saying this but uis there like a block one
Visual Bukkit but it sucks ass
they sucks a lot
Sorry visual bukkit 😭
All things based on sivuality sucks a lot
i remember when i was like 7 i made one in tinker
tinder?
tinker#
i dont rly remember it
The easiest usable thing I know of is skript
This is tinker for me
its made for litarally 7 year olds
An online platform for making circuits that why get messed
That won't work for plugins
yeah
Gotta learn skript prob
but i just want smth like that
?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.
He asked for easiest
i dont wanna learn anything
Then dont code! Is the easiet solution haha
apart from a name of an easy plugin maker
?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/
I'm sorry scripting is for #help-server and programming in #help-development
This is all you'll get for plugins

Scripting is not even catogrized here
Because they are not server help nor programing
surley there will be some sorta easy platform
Visual Bukkit but again it may not even work on latest version
ok then can one of u guys make a plugin for me
So our suggestion is you wont code things properly, then dont do it
?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/
Thats called services
An none make free things 🤡
i dont have any money
Then learn to code
?robabank
that will take so long
Learn to code so you can make money and hire someone to code for you
infinite loop
i just want a minecraft plugin
Then dont code!!!
Lol
WE MUST ESCAPE THE MATRIX
Yeah now its the momment to leave the channel
HELP ME
break;
Vigure it out no one here knows
What do you want your plugin to do?
get those children out of your basement first
like a money 1
where u can exchange diamonds and netherite for money
yep
yeah so what you need to do first is work at google
Google your question before asking it:
https://www.google.com/
my friend lookes and couldnt find any
He doesn't wanna learn
That has too much config
how would I spawn a tnt entity that is already lit at a specific place and make it blow up but not destroy any blocks
No
I’ll order a custom-made plugin
?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/
😂
Yes
does minehut work
I usually use server.pro for test servers
Anyways get your ass to #help-server
plez
Hey just started making plugins, anyone know the problem here?
forgot to close a bracket
All events listening must bea nnoted
Its specified on the docs
Is it national new spigot people day or sum
?eventlistening
?
?events-listening
Thats the registration, its not what i mean
@EventHandler
@fresh templetHandler annotation
its not indented correctly
Poor even
LMAO
oh poor guy
oh shoot
That why you can always look online
Yeah I missed that one
I knew that, I just didnt see it
how would I spawn a tnt entity that is already lit at a specific place and make it blow up but not destroy any blocks
Cancel the EntityExplodeEvent, that will not allow tnt to break blocks
a TNT entity is already primed
a Block = unlit TNT, an Entity = primed TNT
ah alr
will it still like make particle explosion and make sound?
in the explosion event don;t cancel it, set the yield to zero
uh ok
what that?
Its something new?
thats for 1.12 ups
its been in many versions
Which 1.12 up sucks
Because newer versions are optimized for a potato
idk how people use them, they just getting stealed their money
I use newer cus I dont wanna make every plugin for my server and I cant get all the plugins I need in like 1.8 or anything soo
How can I get all of the players in a certain block radius around a location?
There is different ways
Get nearbyentities with a player filter
Get all player and match their distance to that location
?jd-s
This "should" workjava world.getNearbyEntities(loc, 10, 10, 19, LivingEntity.class::isInstance);
o
I just used event.getEntity().getLocation().getNearbyLivingEntities(10.0d)
I dont actually need only players rn
that would work tho?
both shoudl get all living entities
alr ty
LivingEntity.class::isInstance 
yep
💀
private static Method getProfileMethod() {
try {
Method method = Class.forName("org.bukkit.craftbukkit.v1_19_R2.inventory.CraftMetaSkull")
.getDeclaredMethod("setProfile", GameProfile.class);
method.setAccessible(true);
return method;
} catch (ClassNotFoundException | NoSuchMethodException e) {
e.printStackTrace();
}
return null;
}
``` This can't find `org.bukkit.craftbukkit.v1_19_R2.inventory.CraftMetaSkull#setProfile(GameProfile gameProfile)` for some reason
Any ideas why?
cant find the class or cant find the method?
Can't find class, my bad
why?
you sure about the package?
Why use reflection on a method which I believe is already public
The class isn't public
And yeah it's private
pretty sure that shoudl be accepting a Spigot Profile not an MS game profile
No
You've no reason to be accessing profile methods in skulls. Spigot has API for this now
Huh
you want setOwningProfile
Yeah
public method
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");
gameProfile.getProperties().put("textures", new Property("textures", texture));
itemMeta.setOwnerProfile(new CraftPlayerProfile(gameProfile));
``` Like this?
accepts profile above ^
Bukkit#createPlayerProfile() iirc to create one
not GameProfile, thats Mojang
How do I set the textures
PlayerProfile profile = Bukkit.getServer().createPlayerProfile(id, name);
try {
profile.getTextures().setSkin(new URL(getURLFromBase64(base64Texture)));
SkullMeta meta = (SkullMeta) head.getItemMeta();
meta.setOwnerProfile(profile);
head.setItemMeta(meta);
} catch (MalformedURLException e) {
e.printStackTrace();
}```
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID());
profile.getTextures().setSkin(URL);
skullMeta.setOwnerProfile(profile);```
Aight, thanks
I think getTextures() returns a copy, Elgar. Unless I'm mistaken
Oh it doesn't, you're right
I'm using a texture value though
eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTQyY2M5MjAzYzkwYjg5YmRhYzFkZjI4NDE2NzI2NmI5NTNkZmViZjNjNDY5MGE3Y2QwYjE1NzkxYTYyZTU4MiJ9fX0=
This'll work right?
new String(Base64.getDecoder().decode(base64.getBytes())).replace("{\"textures\":{\"SKIN\":{\"url\":\"", "").replace("\"}}}", "");
thats for the snippet I posted above to get a URL
(base64 being that string above)
Ah, alright
Thanks
So I'm trying to make a skull that gives you potion effects when you wear it. Can't get it to work though. ```java
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (!(e.getInventory().getHolder() instanceof Player p)) return;
ItemStack itemStack = e.getCurrentItem();
if (itemStack == null) return;
if (!itemStack.hasItemMeta()) return;
PersistentDataContainer pdc = itemStack.getItemMeta().getPersistentDataContainer();
if (!pdc.has(POTION_TYPE_KEY, PersistentDataType.INTEGER_ARRAY)) return;
if (!pdc.has(POTION_AMP_KEY, PersistentDataType.INTEGER_ARRAY)) return;
int[] potionType = Objects.requireNonNull(pdc.get(POTION_TYPE_KEY, PersistentDataType.INTEGER_ARRAY));
int[] potionAmp = Objects.requireNonNull(pdc.get(POTION_AMP_KEY, PersistentDataType.INTEGER_ARRAY));
if (potionAmp.length != potionType.length)
return; // PDC is corrupted
for (int i = 0; i < potionType.length; i++) {
PotionEffectType type = PotionEffectType.getById(potionType[i]);
if (type == null)
continue; // Potion type not valid
if (e.getSlotType() != InventoryType.SlotType.ARMOR) {
p.removePotionEffect(type);
continue;
}
p.addPotionEffect(type.createEffect(Integer.MAX_VALUE, potionAmp[i]));
}
}
It just gives you potion effects, and it does remove it. Would making a bukkit runnable that runs each few seconds for this overkill? It just adds more time to the potion effect once it runs out
Can some one help me?
how to access my string from the main file that contains a string from config.yml in another class?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
depends
is it a constant
or does it change
if it changes do what ElgarL reccomended
othgerwise just make a public static constant
thanks bro
another thing
i got this error:
[15:02:53 ERROR]: Error occurred while enabling DTAnvilRPG v1.0 (Is it up to date?) java.lang.NullPointerException: null at cirosanchezb.voltdevelopment.DTAnvilRPG.onEnable(DTAnvilRPG.java:19) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794] at java.lang.Thread.run(Unknown Source) [?:1.8.0_361]
And it says .onEnable
right
so ig is in the main - onEnable
and i go to check
And its alr
see
?paste
?npe
The NullPointerException, (commonly referred to as NPE), is thrown in the following cases, but not sealed to: 1. null is passed into a method or constructor which does not allow it; 2. When trying to access a field on an object pointing to null; 3. Casting null to a primitive. See https://stackoverflow.com/a/3988794/17047120 for information on how to debug NPEs.
whats the code for bolding chat color
ChatColor.BOLD
DTAnvilRPG.java:19
What line is that?
getServer().getPluginManager().registerEvents(new onAnvilClick(), this);
getCommand("anvilrpg").setExecutor(new mainMenu());
someone of them
i just put the strings for the messages i mentioned before
chatcolor.bold.yellow doesnt work, am i doing something wrong
Then you probably forgot the command in your plugin.yml
Never used BOLD before
Ohhh
yesss
thanks
ChatColor is an enum
So ChatColor.YELLOW is like, a single thing. ChatColor.BOLD is another
You can't combine them like that, you would want ChatColor.BOLD + ChatColor.YELLOW
ask to chatgpt idk
Hey @lost matrix i got a problem, so i have this permission anvilrpg.guicommand that will open a inventory named AnvilRPG, and ye, so i used LuckPerms to grant myself that permission but i cant execute the command even having the permission in LuckPerms
do i need to interact with smth?
[15:28:42 INFO]: UrDaddyCiro issued server command: /anvilrpg
[15:28:42 INFO]: [LP] VB > urdaddyciro - anvilrpg.guicommand - true
How do you check for permission in your command?
yep
if (player.hasPermission("anvilrpg.guicommand") || player.hasPermission("anvilrpg.click")){
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f);
Inventory inventory = Bukkit.createInventory(player, 54, ChatColor.translateAlternateColorCodes('&', DTAnvilRPG.mainMenuName));
}
but i still get this player.playSound
but no inv
maybe for the Or?
Because you didnt open the inventory for the player
Then your logic is flawed
Oh nvm
Well everything below the if-else will ofc be run regardless of the if-else outcome...
a permission was wrong
yee
i should use the else if instead ithink
What you are missing is player.openInventory(inventory)
Yes
holder instanceof Block && ((Block) holder).getType().name().contains("ANVIL"))
Is this actually checking if the block is a anvil?
isnt executing the code of block inside of the if statement
what event
What would be the easiest way to make like a chest-like thing that people can access anywhere by running a command?
Like a GUI?
No, I can do that part - I just need like persistent data storage (like world nbt data) but for items
Like does that exist?
Can I have a link to the docs?
?jd-s
?pdc
How to remove the damage stuff from the sword?
Thanks @rotund ravine
i tried with this; enchanterMeta.removeAttributeModifier(Attribute.GENERIC_ATTACK_SPEED);
enchanterMeta.removeAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE);
but it doesnt work
obviously i updated the meta
but it still appears
Which damage are you talking about
Durability?
(the green/red bar on the item)
Or the attack damage
If you remove the modifiers, MC will show the default for that item
Do you want to set them to 0, or hide them, or both?
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
You want to add ItemFlag.HIDE_ATTRIBUTES
declaration: package: org.bukkit.inventory, enum: ItemFlag
do i have to specify what i wanna remove?
so with
Although keep in mind this is only visual
itemMeta.removeItemFlags(); its ok?
its for a gui so it doesnt matter
if you wanted to re-show the attributes.
the ItemFlag HIDE_ATTRIBUTES, when added will hide the attributes.
When you remove the flag, it will show them again.
okay
disenchanterMeta.removeItemFlags(HIDE_ATTRIBUTES);
this should be ok?
no what
no its not
Because you're re-showing the attributes.
Removing the HIDE_ATTRIBUTES flag will make the client, well, not hide the attributes.
You put removeItemFlags.
You want addItemFlags.
Does anyone know how I can create a filled map that doesn't need to be explored? I'm trying to get a map that is constantly centered on the player and is already pre-explored so the player has the ability to see the whole map
I've already centered the view around the player, but cant seem to render the terrain into it
So i have seem some things about not using static and im just not completely sure when to use it and if its bad for certain things. I am using it to create and be able to call custom items in spigot as I have seen in youtube tutorials is this good for a custom item or would it be better to not make it static and get the items a different way?
static item constants is fine
The API to check the version sometimes return Failed to connect to MySQL: (1044) Access denied for user 'sso'@'localhost' to database 'xenforo', are someone else impacted by this ?
sometimes = you probably ran out of connections
item.getItemMeta().hasDisplayName()
what does that function do?
like I can't pass any arguments (probably not the usage I need)
It checks if the item meta has a display name set
The name is a bit self-explanatory lol
I am stupid
.hasDisplayName()
and as argument pass a string to check if that was the displayname
yeah self explanatory, I thought all items had a display name
Nah. A display name is more or less a custom display name. e.g. an anvil name
The regular ole "Diamond Sword" name isn't a display name
If you want to compare display names, you can getDisplayName() and check if it's equals() to another
It would be null, yes
hasDisplayName() is a pretty null check
Internally it literally does return displayName != null
can anyone here tell me about kotlin? is it worth learning that to use in plugin development?
fair enough
its worth learning
cause gradle
:D
I just use groovy
well it appears not everyone agrees
If you feel it's worth learning, it's worth learning. I personally don't see any value in learning it because I hate scripting languages with a passion (I know it's not, but it looks a hell of a lot like one), but to each their own.
but its a useful lang
what's even that
Compat
^
Kotlin <--> Java
at compile time ^
what would be a good use case over java
plugin dev aside
u have kotlin native
not really
which method should I use for getting the ItemStack of the item the player used to break a block?
I am looking through old posts and can't seem to find a good response without using deprecated methods
unless someone is using the kotlin JVM, kotlin isn't going to magically give you any improvements in what java already does
Have you tried reading the deprecation notes
is it worth learning for any other application?
Are you listening for a block break event?
wait what
yeah
android dev
If you want to do android stuff
otherwise no
I just use Java for android
A player will always use their main hand item to break a block. They can't use the off hand. So player.getInventory().getItemInMainHand() will suffice
naaa not into android.
thanks
With world NBT/PDC data, how would I take items from somebodies inventory and put them into a world PDC?
Almost like a chest emulation
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
^^ I'd use this library by mfnalex
It helps with storing itemstacks
In my class i have a public void MyClass(Player p){
}
and i wanna call it in another class
i make
MyClass class = new MyClass();
where do i put the player p in the external class?
uh that's not a valid class???
constructors don't take void
what
public what
this is the method
public void enchanterMenu(Player player){
}
}
here is where i wanna call it
case DIAMOND_SWORD:
HumanEntity h = e.getWhoClicked();
Player p = (Player) h;
enchanterMenu enchanterMenu = new enchanterMenu();
public class MyClass {
private final Player p;
public MyClass(Player p) {
this.p = p;
}
}```
a basic class and basic constructor
i mean that the Class will then make another GUI and stuff
also, please use ```java
code here
```
Okay
you need to remove void then
Okay
"understand"
to know
oh
yeah just im learning oop with this
i heard constructor before but idk that i can use that
like
Well, sorry, but this is a spigot development channel
here
not a general Java help channel
okay, btw
if i have that method i created how tf i can execute the rest of the code i was planning to write (creating a gui, putting in some elements, yknow)
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/#post-4553427 this is a very good start point by our famed 7smile7
but it does assume you understand some things
Hmm
I think practice is better than only sit and make some code ill never use, but okay, i take ur suggestion
How can I set a custom nbt tag to an Item ?
Serached onn google and found some thongs like CraftCompound etc...
but most infos or tutos don't work with 1.18
What I want in a nutshell is to set a tag like this on an item
ItemStack item = foo;
foo.setTag(<TagName>, <TagValue>);
you shoulnt use nbt tags on that version
you can use pdc tags
What are those ?
the same thing. but with a proper api
?pdc
Anyone know why with this code, I am getting a java.lang.StackOverflowError: null?
@EventHandler
fun inventoryClickEvent(event: InventoryClickEvent) {
val player = event.whoClicked
val playerUUID = event.whoClicked.uniqueId
if (event.inventory == TestPluginWMaven.guiMap[playerUUID]) {
if (event.currentItem == null) return
when (event.currentItem!!.type) {
Material.ARROW -> {
val itemsToDonate = event.inventory.contents
// Put the items in the admin-only accessible NBT storage medium
val key = NamespacedKey(TestPluginWMaven.plugin, "donations")
val pdc = Bukkit.getWorlds()[0].persistentDataContainer
val items = pdc.get(key, DataType.ITEM_STACK_ARRAY)
if (items == null) {
pdc.set(key, DataType.ITEM_STACK_ARRAY, itemsToDonate)
} else {
val itemsToStoreInPDC = mutableListOf<ItemStack?>()
val inventoryItemsList = itemsToDonate.toCollection(ArrayList())
val itemsInWorldPDC = items.toCollection(ArrayList())
itemsToStoreInPDC.addAll(itemsInWorldPDC)
itemsToStoreInPDC.addAll(inventoryItemsList)
pdc.set(key, DataType.ITEM_STACK_ARRAY, itemsToStoreInPDC.toTypedArray())
}
pdc.set(key, DataType.ITEM_STACK_ARRAY, itemsToDonate)
}
else -> {}
}
event.isCancelled = true
}
}
Like am I doing something I shouldn't be?
can you send stacktrace
at com.github.deadhash.testpluginwmaven.TestPluginWMaven$Companion.getPlugin(TestPluginWMaven.kt:16) ~[testPluginWMaven.jar:?]
It's just that but loop printed
I'd show you a screenshot but I can't send it here unfortunately
?paste
Gonna use more than one value in the future + implement all other features later, but for now I am trying to implement this section.
basically the main error other than the StackOverflow is "Could not pass event InventoryClickEvent to testPluginWMaven v1.0-SNAPSHOT"
and class you sent is TestPluginWMaven, right ?
send TestPluginWMaven
class TestPluginWMaven : JavaPlugin() {
companion object {
val guiMap: MutableMap<UUID, Inventory> = mutableMapOf()
val plugin: TestPluginWMaven
get() {
return plugin
}
}
override fun onEnable() {
// Plugin startup logic
logger.info("GUI Plugin Started Up Fine!")
registerCommands()
registerListeners()
}
private fun registerCommands() {
getCommand("donate-items")!!.setExecutor(Donate())
logger.info("Registered commands!")
}
private fun registerListeners() {
Bukkit.getServer().pluginManager.registerEvents(InventoryCloseListener(), this)
Bukkit.getServer().pluginManager.registerEvents(InventoryClickListener(), this)
logger.info("Registered Listeners!")
}
override fun onDisable() {
// Plugin shutdown logic
}
}
Would it be the plugin companion value that's causing the stack overflow?
bit of a weird companion object
yes
mb, didnt read code
but kotlin strictly advocates not using companion for stateful stuff
But basically, I am trying to get a ref to the plugin for the NamespacedKey
🤣
Ah yes, recursiveness
Do you know I can get a ref to the plugin then for the namespaced key?
yea
NamespacedKey(this,"namespace") no?
No, I cannot call this as the line is being run in another class called InventoryClickListener : Listener
So I cannot use this as then I'd be referring to InventoryCickListener
pass it
?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Mk
idk if there's a kotlin version
just type private val plugin: JavaPlugin in your primary constructor
So pass it down like this:
class InventoryClickListener(private val parentPlugin: TestPluginWMaven) : Listener {
And use it like this then?
val key = NamespacedKey(parentPlugin, "donations")
some one help me to create a plugin can show message or api or anythink under the name like this for example
And of course pass it in properly
which class is key ib=
in*
class InventoryClickListener(private val parentPlugin: PluginWMaven) : Listener {
like thats is will work
put it on function
nope
show again
Error trace:
[23:44:54 ERROR]: Could not pass event InventoryClickEvent to testPluginWMaven v1.0-SNAPSHOT
java.lang.StackOverflowError: null
at com.github.deadhash.testpluginwmaven.TestPluginWMaven$Companion.getPlugin(TestPluginWMaven.kt:16) ~[testPluginWMaven.jar:?]
at com.github.deadhash.testpluginwmaven.TestPluginWMaven$Companion.getPlugin(TestPluginWMaven.kt:16) ~[testPluginWMaven.jar:?]
at com.github.deadhash.testpluginwmaven.TestPluginWMaven$Companion.getPlugin(TestPluginWMaven.kt:16) ~[testPluginWMaven.jar:?]
at com.github.deadhash.testpluginwmaven.TestPluginWMaven$Companion.getPlugin(TestPluginWMaven.kt:16) ~[testPluginWMaven.jar:?]
show TestPluginWMaven
you didnt recompile your code
Uhh I ran maven lifestyle > package script again?
oh I have a duplicate plugin for some reason in my server files
one sec
Yeah ok should be fine now...
Ok, well no errors!
Cool, thanks guys 👍
Oh also
class TestShow(private val parentPlugin: TestPluginWMaven) : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
// Get items from PDC, then make a temp inventory for the player and stick them in
val key = NamespacedKey(parentPlugin, "donations")
val pdc = Bukkit.getWorlds()[0].persistentDataContainer
val items = pdc.get(key, DataType.ITEM_STACK_ARRAY)
if (items == null) {
sender.sendMessage("No chest data found.")
} else {
if (sender !is Player) return false
val inventory = Bukkit.createInventory(sender, 9, Component.text("Donation Window").color(TextColor.color(0, 133, 0)))
items.map {
inventory.addItem(it)
}
TestPluginWMaven.guiMap[sender.uniqueId] = inventory
sender.openInventory(inventory)
return false
}
return false
}
}
Can I not do this for another command to show all of the items I put in the item array PDC thingy?
@hazy parrot
Because this just errors like this: https://paste.helpch.at/kujalegoka.rb
It's a kotlin map with it as the predicate
some item inside of your map is null
So it just loops over the array and gets every item and adds each one to the inventory var
Oh right
i know kotlin 😂
Oh sorry 🤣
Thought you were asking what the map was lol
So, is there a way to do what I'm trying to do?
Like show all of the items in there?
before i look into it, can i intercept packets sent to players to see blocks and then change the block they see?
just skip null items, also why using map insted of foreach
tryna make like a one way mirror
map will change list
oh shit right
use foreach, not map
and filter out null items if there are any
will do
Nice! It's doing it :D
One last thing, how can I make it so that one of the items in that "inventory" is not removable?
listen for InventoryInteractEvent and if its one of the items you don't want to remove, cancel event
So like, e.g. item slots up to the last are interactable
Yeah alright
@hazy parrot
class InventoryInteractEvent : Listener {
@EventHandler
fun inventoryInteractEvent(event: InventoryInteractEvent) {
val playerUUID = event.whoClicked.uniqueId
if (event.inventory == TestPluginWMaven.guiMap[playerUUID]) {
if (event.currentItem == null) {
return
}
}
}
}
Why is event.currentItem not working?
Like it's "not resolved"?
"Unresolved reference: currentItem"
net.md_5.bungee.api.ChatColor.of(color) does not support transparency, right?
While you can certainly intercept and modify chunk/multiblock/block updates, I don't think it will allow you to create the mirror in the way you want to, although I do not yet know the details. There has been this amazing portal plugin some time back which did actual live "mirrors", but I have no idea how they did it, to be honest. Maybe there's some inspiration to take there tho.
Okay
No, that's exactly what I meant
Yeah, no, you can't
I mean, not alone
You would need a resource pack with core shaders
but no pure Vanilla Mojang way to do that, no.
Okay-okay, whatever
yep text is rgb not rgba
Then I have a question
Shoot
More like, not a question, but want an advice
Let's say, I want to make a pixel art made out of these █ characters
In the game they appear as squares
I pain them different colors and get a picture
yes
because that is not valid getter in inventoryinteractevent
Oh, do you know what is/how to do it?
The only problem is that if I have a transparent pixel somewhere (it's just a space in this case) in the middle, they don't align
there is no getter for curent item in interact event as its kinda abstranct, but you can check if it is InventoryClickEvent and cast event to it
you dont even have to cast, kotlin autocasts
So what are possible workaround for this?
how about a black square? maybe that might blend into the chat and look invisible?
Two spaces?
or yeah just add extra spaces until it aligns
They are too wide
they'll never align properly I think
try bolding the spaces
as characters have different length in pixels
or,
you'll have to make a new resource pack font that has a character with a custom width
using the "spaces" provider
Or can I not just use the InventoryClickListener I already have then?
This is it right now @hazy parrot
Right now I only have the event.isCancelled = true on the arrow if it's clicked
Eh, it's like cracking a nut with a sledgehammer
Like is this good?
i dont think so
type event and . and let your ide complete
Well I mean I can do event.isCancelled in the inventoryclickevent listener
That part works
What do you want me to do with that exactly?
It would be a nice idea, but another problem is that these pictures are generated based on larger png images
And these images are dynamic, so it is not possible to visually align them
How weird, two spaces seemed to do it for me
You cannot type out two spaces in chat tho, have you tried sending two spaces programmatically?
Yes, I did. The more transparent pixels are there, the worse it gets
yeah if that works alright
Oh, I see, it's off by a little bit, which accumulates over longer distances, :/
Ok, well @hazy parrot now how do I make it so that the items are cleared from the PDC when they take them out of the "inventory" GUI menu?
sorry, but i don't really remember your code, in what pdc are you saving what
Just an item PDC instantiated like this:
val key = NamespacedKey(parentPlugin, "donations")
val pdc = Bukkit.getWorlds()[0].persistentDataContainer
val items = pdc.get(key, DataType.ITEM_STACK_ARRAY)
It's of persistent data type ITEM_STACK_ARRAY provided in the library by jeff
so you are storing it in world
Yeah
i think you would have to remove it from array, then put new array into pdc
Yeah ok
@Override
protected void execute(Event event) {
NMSHologram hologram = this.hologram.getSingle(event);
Player[] players = this.players.getArray(event);
List<UUID> hiddenPlayers = hologram.getHiddenPlayers();
for (int i = 0; i < players.length; i++) {
if (show) {
if (!hiddenPlayers.contains(players[i].getUniqueId())) {
Core.getNMSVersion().displayHologram(hologram, players[i]);
}
continue;
}
if (hiddenPlayers.contains(players[i].getUniqueId())) {
Core.getNMSVersion().hideHologram(hologram, players[i]);
}
}
}``` any way to make this better?
The only real way to fix this issue is with a custom font which requires a resource pack. Otherwise you'll have to deal with character spacing math and obscure invisible characters from another charset since minecraft uses a monospaced font.
Either that or get real lucky with a character that you find.
how might i go about detecting when a players armor changes?
While certainly not ideal, I think a hack like this may be the only solution. The tilde is 1+2+2+1=6 pixels, 1 pixel distance and the dot is another pixel, giving you 8 in total, where 8 seems to be the max character width, which the UTF8 block takes up.
edited to this:
@Override
protected void execute(Event event) {
NMSHologram hologram = this.hologram.getSingle(event);
Player[] players = this.players.getArray(event);
List<UUID> hiddenPlayers = hologram.getHiddenPlayers();
NMS nms = Core.getNMSVersion();
for (int i = 0; i < players.length; i++) {
Player plr = players[i];
if (show) {
if (!hiddenPlayers.contains(plr.getUniqueId())) {
nms.displayHologram(hologram, plr);
}
continue;
}
if (hiddenPlayers.contains(plr.getUniqueId())) {
nms.hideHologram(hologram, plr);
}
}
}``` probably better
Although it looks weird, but might work
Three backticks in a row also work. A square is 8 pixels plus one pixel space, so you need to bridge 9 pixels in total. There aren't many possibilities, but spaces cannot work, proven by the fact that they're 3 + 1 space in width and 9 is not evenly divisible by 4.
Hope that helps at least in some way, xD
This helps a lot
What is that dotWidth array though?
