#help-development
1 messages ยท Page 51 of 1
yes
p.getInventory().addItem(heart);
and in here
i want to do like: /withdraw 5 and it give me 5 hearts
So it gives you 5 of those items and removes 10 hp from the player?
ItemStack heart = new ItemStack(Material.NETHER_STAR, amountOfItems);```
Check if the player has >= hearts than the amount he wants to get
ah sorry only >
otherwise it just kills him
if(((Player) sender).getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= Integer.parseInt(args[0]) * 2) return false;
it already check
The whole command class is a bit messy
if (p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= Integer.parseInt(args[0]) * 2) return false;
I don't see you checking for args.length anywhere
There could be no args[0]
that's why u have to check args.length == 1
and then you have to check if args[0] is a number
thx
anyone know how to make it so custom entities dont reset when the chunk unloads?
try {
Integer.parseInt(args[0]);
if (p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= Integer.parseInt(args[0]) * 2) return false;
} catch ()
what i put i catch?
NumberFormatException
Why do you call Integer.parseInt(args[0]) twice
And you don't even do anything with the result of one
Paste your whole command class here please
?paste
if (args.length == 1) {
try {
Integer.parseInt(args[0]);
if (p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= Integer.parseInt(args[0]) * 2) return false;
} catch (NumberFormatException e) {
p.sendMessage(ChatColor.RED + "You have to write a number");
}
}```
you could just use player#health
That's not the class
thats good @iron glade
?
thats
I assume you are wanting to make it the parsed arg
well u gotta declare the variable outside the try and set it inside
check if its not null at the end..
The way I'd do something like that would probably be something like
public boolean isInt(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException ignored) {
return false;
}
return true;
}```
Then after checking
```java
if(args.length == 1) { }```
I'd use
```java
if(isInt(args[0]) {
int input = Integer.parseInt(args[0]);```
^
and now you can check if input > the player's hp
ok thx
if (args.length == 1) {
try {
Integer.parseInt(args[0]);
} catch (NumberFormatException ignored) {
return false;
}
}
like this is good?
i will go to bed now, can we talk tomorrow?
you can literally copy and paste the isInt(String s) method into your utility / main class and access it from your command class
alright, good night then
thx
i'm trying to only make the hoe's replant when the durability is above 0
PlayerHarvestBlockEvent?
any1 know how to fix playerinteractevent firing right_click_block twice/thrice? already searched & tried multiple fixes to no avail
tried damageable.getDamage() > 32 then wooden can't replant cause the durability is under 32 not sure what is happening
but when its 0 or 1 keeps going negative
_ _
e.gethand
you're checking if the hand is the right hand?
didnt do anything but make it so i can only use it in offhand
got any better ideas?
Have you tried something like adding the player to a list when the event fires and only make the event fire when the player is not in the list?
if(e.getHand() != EquipmentSlot.HAND) return;
thats what i was doing before
I specify my GUI items like this: java GuiItem guiItem = ItemBuilder.from(Material.STONE).asGuiItem(event -> { event.setCancelled(true); String test_message = main.getConfig().getString("test-message"); player.sendMessage(MiniMessage.miniMessage().deserialize(test_message)); }); How could I add a certain CustomModelData/nbt to it?
I'm using TriumphGUI if it matters.
I can also chance GUI libraries if there's something that makes it easier/better...
CustomModelData is on the itemmeta
Is there documentations/an example on how to use it?
gui.getItemStack() I think
ah sry I misread
CustomModelData goes to the item meta?
why don't grab the guiItem's itemStack and from there on its itemMeta, edit it and put it back on the item?
i only clicked once
doesn't work
any other ideas?
Wooo! Custom textures finally :) Since this is my first custom textures video, I made it pretty simple. There is definitely a lot we can do with textures as well as multiple ways to apply it to a player but first, we need to learn the basics. In this video, I explain how a texture pack works, how we make our own, and finally how to apply it to a...
Erm, how shall I do that? I've never worked with itemStacks/itemMetas.
I'll take a look :D
well you can easily get the guiItem's item stack by using guiItem.getItemStack()
and from there on you just have to know how to edit the CustomModelData of its meta and set it back
how come this simple line of code doesnt work?
aaaaaaaa i need a good solution
its causing a bunch of errors with certain things
cause it needs to be a List of type "World"
yeah ty
Is there a way to remove a player from tab list without making him invisible?
Another quick thing, how can I make colors work with the title here: java Gui gui = Gui.gui() .title(Component.text("&dTest")) .rows(6) .create();
use ยง instead of & or do .title(Component.text("Test").color(NamedTextColor.YOUR_COLOR))
Thank you!
np
Legacy in a text component is a sin and you should be crucified if you do it >:((
If that's Adventure, you can do Component.text("Test", NamedTextColor.LIGHT_PURPLE)
Fair enough, the GUI guide just had this as default, so I used it haha
Another dumb question... ```java
public class JoinEvent implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().setResourcePack("https://www.dropbox.com/s/rieh4n8tvkjh1gw/dd.zip?dl=1");
}
}``` How can I determine if they accepted or declined the pack?
PlayerResourcePackStatusEvent
declaration: package: org.bukkit.entity, interface: Player
you can also force them to accept it
or it will kick them,
Perfect, that's what I was thinking haha
Thank you very much!
still need a fix
nws
check which hand it is
already tried
it fires for both main and offhand
didnt do anything
show your code
package plugins.neptune.neptune;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.block.Action;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import java.util.Objects;
import static org.bukkit.Bukkit.getServer;
public class Interact implements Listener {
NamespacedKey key = new NamespacedKey(Neptune.getPlugin(), "item");
CustomItemEvents customItemEvents = new CustomItemEvents();
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Action act = event.getAction();
ItemStack item = event.getItem();
Player plr = event.getPlayer();
getServer().broadcastMessage(act.toString());
if (event.getHand() != EquipmentSlot.HAND) { return; }
if (act.equals(Action.RIGHT_CLICK_AIR) || act.equals(Action.RIGHT_CLICK_BLOCK) && !(item == null)) {
PersistentDataContainer container = Objects.requireNonNull(item.getItemMeta()).getPersistentDataContainer();
String itemtag = null;
if (container.has(key, PersistentDataType.STRING)) {
itemtag = container.get(key, PersistentDataType.STRING);
} else {
return;
}
assert itemtag != null;
customItemEvents.handleRightClick(itemtag, event);
}
return;
}
}
sorry if this is bad im still a newbie to java
the broadcast is for debugging purposes
that looks fine to me
how can you tell its firing multiple times?
wait for a response no need to advertise your question
broadcast says it twice, aswell as some errors happening in my block destroyer item because the block was already broken
player interact event fires twice once for each hand
by block destroy item do you mean CustomItemEvents?
the errors are still happening, so thats probably not it
yes
customitemevents does all the cool stuff
hm strange
dont see why it would fire twice
also dont use assert just use an if statement
stupid intellij idea told me to use assert
it looks nice so im keeping it
it will throw an error if not true
quote from a stack overflow comment "They should never be triggered in production code, and are indicative of a bug or misuse of a code path"
your best bet is just printing out the action, and hand and seeing which are passing through your if statements
alright, ill stop using assert
itemtag will never be null anyways though
so i can just remove that
yeah
alright i fixed it
thanks man
do you know any way to completely freeze a server to cut down on memory?
i want to make it so when nobody is playing on my server no code will be ran, no npcs will move, basically nothing
eh not really possible
hm
just have functions in place that doesnt run logic code when no one is on
depends what your code is
ah right
unless you modify the server jar, not really
base minecraft code doesnt really use much mem anyway
you'll probably run into more issues trying to cancel it than not
when i go idle/leave my memory usage will slowly go up
you have a memory leak then
^ one of your plugins has a memory leak
how would i tell what thats coming from
use a profiler
are you storing the Player variable anywhere?
that can cause mem leaks
generally rule of them to use UUID instead of player object
no ahaha
He means if you store a player like this
Map<Player, ?>
or Map<?, Player>
any collection containing a player can cause memory leaks
nah anything declared on the class scope
will cause a mem leak
method scopes are fine
@EventHandler
public void onResourcePackStatus(PlayerResourcePackStatusEvent event) {
Player player = event.getPlayer();
// If the resource pack download failed
if (event.getStatus().equals(PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD)) {
player.kick(Component.text("Server resource pack has failed to download.\nPlease rejoin."));
}
// If the user declined the resource pack download
if (event.getStatus().equals(PlayerResourcePackStatusEvent.Status.DECLINED)) {
player.kick(Component.text("You failed to download the resource pack."));
}
}``` Is this how I would check to see if they decline the resource pack?
yeah
I'm quite new to java, but I would assume it would work like this? https://paste.gg/p/anonymous/5c4fd3114b0b4ac4957cdec54c7bb454
Under the JoinEvent class.
yeah looks good, maybe have it ona runnable
Could you explain a runnable?
basically, its a piece of code that will run after x ticks
_ _
Bukkit.getScheduler().runTaskLater(plugin, () -> {
//CODE
}, delay};
ok
I'm so confused on how to use that, can I get a bit more of an example, sorry ๐
In newer versions you can natively enforce a resourcepack
I'm on 1.18.2, so that would work?
It was either 1.18 or 1.19
Where shall I go to see how to do that? hah
.
I have this, isn't it similar/the same thing? java @EventHandler public void onJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); player.setResourcePack("https://www.dropbox.com/s/rieh4n8tvkjh1gw/dd.zip?dl=1"); }
is there any way to set time for just one player
i wanna make time corresponding with irl time
You would need to use packets for that
i dont mind
hey @lost matrix
Is there any way to hide particles from specific players?
I was working with a couple guys last night trying to make it so bees couldnt wander over 32 blocks from their hive using:
@Override
protected PathNavigation createNavigation(Level world) {
final PathNavigation vanillaNav = super.createNavigation(world);
FlyingPathNavigation navigationflying = new FlyingPathNavigation(this, world) {
public boolean isStableDestination(BlockPos blockposition) {
return vanillaNav.isStableDestination(blockposition) && blockposition.closerThan(blockposition, 32);
}
public void tick() {
vanillaNav.tick();
}
};
navigationflying.setCanOpenDoors(false);
navigationflying.setCanFloat(false);
navigationflying.setCanPassDoors(true);
return navigationflying;
}
in my custom class, but the bee's ai breaks once it gets nectar
it just floats in place indefinitely
Either send the particles to only specific players or listen for outgoing particle packets and intercept them for certain players.
Alright ๐
i just realized it counts the durability
made it work
added playsound, it really does the job damn
How can i filter a TabCompleter. Like if i add "s" it'll show only the things that start with s?
Is it possible to spawn an invisible block thats not a barrier?
There is also a light block. What do you need this for?
Nah that wont work
Just need any block being invisible but interactable
So you can still break it
Im willing to use packets if i have to
There is no invisible breakable block in minecraft. If the client thinks that the block he is hitting doesnt exist, then he
wont send any packets that would indicate that he wants to break the block.
No by invisible I mean its just see through, Im ok if the player can see the outline of block it just has to be see through
could it be possible to use a resource pack?
Easiest way is a texture pack
That wont work either
Yes you would have to replace a block texture
Ok but there is no such block in minecraft
Damn ight thanks for the help
a
has to be a selectable block
not one set one
oh
sendBlockChange makes a block only visible for one player or whoever you send it to
right?
Yes. But you would need to change it to air in order to be invisible. In which case the player doesnt
even attempt to break it
Yeah thanks
how would i make it so the if (e.getPlayer().getItemInHand().equals(item)) { works with any stack number
only works with 1
ItemStack#isSimilar(ItemStack)
But dont do this to check for custom items. Use the PersistentDataContainer of the ItemMeta.
This method exists since over half a decade
But dont do this to check for custom items. Use the PersistentDataContainer of the ItemMeta.
ye
how do I allow using hex colors?
md5 chatcolor
I mean they are not forbidden in the first place...
not exactly what I meant
more like how do I make it possible to use them without getting white numbers and letters in return
In the tab completer, create a new list of strings. Iterate over the items in the potential list of results. Any which start with the letters entered, add to the list. Return this list
Does anyone know if Bukkit.unloadWorld() is async or not?
yeah but why is the permission denied
presumably it's still in use by the server or smmin?
K
Yeah
Thats not your plugin
Try hosting your own server on e.g. ploudos and test your plugin on there. If it works there then its the server owwners fault
I'm hosting the server
How would this make a difference?
Maybe its some kind of "anti hack" so dont 3rd party stuff can delte files idk XDD
Make sure the user that runs the server has permissions for that fiel
Yeah I do
I only use one server
and I can delete it
*one user
I''m going to try delaying the deletion
Still no permission
What if I try running the server as an administrator?
Not one tick lol
well how long then? What am I actually delaying for?
I would just try deleting the folder every 50ms until its gone
why do I actually need to do this though?
Because unloading the world doesnt instantly release all resources. The spigot api for loading and unloading worlds
is absolute utter garbage (no exaggeration)
๐
Is there anyway I can make it release them?
Why is AsyncPlayerChatEvent.setCancelled() is deprecated?
Why is Player::getDisplayName() deprecated?
What should I replace those by?
Thats paper
displayName() and displayName(component)
And paper favors AsyncChatEvent to AsyncPlayerChatEvent @vivid cave
(Uses components instead)
ah
Thats all
But damn i don't want to use their components it's overly complicated for what i want
I mean just use minimessage?
what's that?
But am I really obliged to go through their stuff? I really dislike it

I think it's cool for specific cases but strings is so much simpler
I use custom formatting for colors
for example and many other stuff
Thats where mini message comes in
based on regex
To be genuine here I dont see the issue
Sure components can get long to use and all that
But mini message sophisticatedly fixes that
Or well you could just use spigot
okay
Since you were asking here after all
yeah sorry that i'm being like that
Anyway do whatever you feel comfortable with
i'll check ^^
I guess at this stage where paper hasnt hard forked yet your choice is really insignificant, and it will stay that way if you choose not to migrate to paper once all that has happened
i'm checking, it looks really fun like html but still a bit complicated for what i do (i'd need to change a lot of code)
Alternatively get used to components a bit, and minimessage which isnt that big of a deal with you pay 5 min of attention 
Best of luck :3
yeah i'll be actively considering that choice
but do you know why the setCancelled method (specifically) is deprecated?
isn't that a great way to circumvent 1.19.1
By the way thanks a lot for your assisante buddy ๐
Already told you
but like getPlayer isn't deprecated
Probably just forgot to deprecate that also
minimessage is so annoying though
Elaborate
e.g. no legacy color codes, you always have to turn them hex colors yourself
admins don't like having to switch to a new syntax after having used &c for years
that's a bit my situation yes
Yes well the aim of minimessage is to address the ambiguity of legacy color codes
thats why I wrote my library OysterMessage that combines both lol
So if you find their aim annoying sure Ig
https://github.com/JEFF-Media-GbR/Oyster-Message this is basically adventure + legacy combined
I mean i keep an open minded i won't bash them they're probably a great alternative
It's just that i'm so not used that it'll take time
yes, sure it's good, it's just annoying to switch to it after using normal codes for years
but yeah it's paper being paper again
"let's deprecate everything"
I mean, minecraft stopped using it in principle and has a more intricate system to represent complex components
So it makes sense to dry out it from the api
The deprecation is to make devs aware of it all the more
Like finalize in Java
First provide alternative solutions, then deprecate and after some time invoke the removal
fair enough, if they wouldn't also remove methods that take a string
Myeah Ig thats partly true
can anyone dm if you are able to make custom enchants
Altho they are trying to provide hands on string methods that use mini message
like sendRichMessage or sth iirc
?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/
should we just DM you with saying "yes", or what?
that looks a very interesting plugin^^
I won't use it though, because i've been doing that "write everything myself" policy
I even made stuff like dithering algo, maths expression parser (convert string to maths expression and compile them and evaluate them), so following that line of thought u can understand it'd be a bit frustrating to give it up for a chat stuff
if you can dm me
I wrote this to allow people to use both minimessage and legacy codes in my plugins, but since I have to shade minimessage, this lib is like 1.5 mb so I never used it myself too lmao
and then?
if you are trying to request work, then this is not the right place
?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/
that link doesnt even work
I believe they were here yesterday offering 2$ for an entire custom plugin
It does
nope it says error
you probably just don't have any forums account
Dont come here again trying to recruit people or request commissions, this is your second warning, we have a dedicated section on the forums for that sole purpose
create an account, login, then you can see this forum
it doesnt even let me open any spigto website
wdym
also wtf intelliJ
last time I checked, java 17 was already released lol
okay I started to love Jeka
JkDependencySet deps = JkDependencySet.of()
.and("com.googlecode.playn:playn-core:1.4")
.and("com.threerings:tripleplay:1.4")
.withDefaultScopes(COMPILE_AND_RUNTIME);
JkDependencyResolver resolver = JkDependencyResolver.of(JkRepo.ofMavenCentral());
does anyone know how to do this without creating resource packs?
I would love to know too, toast ui is very gooood
is it just ChatMessageType.SYSTEM
I'll try it out
great, now my intellij stopped working completely >.<
nope, its not just ChatMessageType.SYSTEM
seems like you actually have to create an advancement
then grant it
then you can remove the advancement again
Back on this, now trying to repeat like this
even after 50s it still fails
How long do I have to wait until I can delete the files?
you probably wanna return in case the deletion worked
IIRC you can't just delete() a folder
yo uhave to recursively delete all child files
or use something like apache's FileUtils that does this for you
That's true, but it still in my folder
Oh?
ah
pretty sure about this
Id recommend using Files.newDirectoryStream or sth to avoid DoS
Which normal File can cause
DoS?
Denial of Service
isn't the whole File api kinda deprecated anyway? i heard everyone recommends to use Paths now, which I hate, they are so annoying lol
File has a method called listFiles or sth, but that returns File[]
yes, thank you gradle, you are so fast. only took you 3 minutes to setup this project duh
And that also means the array with its elements is eagerly created
So yes
Files + Path is objectively better
Its a miracle File isnt deprecated
i actually don't understand at all what's wrong with File
As said
It can cause a dos
If you use listFiles
And iirc the remame function for instance did not work consistently across different platforms
Small things like that which makes it volatile and unreliable to work with
Also
File metadata accessed with javaโs File class was inefficient
And also, some methods did not throw exceptions that they were contracted to
also the symbolic link impl was a hacketry iirc
Some more stuff also
Its on the oracle website
hm
Legacy io or sth if you wanna google it
oki thanks, will google that after I finally made toasts working
they are so annoying D:
why is there no toast api D:

