#help-development
1 messages · Page 1701 of 1
damm that’s a shame
i really wanted some money
i don’t really see the issue with it if they consented to it
but eh nvm
I highly doubt anyone would actually enable a cryptominer
What about a plugin that just makes every block pink concrete
Wow hi md5
That's the first time I've seen you in the help channel
Lol ig he's just never on when I am
what's the easiest way:
i would like to check if no-one joined the server is last hour (like the server is empty for 1h)
just store the time of the last leave/join and then every 10 minutes or whatever check if that time is over an hour
actually you can just store it if that leave drops the player count to 0
so if the last player leaves store the time they left
It probably needs to be mapped anyways
Maybe a Cache<Integer,E> where Integer serves as the index?
if you use caffeine it’s possible to add a remove listener
or just reuse this as a set and use the lists hashcode as the key
then you have your "collection"
Which then removes the element from a list or smtng
will try, i suck in java tho...
Ok if you need more help dm me
The list implementation could be a LinkedList as I assume you might want add to be O(1)
I'm surprised I've never come into this before, but can you force a block update?
Block#update() ?
BlockState#update()*
and uh
im kind of noob, im not sure what im doing
if you cant tell, im trying to make a minutely rewards system...
im definitely not doing it right
Tried that, doesn't seem to work
theres 20 ticks in a second
so
and 300 seconds in 5 minutes
why not just make a runnable that runs every 5 minutes
because thats not gonna work?
if someoen joins halfway through 5 minutes that runnable is gonna give them shards next time it runs
not next 5 minutes
not at all???
why not do it for 5 mins loop and when a player joins in they get assigned a separate non-repeating task before being put it into the 5 min loop
so save the 5 minute loop into an object and the list of players attached to it
when they join create a runnable and when they leave stop it
save their time too
obviously
yeah
btw hitbuns love your pfp
did you make it yourself? or is it from a clip
ahhh nope just thought it looked cool
oh its from a gif i found
oh thats cool
Hi, I would need some help, in fact, I made a custom event, and for some reason it doesn't seem that it cancel it when I do e.setCancelled(true) (the event implements cancellable of course)
here is the custom event
how did you link it back to the section you used the event
did you remember to also call the event
register listeners
so everything works now right
public class VehicleInputListener implements Listener
{
public VehicleInputListener() {}
@EventHandler
public void onVehicleInput(VehicleInputEvent e)
{
e.setCancelled(true);
System.out.println("HI ! " + e.getInput().name() + " " + e.isCancelled());
System.out.println("Nice ! " + e.getPlayer().getName() + "\n" + e.getVehicle().toString());
e.dismount();
}
}
what about the part where you called it
the e.isCancelled() inside the sysout does return true
but
if(move != null)
{
final VehicleInputEvent vie = new VehicleInputEvent(event.getPlayer(), move);
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(vie));
System.out.println(vie.isCancelled());
event.setCancelled(vie.isCancelled());
}
it returns false
I don't get why
To make it sync
k
cause events needs to be called sync
my guess is that you're calling it async then sysout before its called
its his own
PacketEvent
i see
PacketEvent is async I guess
So, the async task goes "faster" than the synced one and it sysout before having it called. Well, just need to make it sync then x)
its simple
K
👍🏿
so i got ntohing but bad ideas for a response to this, im not sure how i can make this work - any ideas that dont involve making runnables whenever someone joins?
What are you trying to do ?
.
@quaint mantle
i literally explained why that wouldnt work
give people shards every 5 minutes after they're online
ye as i was saying you can put them on a separate non repeating task
when they first join
make a list of player with the actual play time, at the 5 min mark give them
you can do it with an unique scheduler
so thats sort of what im doing i think?
im really not sure
nope
shardsloop is just HashMap<Player, Long>
You're making a scheduler per player aren't you ?
Oh lmao
UUID, Long
its what im trying to not do
ah
i'll use UUID, thats not too big of a big problem
#English
i just read somewhere to not use Bukkit API in tasktimers somewhere lmao
Don't interact with it, but you can get infos
that's not a problem
ohhh
okay
as for the time check.. is that mostly right?
alright
5000 isn't 5 seconds in a bukkit runnable
100L is
cause it works on ticks
Would be too precise for the actual server to run
yup as 20 is 1
meaning 6000L should be 5 minutes?
yes
okay coollllll
a 5 minute loop would suffice as long as you have a player join separate non repeating task at the start which then puts them back on the 5 minute loop
Ok, now the sync is ok, but the async event isn't cancelled 🤡
i dont understand
I mean, when I do cancel the event, it seem that it already happened async and so it doesn't seem to be cancelled when cancelled by the sync task
Like, if the PacketEvent would be cancelled, the player wouldn't be able to jump for example
are you sure it would be 6000 @opal sluice
if I cancel it directly inside the async task, it does cancel it properly
oh yeah nvm
20*300 = 6000
but if I cancel it inside a sync task, it does not cancel it, or it does cancel it but after that the event happened (the player has already jump)
ok im able to do some testing now my power is back
and nothing is null there
hey guys
how would i make a custom world generator that only has river, plains and forest biomes
or well
only set biomes
Oh
Can't you make custom worlds with a datapack now?
Maybe you could do it that way
You can, yes
how can i uh.. fix this
im following a tutorial for the most part, at least now i know my events /run/
just not sure how to fix that
i can send the entire error if needed but it happens with every event right now
first go search what that is
zip file closed?
btw ankle
yeah... nothings corrupt, nor bad in the JAR file
give us the events that it is happens right now
GuildMessageReceivedEvent
well it did something actually?
nvm
wait dont you have to .queue() it
or something
.await() i fforgor
hold on
do u mind to give the code?
tbh no LMAO
let me try this .queue magic real qucik
make sure im not going crazy
yeah im juist an idiot, i just had to .queue(), thanks
lmaooo
Oh yo, you found the problem? @proud basin What was wrong?
how do i sort a hashmap by its value
You can’t sort a hashmap
already did
Yeah you can get the values into a collection and sort that
I was returning a value
Using treemap
Lol i dont know what do you mean by that until u ping me lol
Could you show us pls? Im curious on how you sorted a HashMap...
kk
btw i copied code
lmao
but here
lemme get it
Stream<Map.Entry<UUID, Double>> stream = money.entrySet().stream()
.sorted((k1, k2) -> -k1.getValue().compareTo(k2.getValue()));```
uh its sorta like that
i was sorting player balances btw
making /baltop
prob not most efficient
Ah ok you just sorted the entry set.
but hey
yep
also is there a better way to do this
final int[] i = {page};
stream.forEachOrdered(e -> {
if (i[0] > page * 10) {
return;
}
p.sendMessage(i[0] + ". " + g.getNameByUUID(e.getKey()) + " - $" + new DecimalFormat("###,##0.0#").format(e.getValue()));
i[0]++;
});```
i dont like using final arrays lol
it feels a bit hacky but i wouldn't know
AtomicInteger from java or MutableInt from apache.
As you dont need multithreading you should go with MutableInt
MutableInt pageMutable = new MutableInt(page);
... {
int pageVal = pageMutable.intValue();
...
pageMutable.increment();
}
ah
alright
MutableInt pageMutable = new MutableInt(page);
stream.forEachOrdered(e -> {
if (pageMutable.intValue() > page * 10) {
return;
}
p.sendMessage(pageMutable.intValue() + ". " + g.getNameByUUID(e.getKey()) + " - $" + new DecimalFormat("###,##0.0#").format(e.getValue()));
pageMutable.increment();
});```
that?
oop
Yeah
is there a way to get the spigot.yml (or bukkit.yml i forgot) no-permission message?
can't u use a SortedMap for the money variable instead of creating a stream then sorting the stream ?
idk
im not bothered to look into that lol
it works fine
String msg = Bukkit.getPermissionMessage();
oh lol tyh
ty
if i change that in spigot.yml, will it use that
It uses whatever was in the config when the server started.
Condition 'Bukkit.getOfflinePlayer(args[0]) != null' is always 'true'
im just gonna ask questions lol
im bored
Also:
oh nice
im trying to go full custom 👀
we'll see how it goes
well apart from worldedit, worldguard and lp
getOfflinePlayer will always return an OfflinePlayer.
It will first check for an online player
then check in the offline player cache
then check all profiles on the disk
if there is no data available it will query the mojang API and create a new profile.
So it will return an OfflinePlayer no matter what.
This method can be quite expensive if the player is not online and not in the player cache (about the last 10.000 players which connected)
oh
would hasPlayedBefore() work?
Work to achieve what exactly?
im trying to make my /bal command support offline players
and check my yaml file
You should be fine for the most part.
Hello, I get an error on a plugin using it with a modified spigot, and I know that all other plugins that use packets work but this one doesn't and the error comes from here
@SneakyThrows
public static WrappedClass getNMSClass(String name) {
Pattern toTest = Pattern.compile("\\." + name.replace("$", ".") + "$");
for (String className : classNames) {
if(!className.startsWith("net.minecraft")) continue;
if(toTest.matcher(className).find()) {
return getClass(className);
}
}
throw new ClassNotFoundException(name); // line 71
}
``` (the error is from line 71)
what are other ways of getting a NMSClass
an example for "name" is "Packet"
Check timestamps on access or with an executor service.
sorry why this line still threw java.lang.NullPointerException (line: 2) in the code:
1 | team = scoreborad.getTeam (TeamHelper.getColorFromEnum (color) + arenaName);
2| team.setColor (ChatColor.RED);
Cannot be null.
because this calls an error that already exists: team = scoreborad.registerNewTeam (TeamHelper.getColorFromEnum (color) + arenaName);
well it can
the error says it
sure the variables are always the same??
ok i try
yes
hmmmmm
otherwise the plugin would write that they are different and copy them
sorry value is null, i stupid
team = ScoreaboadManager.InitTeam(team, this.name, Colors.red); //input parameter team is null
I didn't check the arena class I forgot about it
Hey I am currently trying to change the knockback of a mob attack.
I am able to import the Attribute Enum but not use its values...
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 have an idea for a plugin, but I think I will need to learn about custom world generation.
The idea:
The plugin generates a world where dirt and diamonds are switched. How would I do this? Thanks in advance.
ItemMergeEvent
- Get an AttributeInstance
- Either change its base value or apply a new AttributeModifier
.poll() means you get the first thing in the deque and it get removed right?
yes
okay thank you
the addItem method in inventory doesnt require any check to see if the inventory is full ?
Explaining it a bit more I was overwriting it and that’s why it was returning null
how to change the durability when the setDurability method is depreciated
hello
((Damageable) ItemMeta).setDamage(int)
anyone know how i can protect my database from sql injection?
Meta, not itemstack
👍
Would it be possible to calculate how a player's y level would change with a certain y velocity?
Sure. The velocity is just a vector with length N and i believe that every tick the velocity is just added to the players position.
So let's say the y level is 0.0 and the velocity 0.2 the next tick the y level would be 0.2?
Yes
Alright ty
I thought about it a lot now. Dont I need to calculate every path possible to be able to tell which one is the shortest?
No
you could use baritone's path finding "way"
No point in appealing unless you have fixed the issue
I did fix the issue for which it was deleted
you mean this one? https://github.com/cabaletta/baritone
👍
see how they do it
probably the best way
and translate that into the spigot api
okay I will try that
I think they just use A*
Pretty sure actually
Or a surface linked Theta*
Yep
Thats so much code tho what do I need? Do I need everything?
Dont copy that. Its not abstracted enough so you wont be able to just translate it to spigot.
Hm. Maybe it is.
I am kind of overstrained
One moment ill give you a simple example using spigot blocks.
thank you
guys
I have PlayerInteractEvent called 2 times. how can I fix this?
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
Action a = e.getAction();
EquipmentSlot h = e.getHand();
if (a != Action.RIGHT_CLICK_BLOCK)
return;
if (h == EquipmentSlot.HAND) {
p.sendMessage("HAND");
e.setCancelled(true);
}
else if (h == EquipmentSlot.OFF_HAND) {
p.sendMessage("OFF_HAND");
e.setCancelled(true);
} else {
return;
}
}
It gets called for each hand once thats why you get it called twice I think so
.
I did it like this:
if (event.getHand() != EquipmentSlot.HAND) {
return;
}
no
.
Any idea what java.lang.NullPointerException: Cannot invoke "org.bukkit.Material.getId()" because "type" is null means?
your "type" variable is null ?
It's not though
show the code and the line its shooting the error on
it should be enough
Oh sorry, wasn't setting the variable in the constructor. Sorry for wasting your time.
you have a variable that is null xD
yeah
I was doing material = material; instead of this.material = material; lol
Ok well now ItemStack.setData(new MaterialData(byte)) isn't working
anyone know how i can protect my database from sql injection?
Is that what PreparedStatements are for?
I never really understood their specific use-case
yes, it sanitises any values it inserts
Oh, awesome. Learn something new pretty much everytime I click this server
So I'm serializing an item to a json string but when I try to parse it back into a json object it errors...
Map<String, Object> serializedItem = i.serialize();
String serializedString = JSONObject.toJSONString(serializedItem);
p.sendMessage(serializedString);
JSONObject objectMap;
try {
objectMap = (JSONObject) new JSONParser().parse(serializedString);
ItemStack desearlize = ItemStack.deserialize(objectMap);
p.getInventory().addItem(desearlize);
} catch (ParseException e) {
e.printStackTrace();
}
Parsed string:
{"v":2730,"type":"DIAMOND_PICKAXE","meta":UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name=[{"text":"Testing","italic":false,"color":"gold","bold":true}], lore=[[{"text":"","italic":false}], [{"text":"Testing","italic":false,"color":"gray"}]], enchants={DIG_SPEED=5, LOOT_BONUS_BLOCKS=3, DURABILITY=3}, ItemFlags=[HIDE_ENCHANTS, HIDE_UNBREAKABLE], Unbreakable=true, Damage=1560}}
Error:
Unexpected character (U) at position 42.
It doesn;t understand UNSPECIFIC_META
For BukkitScheduler#runTaskTimer:
Delay should usually be 0, or what?
Period is in ticks I assume?
why would it crash it?
Ah. I'm blind lol
Should I string value it or... How should I fix that?
I thought that was the delay for the time after it starts for the first time
or similar
If my period is 0 that would certainly crash it, no?
you could try that, its just expecting a value or an object
Not seeing any deserialize for ItemMeta... I see ItemMeta.serialize()
just ping me if you got it so I wont miss it thank you
So can only convert itemmeta to a string/map object but can't convert it back into itemmeta?
Why are you not simply serializing the ItemStack?
... I am but clearly I can't just parse it to a json string as shown above
ItemStack itemStack = new ItemStack(Material.STONE);
Gson gson = new Gson();
String message = gson.toJson(itemStack);```
when opening up an inventory, can I somehow tell the client not to show the players own inventory?
now convert it back
Not tested but try ```java
Gson gson = new Gson();
//Serialize
String message = gson.toJson(item);
// Deserialize
Map<String, Object> map = gson.fromJson(message, new TypeToken<Map<String, Object>>(){}.getType());
ItemStack is = ItemStack.deserialize(map);```
for something to be actually drawn on screen the class has to extend GuiScreen correct?
For persistant storing of simple data, is scoreboard or persistentdataholder better ?
String message = gson.toJson(item);
Caused by: java.lang.AssertionError: java.lang.NoSuchFieldException: ARMOR
sec and I'll test
Yeah testing with item.serialize() instead of just item
Why not just use a type token of ItemStack and pass that as the serializer/deserializer
yep
Also use a GsonBuilder where you can pass complex object serializers like a type adapter of ItemMeta
So... Map<String, Object> map = gson.fromJson(message, new TypeToken<ItemStack>(){}.getType());?
Gson gson = new Gson();
//Serialize
String message = gson.toJson(drop.serialize());
// Deserialize
ItemStack is = gson.fromJson(message, new TypeToken<ItemStack>(){}.getType());```Seems to work
at least on a simple object like sand
Didn't work for me.
Item testing:
minecraft:give @p diamond_pickaxe{Damage:1560,Unbreakable:1,display:{Name:'[{"text":"Testing","italic":false,"color":"gold","bold":true}]',Lore:['[{"text":"","italic":false}]','[{"text":"Testing","italic":false,"color":"gray"}]']},Enchantments:[{id:efficiency,lvl:5},{id:fortune,lvl:3},{id:unbreaking,lvl:3}],HideFlags:5} 1
[15:51:00] [Server thread/INFO]: ItemStack{SAND x 2}```
Oh my bad you're doing ItemStack instead of map. let me try that
hi
i finish my first plugin
in intilej
how i can export it
to my server files
are you using maven or gradle ?
maven
open your "maven" tab on the right side of your screen usually
find the goal "package"
and just double click that
intellij should then run the required maven command to package your plugin into a jar
ItemStack is = gson.fromJson(message, new TypeToken<ItemStack>(){}.getType());```
`Caused by: java.lang.RuntimeException: Unable to invoke no-args constructor for interface org.bukkit.inventory.meta.ItemMeta. Register an InstanceCreator with Gson for this type may fix this problem.`
`Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: org.bukkit.inventory.meta.ItemMeta`
yep I just tested on a more complex item
Yeah so my next test was to just serialize and desearilize the ItemMeta instead of the whole item. But there is no ItemMeta creation method off a string or map. (Deserializer)
At this point it looks like I might just have to make my own.
what does the luck enchantment does ?
Can someone please send an in depth tutorial on how to manipulate and create custom world generation?
any fix for this??
how the inventory gettype method can produce nullpointerexception ?
When the inventory is null.
can InventoryClickEvent's inventory be null ?
Of course when you click outside the inventory
then you didnt clicked on the inventory
You did. Just not in an inventory
bruh
Hence... its null
and what is the inventorytype for disenchanter
IDK you're gonna have to search for that lol
i have question
what pathfinder goal should i set
so an entity attacks any player
other than you
You probably have to implement a custom one
But use the same logic as the normal attack one and target goal, just change it a little bit
Like what it may target (:
NearestAttackableTargetGoal takes a Predicate, you should be able to use that to filter out any players you don't want it to attack
i dont know how
Oo
Is there a specific reason spigot chose not to implement Cancellable for EntityDeathEvent?
A predicate is a function which takes an argument in this case an entity and returns a boolean, basically a function that acts like a filter
what is that in 1.17.1
Well, look at how Mojang does it. That's just how it is with NMS.
They're creating a Goal for this (which in this case is a Zombie), telling it to Attack turtles (Turtle.class), at a random interval of 10, it must see the Turtle but doesn't have to "reach" it (true, false), and the Turtle must be on land. (Turtle.BABY_ON_LAND_SELECTOR is the predicate for "this turtle must be a baby AND on land for the zombie to attack it.) You'd use the Predicate part to filter the player.
Because its post death
You can use the damage event if you wanna cancel a death
Ah, so papermc made it pre death?
Presumably
thx
You're gonna have to find all the obfuscated names if you're not using MojMaps, makes it infinitely harder to work with NMS.
👍
Hey guys! How can I check if a chest is part of a double chest, and then get the location of both sides of it? I have already tried casting to a DoubleChest and then using .getLeftSide().getInventory().getLocation() and .getRightSide().getInventory().getLocation() but those always output the same location. Any ideas?
Well Geek the chest has one inventory
That is what I figured, but then what is the point in the rightSide and leftSide :P
clicking types?
Hmm believe the holders still are for the different locations
Actually it might be a bug
unfortunately, doubleChest.getRightSide().getLocation() doesn't exist...
it gives me the location directly in between both sides
Oh ok
so idk mby there is a more manual way of just checking if it's connected to a chest, then checking for direction, and then getting the block shifted by 1
would you count a DoubleChest as a BlockState?
Yeah sounds like a doable workaround since the api seems to behave somewhat oddly
Ok now the question is, how do I check which direction half a double chest is facing :P
nvm
yeah I have, which is why I figured the rightSide and leftSide should give different locations... but alas
can you show me how your casting DoubleChest?
?paste
instead of if (chest.getInventory().getHolder() instanceof DoubleChest doubleChest) try something like this if (chest.getInventory() instanceof DoubleChestInventory){}
awesome!
Another question:
On some occasions I cancel a block break event. However when breaking a double chest half of it looks detached from the other side after the event is canceled until I interact with it again. Is there some solution to this?
How are you breaking it
how should i fix this?? (there are two symbols that mustn't be here :|
fix your encoding
if u r not coding anything then #help-server
heyyy
u actual command geek?
Anyone who can spoon feed me?
I need help in this intializing I dont get it
In making a custom items and then afterwards Initializing them
can someone help me with it?
be patient, one message suffices
I will just ask and sorry for ping but is asking for spoon feeding allowed here? I got taunted in another plugin development help discord in which because I am not a pro and not even at a level of noob so I didn't got what they meant and when I asked can you edit the code and give me which will help me understand what you meant then they said we wont spoonfeed
So I will ask first
it is allowed but a naive way to solve your problem
it will just solve your issue superficially which is the long term problem (spoonfeeding)
so I am starting java along with bukkit api and I came acrosss some other professional devs which did same
yeah
its not rude but spoonfeed, people will less likely help you
because I thought it makes it easier for both
soo okay
in another server I asked for help but the person was just saying Initialize Initialize and i didnt get it
it doesnt
Okay thankz
I think theres a big difference between spoon feed where you want to get the exact code you need and asking for an example because you can understand the code easier then
I read all basics of java and tried to learn some as well but I did not come across Initialize
Yea well I guess spoonfeed is that they fill up the spoon and put in your mouth
What don't you understand about initializing
Because if u spoonfeed youll learn scarcely anything, and then you'll come back the next day asking for more, its a continues evil circle
Hiya. When looping through player.getInventory().getContents() ItemStack is null, do you know why?
While Non spoon feed would be they teach us how to fill up a spoon and put it in our mouths oursellves
Hmm Yes I guess
yes
can you take a look at my code however and explain what I should do?
and what Is initialize
what code?
Making custom items
?paste
Hiya. When looping through player.getInventory().getContents() ItemStack is null, do you know why?
oops
didnt mean to send again lol
How are you using ItemStack?
public static int getHowMuchPlayerHasOfItem(@NotNull Player p, @NotNull Material material) {
int count = 0;
System.out.println(p.getInventory().getContents());
for (ItemStack itemStack : p.getInventory().getContents()) {
if (itemStack.getType() == material) {
count += itemStack.getAmount();
}
}
return count;
}
Line 3 I was just double checking it wasn't null
this? for (ItemStack itemStack : p.getInventory().getContents()) {
About my prob Imma check some tutorials and try to find myself
as I guessit will be less annoying
Line 5 triggers the error
if (itemStack.getType() == material) {
This error:
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "itemStack" is null
well
you need to add a else statement
no
you need to put their contents in a itemstack list
if statements do not require else statements
wdym
oh actually
let me try something
kk
Ill be able to help in 50min or so
Jtx sorry for ping but in the code he gave if the inventory has no items then value = null right?
yeah I'd put the ItemStacks in a list
but then it wouldn't even loop
so if we add a else statement saying if its null and then run its specific action wont that work?
Oh Hmm I guess I will leave it to pros
so ItemStack[] inventoryItems = p.getInventory().getContents()
Maybe its not detecting it?
But why does it even need that, it's just unnecessarily storing a variable
then you can do for (ItemStack itemStack : inventoryItems) {
Oh I guess you are making this in a util form
yes
that's pretty much what I'm doing
Nvm I still dont get it properly I will first learn.
does the player have a single item?
yes....
still doesnt work
ok let me open up my ide
ok
Hi, any ideas what can be used in order to remove Elytra from End Item Frames?
Like they never generate EVER.
Turns out I do have to null check ._.
Sometimes I hate the Bukkit API
I also needed that once but dropped the idea to first try basics
^
I wanted to make a custom item and auto generate it as loot in end and nether forestress
Can spigot detect if you hit middle click if you’re not in creative
You either modify the world generator,or listen to chunk generation and check for it,it is afterall a entity so it can be easier to get
I think if you add it that if the event detects the item in the player inventory it will auto remove it
So upon generation obtain all entities in that chunk if instanceof ItemFrame and contains Elytra remove?
Hmm
yep
Maybe a event to check any items frames with that item
considering the chunk itself has a getEntities inside it
And then get the location of it and break it then use kill item to kill the item in a radius of 2 or 1
I'll try that out just now and see if it gives any results
best bet for the generation one
if you listen to all item frames you risk deleting ones placed by the player
Yeah i know
Yea but dont you wanna disable the item itself?
No
Oh then I guess my idea is wrong in that case 🙂
fixed what?
Literally going to bathroom refreshes your mind like pressing a refreshing button on a hanged site
The error in custom item
It was not being registered in recipes
oh cool
now i can finnaly continueeee
?stash
also jtx care to help me tmr with a thirst plugin ?
I need some help on variables if you know
uh
Did they removed the checks if the World == END world? Or i'm just being unable to find it?
i couldnt find any tutorials and any help info
do you know about finallized or yml saved data files?
well yea I used 5 - 7 tutorials and stacked em together to fix it
tmr I may need help
I will need help on making a file like a config file to save player thirst data with uuid
ok
I will use both uuid as first priority and username as second priority so that it may work on cracked if needed to
Gunna be real hard 😦
gn...
and wrong channel
use InventoryClickEvent
I think he meant middle clicking a player or block
then use PlayerInteractEntityEvent
uwu cuties
if i get the getClass of an object
and the class of a class
and use them as key for a map
will they be the same?
the class of the class wait my brain goes brr
you mean obj.getClass() and this.getClass() inside a class?
the classes will be the same if obj instanceof getClass()
object.getClass()
ObjectClass.class
its the same
:D
yes
every class has a Class<ClassName> instance which can be used as an identity holder
However invoking this.getClass() might at runtime return the Class<? extends ClassName> instance of a subclass
hence the extends
how do I stop a player from dropping items onDeath
Listen to the PlayerDeathEvent and clear the drops
i realy want to know what does this do in worldguard source code so i can change it to a runnable
that doesnt makes sense
yeah how do i clear the drops I already have a player death event
if there is an else sure
event.getDrops().clear() i guess
check the e.getDrops()
yes
oh thanks
can somebody explain me this ?
It just seems to do nothing. It checks if the player location changes after he moves. And then it does nothing.
so this tells us a lot about worldguard code being clean
if the player didn't move return
but nothing happens after
probably something was there but then it got removed
so
its this the code
that ruined the server's performance
with just 2 regions ?
doubt it
no
why do you even use it?
its in worldguard source code
it should be in every plugin that monitors the move event
Makes sense
the playermoveevent is annoying
i think that's a bigger check
much heavier, and no, as that would not early exit
it would allow for minor movement including head movements
bruh wait
wait
it was not only that
it had more than it below it
eyesight power 100
That code is to optimize the move event and prevent it running when it doesn't need to. That code is perfect.
you mean !event.from().equals(event.to())?
unless block positions are cached, I don't think != would work.
from and to are not block positions, they are Locations, so bad to use them to test, which is why it uses getBlockX etc
hmm yea
Yeah. getFrom() and getTo() are Location instances which aren't rounded. The slightest movement would allow the condition to pass
true
Though that method above only cares to call once a whole block position was changed
Could call getFrom().getBlock().equals(getTo().getBlock()) but that's then creating an unnecessary CraftBlock middle-man instance just to perform the same comparison
So yeah, compare getBlockXYZ()
Can someone tell me why this Gradle build file does not work:
...
repositories {
maven {
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
content {
includeGroup 'org.bukkit'
includeGroup 'org.spigotmc'
}
}
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
mavenLocal()
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' // The Spigot API with no shadowing. Requires the OSS repo.
/*
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0'
*/
}
...
Really? What do you think it is.
so where is the getTo method
Its not cancellable so the action has already taken place.
i want to check the new world
that the player just teleported to
should i check the player's world ?
the players location is IN the new world
Ok thanks
anyone know a plugin which will let me have multiple economys
e.g. Tokens, gems, money
/tokenbal
/gembal
/bal
i did look at that but they all use the same bal command
hmm
with the PlayerDeathEvent event, is it possible to also get the thing that killed the player, I've looked at the docs and there are no methods to do so.
Hello where can i find a tutorial for create my first plugin based on maven ? Thanks for help
im playing around with protocol lib, is there a recommended way to debug packets that crash my client when the server sends bad packets
looks like there are more helpees than helpers
is there an event.getDeathSource()?
I've looked at the docs and there are no methods to do so
too lazy to open my ide
bruh, its opening very fast, why not do it
intellij is opening for me like 3 seconds
I have intel core i5 8th gen
😳
With minecraft, discord and firefox ran
IntelliJ is absolutelty fine in terms of memory consumption

indexing...
analyzing...
I can write code while indexing 😂
That happens once on launch, then you are fine
this, though you will not have any IDE features other than that
Not even syntax highlight if I'm not wrong
i can but it doesnt shows the tabcompletions
bruh
^
Put the api key into the config, there no one sees it
whats an api key 🤔
there is no safe way to include an API key
Yes they can?
what? everyone can see a config file
That is the point of a config
exactly
I don't understand what the holy fuck is going on here
bruh
The best way to do it probably would be for the user to get their own API key and give that to your plugin to use.
config.yml is accessed by everyone.
They need to pay for it then ¯_(ツ)_/¯
¯\_(ツ)_/¯
Or, you could use something like a password hash for the api key
So no one could access it
It would probably be better to not comment 🙂
comment :/
you could create a own api to access the api key on a secured way idfk
encrypt it 🧠
thats about as "safe" as you can get, but thats still not safe. You have to decrypt it to use it
two awesome quotes from the 2nd stupidest guy i've seen on this server! "No one can access the configuration file" and "Then don't put it in the jar"!
I just though, who the fuck would decompile a plugin to get access to an api key
No, just don't tell them about the key
No one would do it then
Someone will find it. every plugin gets decompiled
thats what I was going to say, you just type faster than me
then obfuscate the plugin, add a lot of artifacts. Add fake api keys. Etc.
Safer, but still not safe. at some point the key gets used. It can be read from memory
someone will find it then everyone will
Then just create your own api instead of using the one with the api key
THE POINT OF AN API IS SO YOU DON'T HAVE TO DO SOME OF THE WORK DUDE
this guy bro
just leave the chat
You can do what Mojang did in 20w14infinite :p
We could probably advise better if we knew what API it is
They had a string encrypted in the jar
A api is a programming interface
A lot of people worked to try and crack it :p
This is supposed to Teleport a player to spawn when they join, anyone have any idea where I have gone wrong?```java
package me.Teric7.PlayerJoinTP;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
public class PlayerJoinTP extends JavaPlugin implements Listener {
public static PlayerJoinTP plugin;
public final Logger logger = Logger.getLogger("Minecraft");
@Override
public void onDisable() {
PluginDescriptionFile pdfFile = this.getDescription();
this.logger.info(pdfFile.getName() + "§cHas Been Disabled");
}
@Override
public void onEnable() {
PluginDescriptionFile pdfFile = this.getDescription();
this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion()
+ " §aHas Been Enabled");
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
this.getServer().getPluginManager().registerEvents(this, this);
Player player = event.getPlayer();
double x = 0.50; //This is the spawn coordinates
double y = 65; //This is the spawn coordinates
double z = 0.50; //This is the spawn coordinates
Location spawn = new Location(event.getPlayer().getWorld(), x, y, z); //Spawn location
player.teleport(spawn); //This should have teleported the player to spawn
System.out.println("§6§lThis Player Got Teleported To Spawn");
}
}
It was a float :drunkcat:
delay your teleport 1 tick
alr
don't ask for us to fix your code for you tho
I got told that 1,000,000 times or more
^^^
You can use the damage event
yes, but I only want to get it when the player is killed
getKiller() is just the Player that killed them, not any cause
thanks
Ok so this is what I got. From what I can tell it's not actually checking the PlayerJoinEvent or it would've sent a message in console
Code:
@EventHandler //joinevent
public void onPlayerJoin(PlayerJoinEvent event) {
System.out.println("§aJoin Event works?");
this.getServer().getPluginManager().registerEvents(this, this);
//scheduler
getServer().getScheduler().runTaskLater(this, new Runnable() {
public void run() {
Player player = event.getPlayer();
double x = 0.50;
double y = 65;
double z = 0.50;
Location spawn = new Location(event.getPlayer().getWorld(), x, y, z);
player.teleport(spawn);
System.out.println("§6§lThis Player Got Teleported To Spawn");
}
}, 20L);
Console:
[21:35:01 INFO]: Teric7 joined the game
[21:35:01 INFO]: Teric7[/80.233.57.76:10863] logged in with entity id 2164 at ([world]7.143007547713338, 65.0, 10.132142567622157)
I don't need the cause so getKiller() is fine
So it's not registered then
You are regsitering the event IN the event. register it in onEnable
ah xD
lol didn't even notice that
UUID
I need to add an attribute to a player without them holding an item or anything like that, I am pretty certain this is possible because you can do it ingame with commands
equals(). Unless you know the difference between == and equals() (which I highly advise reading about, great information on when and when not to use it), you should be using equals() because it at least defaults to ==
Can someone tell me how the Event API works under the hood? How is it possible for the event managing class to call MyListener.onPlayerDeath(PlayerDeathEvent) without having that method signature declared anywhere? It is not declared in the Listener interface nor anywhere else where I can see.
Entities (including players) are Attributable https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/Attributable.html
Is this some reflection action or how does it work?
Yes, reflection
When registered it filters through methods in the class, checks if it's annotated and gets the first argument in the method. Registers it to the appropriate HandlerList and calls them reflectively
Spigot gets all the methods annotated with @EventHandler and reflectively invokes them
Ah yes, so basically checking using reflection what the signature is and what arguments it takes and based on that call the method? Why go with that complicated route?
Or is there some benefit from that that I don't see?
i have an error in my plugin testing but do i send it here?
or i send it in #help-server
I thought so, but when I search for attribute anything nothing shows up
Alternatives are either ASM or MethodHandles, both of which are viable options but did not really exist back when Bukkit was created
There's no other good route tbh
Consumers
@worldly ingot
I just linked it to you ;p
where
I use something like that for my event manager
ik
entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier(AttributeModifier)
Or setBaseValue(), but you're best to add a modifier
public void register(Plugin plugin, EventPriority priority) {
Bukkit.getPluginManager().registerEvent(this.eventClass, this, priority, this, plugin);
}
yeah, I tried that before I asked the question. getAttribute() isn't a method for my entity.
Are Attributes persistent ?
Yes

Well if you have just an Entity, you're not going to have them. Entity itself doesn't implement Attributable
How to make .db file in plugin folder
You'll have to instanceof and cast accordingly
Hmm I see, why not just put all methods in Listener Interface and then internally check using instanceof? Or am I missing something about the simplicity of that approach?
OOOOOOOOOOHHHHHHHHHH
lol
plugin.getDataFolder()
because then it would break between versions if we ever needed to add new events (which we do all the time)
You have to implement all methods in an interface
Ah yes that makes a lot of sense
Wait yes true
An abstract class would do then, no?
I'm trying to send an offline player (I mean in another server connected in the same bungeecord) to a Bungeecord server in a Spigot plugin. I found that I can do it with online players with player.sendPluginMessage, but how do i do with an offline one?
This will just return the folder
Yes
There's also the hassle of having to determine how events are listened. How does it ignore cancelled events? How does it set its listening priority?
I need a way to make local db
SQLite
I tried mysql but didnt work
MySQL isn't local
So SQLite?
Try SQLite
Okay thanks
Yeah, it's fine imo.
is there a way to do it?
Ah yes I see, that's where the @EventHandler comes in handy
I have not worked with reflection yet so it's like a black magic box for me and hard to comprehend
You have a couple options. Handle this with a BungeeCord plugin so you can communicate with it, or use something like Redis pub/sub (imo the better option)
Something about every problem being a nail when all you have is a hammer
I'm too lazy to use Redis, so i think I'll go for the bungeecord plugin
Redis can save your ass a lot in the future. It's a nice way to mimic packets
In an attribute modifier their are 3 operations, ADD_NUMBER, ADD_SCALAR, and MULTIPLY_SCALAR. is there a way to subtract a number? I need to lower the player's max health by 1
ADD_SCALAR with a negative amount ;p
k
Actually it might be ADD_NUMBER. I don't remember. One of them adds 1 I think by default
U usually use ADD_NUMBER, idk what ADD_SCALAR does
And plugin channels aren't good enough?
Yeah, it's NUMBER
what does ADD_SCALAR do?
Plugin channels work fine and are a viable options. Though it may suffer the same issues because plugin channels are player <--> server communciation
You still need a player
Honestly, don't know the different CJ
lol
I have it
also, thanks for calling me CJ, thats my nickname IRL lol
Looks like it's misnamed. MULTIPLY_BASE is more accurate
https://minecraft.fandom.com/wiki/Attribute#Operations
Because I'm doing a plugin for a Bedwars matchmaking, so I can use the player who starts the matchmaking
Do just dont have time right now or are you not going to help because then I need to search for another way to do it or something I dont know...
What do you put in the addModifier method?
@worldly ingot
and, yes I looked at the docs
an AttributeModifier.Operation
.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("extra_damage", 10, AttributeModifier.Operation.ADD_NUMBER));```
an example
Hi, so I'm getting this warning (it doesn't affect my plugin) that says no such file or directory, when I create a file.
Error : https://pastebin.com/1ktFCNZ5
Code : https://pastebin.com/3ZuEwJWc
works but now no data is being written to the file
FileConfiguration userconfig = YamlConfiguration.loadConfiguration(userfile);
userconfig.set("path.to.key", false);
try {
userconfig.save(userfile);
} catch (IOException e) {
e.printStackTrace();
}```
code to write to file
You gotta write the content
what do you mean?
how do i check what the current weather is
like if it is storming
raining
or clear
Bukkit.getWorlds().get(0).hasStorm();
You're probably trying to remove while iterating
Can you show the full code
You can use removeIf
Otherwise you could construct a second list of items to remove and then use removeAll
Removing from within an enhanced for loop also will not work
or you can remove while using iterator
how can i stop all them numbers from appring? [ Ping me ]
@plain scroll round it when you are converting from float/double to string
im adding it like this
nvm
i think i did it
anyone know why this wont lock the item in place? It works for all my other items in the gui
^^ fixed
So is there a good way to force a block update? setType doesn't update the block itself, only the blocks around it. Block.getState.update doesn't appear to work either
Isn’t there like a tick function?
Not sure?
Don't see anything on the javadocs
I'm surprised setBlockData doesn't cause an update
use formatters
String.format is probably the easiest
Or if you want to be really fancy, just cast it to an int lol
The truncation of that value is not at all significant
But what if I want some decimals
cast to float
In effect it's a whole number. 20 half hearts
Anything in between that should be considered insignificant for front-facing strings
Minecraft renders by truncating that value anyways
why does java return .000000000000000001 sometimes
Floating point precision errors
Pretty interesting topic tbh
Best example I can give. What's 1/3 + 1/3 + 1/3. It's 3/3, right? But how do you represent an infinitely repeating number using bits? You can't represent 0.33333333 forever, it has to stop somewhere. So if you add 0.33333333 + 0.33333333 + 0.33333333, you get 0.99999999
Boom, floating point precision
I think standard precision is 23 decimal places, though I could be off by like 1 or 2
And this is why you should always round your numbers if you are showing them to the user
intellij, fix
I've noticed Eclipse doing that recently too. Usually just an F5 fixes it
thanks
Yeah mine does it randomly too
compactedWheatRecipe.addIngredient(new ItemStack(Material.WHEAT, 64));
why is that throwing error
java.lang.IllegalArgumentException: Shapeless recipes cannot have more than 9 ingredients
tells you
i want u to have to use 64 wheat to make it
use the recipe event
use the recipe event
I dunno why it's doing that. Only started a few months ago