I wonder
if I'd add sendToastMessage or whatever to spigot
should I add it to Player or Player.Spigot
Player.Toast maybe :>
uuugh why is everything deprecated here D:
does anyone know what this was replaced with
I think they just wanted to eradicate support for legacy
Hmm didnt bungee chat add api for it?
dont think so. i need an NMS component to create this thing
Oof
?jd-bcc
no, I need the actual NMS component D:
anyone know if theres any native hash map deque object?
not really a map more like a Pair with FILO
It doesnt conform to the deque contract interface
But its linked so it can effectively work like one
Oh, thats better then :>
Through human suffering probably
What's the difference between these 2? The top one produces a stack overflow but I don't see why

๐คฆโโ๏ธ
https://github.com/ZockerAxel/CrazyAdvancementsAPI, If you wanna make it easy for yourself.
I don't really want to create actual advancements
I just need some temp advancements to send toast messages
basically I just wanna do this ๐
unfortunately Bukkit.getUnsafe().loadAdvancement always returns null
Don't you need to use a resource pack with an advancement in it?
nope
you can also load them using Bukkit.getUnsafe().loadAdvancement
if only that would work
it always just returns null
I did a little digging into that guys source code and this is their packet for Toasts.
but NMS ๐ฆ
thanks, but that still requires me to create an NMS advancement
and this stimply doesn't work for me
1 sec
yea, ik. Thats why I said "but NMS ๐ฆ " lol
I'm fine with using NMS, if only I would know what exactly I have to do to get this working haha
?paste
obviously the advancement json is correct, I copied it from the blaze and caves data apck
Really?
Hey Can I get a list of every chests placed in a world?
no, only of all loaded chunks
is enough
yes, but I'm always too slow to screenshot it haha
Plus, incredibly slow.
Why do you need every chest in your world?
https://wiki.vg/Protocol#Update_Advancements I don't understand anything in there ...
huh? no
to search through every block in a chunk for chests?
Tile entities are likely stored specially
chunks are tile entities
you can just do chunk.getTileEntities()
erm wtf
I meant
chests are tile entities
I would ask to see source cuz im interested but I don't wanna impose.
lol
I only got it working very dirty right now, by loading some json instantly
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
org.bukkit.advancement.Advancement adv = Bukkit.getUnsafe().loadAdvancement(new NamespacedKey("test", "test3"), "{\n" + "\t\"display\": {\n" + "\t\t\"icon\": {\n" + "\t\t\t\"item\": \"minecraft:crossbow\"\n" + "\t\t},\n" + "\t\t\"title\": {\"translate\":\"mfnalex is cool and you're not\"},\n" + "\t\t\"description\": {\"translate\":\"it's true! Also fuck @imajin\"},\n" + "\t\t\"announce_to_chat\": \"true\"\n" + "\t},\n" + "\t\"rewards\": {\n" + "\t\t\"function\": \"bc_rewards:weaponry/ol_betsy\"\n" + "\t},\n" + "\t\"criteria\": {\n" + "\t\t\"shot_crossbow\": {\n" + "\t\t\t\"trigger\": \"minecraft:shot_crossbow\",\n" + "\t\t\t\"conditions\": {\n" + "\t\t\t\t\"item\": {\n" + "\t\t\t\t\t\"items\": [\n" + "\t\t\t\t\t\t\"minecraft:crossbow\"\n" + "\t\t\t\t\t]\n" + "\t\t\t\t}\n" + "\t\t\t}\n" + "\t\t}\n" + "\t}\n" + "}");
Player player = (Player) sender;
player.getAdvancementProgress(adv).awardCriteria("shot_crossbow");
}
catch (Throwable t) {
t.printStackTrace();
}
return true;
}
Json is easy replicable so, ๐คทโโ๏ธ . Thanks!
Now rip out any tabs and newlines
first of all, I wanna make this work more than once
the \n go crazy
because once you use this namespacedkey, the server remembers it ๐ฅฒ
seems like a restart gets rid of it
so I can just use a random UUID as namespacedkey
I'll mess around with it in a little, I have to wrap up some refactoring I'm doing on my codebase
"Loaded advancements will be stored and persisted across server restarts and reloads."
In the docs for the method
yeah, I found out I'll need to manually remove the json files on each shutdown
pretty dirty
but
I dont see another way
Damn, well. In the docs for UnsafeValues#removeAdvancement it says you need to call Server#reloadData alongside it.
Otherwise, it wont remove it from the running server. It will only remove it from persistent storage
what the heck
thank you so much
i didnt see the removeAdvancement method at all haha
I looked for it, but I didnt find it, haha
No problem, thats what we're here for.
I just looked at the docs because I be forgetting half of Spigots methods
but yeah, that method does the same thing I also wanted to do
however I don't need to wrap CraftMagicValues.getBukkitDataPackFolder() now, which is handy lol
crying rm
How would I listen for item rename event (with anvil) and check if the item is a sunflower?
PrepareAnvilEvent
that will be called prior to renaming though, right?
I think to listen to "taking out the renamed item", its simply InventoryClickEvent
public void nomorerename(InventoryClickEvent e){
if(e.getInventory().getType() == InventoryType.ANVIL ){
}
}```
i have this now
now check if the clicked slot is the result slot, and if the clicked item is a sunflower
Ah, I thought they were just asking to check if the item in anvil is sunflower.
i think they want to detect taking out the "finished" item
how'd I do that?
yea
Ok, yeah then you're in the right place.
You can get the finished item by InventoryClickEvent#getCurrentItem [e.getCurrentItem()]
What do I put after this
I'm usually not one to force feed. I believe it is valuable to learn. Though,
InventoryClickEvent#getCurrentItem returns type ItemStack.
You can take that ItemStack and use ItemStack#getType and compare it to Material.SUNFLOWER
Well the problem is I cant really do ItemStack.getType
it just kind of doesnt exist
I'm sorry. I didn't mean to confuse you with the #. just do e.getCurrentItem().getType()
yea I know
its just getType doesnt exist after ItemStack
even after adding () ofc
nvm i got it
but now I cant do Material.SUNFLOWER
now sunflower doesnt exist
Weird
1.8?
am I doing it correctly? cause i also added this Player p = e.getWhoClicked() but it also doesnt work
?
Don't cast it. You need to make sure that that entity is actually a player before you assume so.
can it be anything else?
Yes.
ik
I believe it's always a player. Never seen it anything else
but yes the method returns HumanEntity so I guess do an instanceof check
Your if statement is a bit broken. You're attempting to use ItemStack#getType statically.
so what should I do?
Not to mention, you're supposed to be calling e.getCurrentItem().getType()
Overall, your statement should come out to if(e.getCurrentItem().getType() == Material.SUNFLOWER)
alright yea thats what i just got, so uh thank you guys ill test it
Now, there is only one more thing. ItemStack#getCurrentItem can return null so you'll just want to check that.
#help-server, and It really depends on the features you're looking for. I personally prefer more updated versions just because of the added blocks and customizability.
You can have 1.8 pvp in newer versions.
so uhh it works, thank you guys
?1.8
Too old! (Click the link to get the exact time)
it's only 11 major versions behind
If you want to even remotely compete with every new server out there you can't just use what everyone else does and expect it to work. You have to come up with something new and unique lol
for example a 1.8 pvp server
very original idea lmao
i dont even get why people like 1.8 pvp
it's basically just "no skill needed, just spam left click"
^^
Setting the damage for a crossbow?
got so many wins with my tripe click mouse
@tender shard Hello, I saw your post on nms mappings, is it a version that allows u to see the functions with the proper name or is it still a, b, c... etc?
it allows you to use the "proper" names
e.g. Mob.getNavigation() instead of EntityInsentient.b() or whatever
yeah... i was trying to create a armor stand entity...
you have to use mojang mappings to extend entity class
otherwise you'll get weird problems like "method x() clashes with LivingEntity#x()" and stuff
is it safe to apply that mappings on my current plugin pom or should I create a new project and try there first?
do you already use any NMS things?
nope, tried but that a,b,c,d 1.19 with barely any examples online isn't very good :Sadge:
you can just add everything mentioned in the blog post to your pom.xml then, it shouldnt break anythinig
even using both spigot and spigot-api dependencies?
i saw u are only supposed to have the spigot one after having Buildtools
yeah that's no problem. although spigot-api is basically useless if you add spigot directly, anyway
yeah it doesn't really matter. you can just switch from spigot-api to spigot with classifier "remapped-mojang"
no problem ๐
Is there a way to get tps?
yes but only with reflection
Okay
either reflection or NMS
Then how do I schedule a delayed task not in ticks, but in seconds? Should I assume that tps is always 20?
e.g. this is my 1.19 code ```java
@Override
public double[] getTps() {
return ((CraftServer) Bukkit.getServer()).getHandle().getServer().recentTps;
}
20L * seconds u want
well that's not 100% accurate unless the server always has 20 tps
is there a seconds way to do it tho?
java has method builtin to schedule tasks in "exact times"
gson sucks lol
yeah
had to write to many typeadapters to make it work lol
and it still gives me weird errors
if server is lagging, wouldn't the plugin lag as well by using that anyways?
yeah sure but just imagine your server is always at 10 tps
and now you wanna wait exactly 1 minute
then you can't just do 20*60 to get the correct amount of ticks
so just use java.util.Timer for stuff like this
is there any server.getTicks() * seconds?
or a ScheduledExecutorService
that's probably a better idea than using the normal java.util.Timer
why do we use Bukkit schedulers instead of that?
that seems to be better
because bukkit keeps a thread pool for you, which is handy
fair
creating a new thread is quite expensive
but no problem unless you do it all the time
create your own threadpool ๐
quick question a bit less to do with development, does verified role give extra chats access?
there's a verified channel, yes
I kinda don't want to link my discord to my spigot acc :Kek:
is it important?
smh
p2w discord server
I'm ashamed of my spigot account because of the bad plugins i released in the past, so I dont wanna link it
there is no player. brewing stands can brew even when no player has it open
you can only get a list of all players currently having this inventory open
just cast the Block to InventoryHolder, then do getInventory().getViewers()
i dont think that brewing stands have any titles
@tender shard I don't know where to ask this and search on google a bit but nothing good, is there any website with a list of particles and what they look like, like an image of them?
hm you can just check the javadocs for the Particle class but it's ofc without pictures
there's also a list on the MC wiki but it uses the "vanilla names", but includes pictures
yeah, i wanted pictures to see which one would fit better instead of keep trying all of them
i will look for that one, might be useful
but as said, those are the vanilla names
usually the spigot name is just the vanilla name in UPPER_CASE
(but not always)
is it possible to use interface which is implemented by main plugin class as main class in plugin.yml ?
main: path.to.interface
no
no
your main class obviously need to be the implementation
You can;t instance an Interface which is what spigot will try to do
oh okay, i get it
Hello, im looking for a rough price estimate for a plugin that includes the following:
.a command that gives you an item that allows you to shift click minecarts together (the command must have a cooldown of 5 minutes and only 15 minecarts can be attached together)
.a command that allows you to change the max speed of minecarts and the powered rail boost percentage
.vertical rails and upside down rails
.a new type of track that moves trains at 3 blocks per second that can be toggled on/off by redstone and right clicking
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/
What is the best way to make a count down?
You can use BukkitScheduler#scheduleSyncRepeatingTask.
I need one count down for the game end and for some events that I run while the game is running
I was trying to type the other ones but mobile keyboard not having it
lmao
I saw scheduler and bukkitrunnable
It really depends on the context of the situation.
anyways doesnt the spigot api has sqlite included?
For example the game have a max duration of 10 minuts, then I need to check the timers of every game (I think this is better than 100 different tasks) to check if the game is finished, and I need to run a task every 2 minuts of game
i'd use the scheduler to schedule a task and integrate that into your gameloop
It shouldnโt
ah someone told me that
I thought on this but if I have 100 games will have 100 tasks runnings, I think this isn't a good idea in performance
damn, finally got this ugly toasts working
Makes sense but also youโd always have a task running no matter what?
I think thereโs most likely a good middle ground here
About time. Use any NMS?
I believe it does
i believe these are all the libraries i currently have access to
Even if it doesnโt you can find drivers pretty easy
nope, but Bukkit.getUnsafe()
I think its better because almost all the time there will be games running
ah not the api just the Spigot jar has it my bad
ah meh
Anyways you don't need to access it directly
Then Iโd suggest scheduling a repeating task
Class forName is fine
If itโs already in the spigot jar just add the driver to your project and donโt shade it
dunno if i actually need the driver with hikaricp
with h2 i just did datasource.setDriverClassName("org.h2.Driver") so i might be able to do smth related
You do have to Class#forName() SQL drivers that you intend on using. I still do it even for HCP
I usually just throw in
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}```
Does it do more than just checking if the class exists?
It loads it
Part of me feels like it loads some static values in an obscure way
Class#forName() has two optional arguments, one of which is whether or not the class should be loaded. It defaults to true
But at the same time, It's usually an interface
i thought hikaricp does all that stuff
You honestly might be able to with the setDriverClassName()
just using DataSource#setDriverClassName now
Yeah, that method looks like it loads the class and creates an instance of it
Thing is the Driver class is usually an interface
So I wonder what would we be loading in that case?
com.mysql.cj.jdbc.Driver is the implementation
I see
oh
Makes sense
alternatively, just use the service loader.
Whether that makes sense, I donno
Raw Java stuff. Not related to Bukkit
raaaaawr
The music of Kahoot lobby for 10 hours
Kahoot website on: https://kahoot.it/#/
@iron glade
My programming soundtrack
my soundtrack is to have The Office running on netflix
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
whatever I feel like
listening to french rap lol
I've listened to lloyd banks - warrior part 2 on repeat for 6 hours straight
did a lot of work that day
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player p) {
if (args.length == 1) {
try {
Integer.parseInt(args[0]);
if (p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= Integer.parseInt(args[0]) * 2) return false;
} catch (NumberFormatException e) {
p.sendMessage(ChatColor.RED + "Tu precisas de especificar um nรบmero para levantar");
}
}
if (p.getGameMode() == GameMode.SURVIVAL) {
ItemStack heart = new ItemStack(Material.NETHER_STAR);
ItemMeta heartMeta = heart.getItemMeta();
heartMeta.setDisplayName(ChatColor.RED + "Coraรงรฃo");
heart.setItemMeta(heartMeta);
p.getInventory().addItem(heart);
double pHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(Bukkit.getServer().getPlayer(args[1]).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() + Integer.parseInt(args[0]) * 2);
}
}
return true;
}```
im doing a lifesteal plugin and now im doing a /withdraw command
and i want like: /withdraw 3 and give me 3 hearts
I swear I've seen a commission for health bank notes
but at the same time, all text contents are in portuguese
im portuguese
Would it be possible to force a spawner to load/work?
So am I, still recommend to make a .yml file for messages
eu gosto de fazer assim, o plugin vai ser sรณ para mim por isso sei onde estรฃo as coisas
english pls
^
^
what does the getHandle method do in CraftBukkit classes?
i like to do that way, the plugin is just for me and i know where the things are
lets not parse it twice lol
Return the nms instance
aight
CraftWorld#getHandle would return ServerLevel for example
what
parseInt twice
also man doesnt return whenever you catch a numberformat exception
ehh
that can cause problems later
catch (NumberFormatEx) { pl.sendMessage(aaaaaaaa); return; }
catch (NumberFormatException e) {
p.sendMessage(ChatColor.RED + "Tu precisas de especificar um nรบmero para levantar");
return;
}
like this is good
the blockstate of a trapped chest is instance of Chest?
it says an
ah return true
?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.
i believe so
Can I put a license on my plugin so people won't spread it for free?
if(state instanceof Chest && state.getBlockData().getMaterial().equals(Material.TRAPPED_CHEST))
Licenses won't stop pirates because pirates can't read
ig block.getType() == Material.TRAPPED_CHEST lol
.
๐ฅฃ
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
because you get to do productive stuff like look at bee code for 3 hours
lmfao
beatyoutooit.png
No. I mean that people have to buy the plugin for themselves and not their friend to give it for free. I want to put that kind of system.
You can't
Why?
Because it's java. It's not hard to bypass it
For every 100 hours you spend writing a solution it will take only 1 hour for someone to bypass it
I am not bypassing anything
Reread it
no need to stress over that one plugin that won't reach 10 sales
it's like premature optimization
if it ain't broke, don't fix it
if there is something more fun
than helping people with nms
it obviously is rebuilding an obfuscated plugin's source
So it is allowed if those steps are followed?
obviously, yes
Yeah I guess
for paid plugins only though
Still a waste of time
Well, but I can get more sales.
No you really won't
in theory yes but in practice no
if you want to be a greedy mf and spend every hour of your live making your customer's life hell
for spreading a plugin
that's on you
But those same customers will just view you as greedy
Also nothing guarantees you'll have sales
I think that is outdated.
I've had a premium plugin on sale for 4 months and no one has bought it
but I also did a terrible job marketing it lol
What was about?
Inventory syncing across servers
I think not
instant with fail safe logic
why would be outdated
I have 3 free resources and I can't post premium.
Do you meet the other requirements
21 positive ratings
do you have 80 messages + 20 positive reactions?
oddly specific
Yes
Yes.
Yes
2fa too?
Yes
In the five years which we have run this section for, not once has a user failed to be promoted within one hour of meeting these requirements. Do not contact us about being unable to use this service.
Nice comment
I mean
it seems nice
but in reality
they have taken like 2 hours to promote me
sooo
wtf i thought it's automatic
Also looking at goldenmine's code, this doesn't seem to have the quality to actually go premium
I waited a few days from my last check .
Have you seen the code of other premium plugins :p
It's usually very bad
It is automatic ;p
if you always code like this, you will definitel yjust get rejected
Also, way longer than 5 years at this point
how come that automation isn't instant choco
Why is that?
๐ฅณ ๐ฅณ ๐ฅณ ๐
It's likely run on a cron job
One that isn't run every minute lol
because why would it
because your code is pretty amateur
imma get that guy to make a full soundcloud rap about you
copy pastes of the same things for hundred of lines, e.g.
I'll just leave this thread made by our lord and savior choco


