#help-development
1 messages · Page 1987 of 1
because if i set the upward velocity of a player WHILE they hold an item and right click (flight) if there's a 4 tick delay they just hop up and down
getOfflinePlayer should work for all players, as Player is also an OfflinePlayer
and i really dont want to do more static hashmaps
but I cannot kick an offline player value
I need to kick them after adding them to the bukkit banlist
welp, time to rewrite all the code
or on newer versions of Java, you may also want to use pattern matching w/ an instanceof
e.g.
if (oplayer instanceof Player player) {
player.kick();
}
(or something like that)
so If an offlineplayer returns as null, I can be sure to say that the player does not exist at all right
alternatively i could just run a task timer 3 times but idk if i can do that with an internal value. is it possible to get how often a task has been run?
iirc Server::getOfflinePlayer yields a CraftOfflinePlayer regardless so best way to obtain the normal player would be with OfflinePlayer::getPlayer
(And null check obv)
OfflinePlayer#hasPlayerBefore
Good to know.
a simple boolean condition can check that
using the method mentioned by the peeps above
I cannot check if an offline player has a certain permission, however I would like to check if they have the ban.exempt permission
Vault API allows you to
Do they work with a database or something?
Well VaultAPI is just a bridge
It offers a set of interfaces which any plugin can implement and provide
Restart is like 2-3 seconds. I use run-paper gradle plugin to simplify debug
Damn
Not for me :p
ItemStack iron_sword = new ItemStack(Material.IRON_SWORD);
// Enchantment enchantment = new Enchantment();
// iron_sword.addEnchantment(null, 0);
does using addEnchantment really work?
You should use the ItemMeta regardless
why do they have it then?
Legacy probably
addEnchantment(null, 0) lul
Backwards compat is the cause of all evil
uh
We know right
anyone can help test smth
amogus
actually nvm
Example: Want reified generics? Too bad, backwards compatibility.
i want to help

u have to login mc tho
my laptop cant even run mc
Speaking of Java, I really fuckin' want Project Valhalla to come out >:(
Yeah, I’ll get a virtual orgasm once valhalla is out fr
By the way how was I supposed to know I need to use ItemMeta?
@ivory sleet , I'm still struggling to save all of the nether portal blocks. https://paste.md-5.net/acuwenukuh.coffeescript
Idk
I didnt even know about that class till I googled how to add enchantments
good luck waiting
uhhh actually i still need someone to test with me
Uh, can you provide some more code, or is that all?
wait no way
lol
i just realized it
that is diamond armor
he made the diamond armor become sus
i can see it now
Maybe, there you go https://paste.md-5.net/focipuvoda.java
why is it showing with the red underline and a bunch of errors
I copied it as is
hao
oh I just did that
it worked thanks
I havent actually worked with any APIs before :p
Cap
should i just launch a task three times with different delays or do a counter in it?
I’d say the former
But if you want to keep the same task object the latter would suit you better
eh I really dont need it
the most complicated part is doing it so i dont actually write the code three times
Ye
bc this far I'Ve been doing new BukkitRunnable(){@Override public void run{}}.runTaskTimer...
Looks a bit compact but nice
of course i have line breaks in there
🙏
i just dont know why to bother doing a BukkitRunnable object if i can just initialize and directly schedule it

Does restoring the nether portal inside runTaskTimer will have different result or something?
It only sets one block
With the current code that I have https://paste.md-5.net/focipuvoda.java
is .runTask(Plugin) equivalent to .runTaskLater(Plugin, 0) ?
Yeah
runTask will run 1 tick after
or if it was 1L
Wait, so If I store Block instead of BlockState, will the contents of the Block will be changed If I set the Block type to something else?
Aglerr it’s a bit hard to figure what goes wrong as of now since I can’t test it for myself
Idr the implementation so can’t answer that but I’d assume so
What
@summer scroll Probably no
What’s wrong with BukkitRunnable
I assume you're talking about changing the Material for example? @summer scroll
Yes the material
Then the Block stored in the list will change automatically
That’s false
Reference Types 🙂
BukkitRunnable allows you to derive it and still offers its instance methods imperatively
Which would be a real hassle to deal with if you simply stick with Consumer<super BukkitTask> and the BukkitScheduler
Okay thanks, just what I thought.
god fucking dammit
java.lang.IllegalStateException: Already scheduled as 173
I can't use the same instance
Unless you create an entire new Block class, the block that's stored will just change along since that's how Reference Types work 🙂
I was doing leather_helmet_meta.getItemMeta() and I was wondering why im not getting the method till I realized what variable I was using. Is this the kind of stuff that happens to you guys?
aaaaand it doesnt even have a clone() function urgh
Yeah, basically I'm modifying and storing the same object
Yep since they are both references to the same object
Moterius you’d either use a runTaskTimer or schedule a new BukkitRunnable instance inside the callback itself
Either two are fine (think we went over it alr)
well i want it to trigger exactly three times and im unsure how to count that
also i have yet to hear an answer to the question if i can see how often a task was executed already
ah
i guess doing a counter in a class implements BukkitRunnable, then setting that counter on creation, and just doing if(i++>3) cancel()
anyone knows why it doesnt show an error while i am trying to define a class inside a function?
Because its valid java
so any reason why i shouldnt? (Excluding scope?)
Because it will most definitely lead to unreadable code.
i found a completely different issue lol
it cant see that class
maybe i need to put it above?
yup
How can I get all locations of nether portal block from one location?
flood filling algorithm
This is what I tried https://paste.md-5.net/ezevopuroh.cs but can only get 3 blocks, which is self, up, and down.
repeat on all newly found portal blocks until you no longer find new blocks
Why creating class in a method lol
class only needed in method
And not just an inner class
we need a runTaskTimer(Plugin, task, delay, period, count) function
I already called the method again If the nether portal is found, but I think the problem is on the blockface.
🤷♂️
havent worked much with algorithms like that
one time i tried i gave up and did something else
so I tried getting permissions of offlineplayers using the VaultAPI but even that shows errors lmao
I have the latest version of the API i.e. 1.7.1
doesnt it need a player object?
I believe you need to pass the world as well to use an offline player
public boolean playerHas(String world, OfflinePlayer player, String permission)
Also, has is (mostly) deprecated
which one
The two that are deprecated lol
I am using the top one
You need to use playerHas
.
the world of who
(Player already extends OfflinePlayer)
Actually wait yeah why are you doing player.getUniqueId()?
You don’t need to create an offline player instead at all
I just realised how dumb my brain becomes after I have been awake for 21 hours
note the part where it says that it does not return an object for offline players
my brain is on fire
well it doesnt do it
so
yeah
I just need a way to check permissions of a player regardless of them being online or offline
oh and to check if they are isBanned()
Then get them as an OfflinePlayer
now thats where the issue comes in
its time for me to learn generics
I cannot get the permissions for offline players even when using VaultAPI for some reason
I am either very very dumb or I am very very dumb
Is there a way to let players interact e.g. hitting entities outside of the world border?
get ur perms object from the registeredServiceProvider then use perms.has(offlinePlayer, permission)
Thanks, may I ask why my current method doesn't work? https://paste.md-5.net/zupaluqaci.cs
Already am I think
also has() does not work with offline player object
yeah I because I got it straight from their github instructions thing
can i no longer do Integer.maxValue() ?
Hey can anyone help me with a plugin that I want to make for a manhunt video for my friends channel you can @ me if you want to
Integer.MAX_VALUE it's a field.
/**
* Checks if player has a permission node.
* Supports NULL value for World if the permission system registered supports global permissions.
* But May return odd values if the servers registered permission system does not have a global permission store.
*
* @param world String world name
* @param player to check
* @param permission Permission node
* @return Success or Failure
*/
public boolean playerHas(String world, OfflinePlayer player, String permission) {
nope
in caps
oh wait
yea i just realized that too
different topic, what's the event that happens when a player drinks milk and erases their effects?
can I have a link to that doc plz
PlayerItemConsumeEvent iirc
imma try thanks
its javadocs in the code 😐
just ctr click on the method
ig
whats the difference between CompletableFuture#whenComplete and CompletableFuture#thenAccept
#thenAccept returns a CF<Void> where whenComplete returns a CF<T>
whenComplete also handles exceptions
Hey, how do I convert hours to ticks?
*60 *60 *20
also
EntityPotionEffect e
(e.getAction() == EntityPotionEffectEvent.Action.ADDED) && (e.getNewEffect().getType == PotionEffectType.POISON)``` returns false - I'm not having any effects and using a poison splash potion
Duration.ofHours(hours).toMillis() / 50
💀
im making a home command and im keeping a homes cache for each user, is it bad to save a newly created home on the database immediately?
and then putting it in the cache
Hi, I'm using the events from here https://teamvk.github.io/AutoSellAPI/javadoc/me/clip/autosell/events/package-summary.html but IntelliJ keeps saying that the plugin can be a record is it bad to make a listener class a record?
a record will expose all its fields
So is it worth making it a record then?
So, I want to fix a player's camera rotation. The player can't move the camera. And no, I don't want the... what should I call it?... I don't want the jitter effect when trying to move the camera that is achieved by constantly teleporting the player. My idea is that I can switch the player to spectator mode, and make the player go into a mob. The mob has no ai or gravity, and the player can't rotate the camera. Would this work?
if you want to have a getter for all of your fields you can consider making it a record
fields are also final
pretty sure yes but use an item frame or armorstand as entity
instead of a mob
Ah okay
Oh I might do it then that seems useful
Is there a method that sets what entity the player that is in spectator mode viewing as?
alr thanks
for example if you have a field test the getter will be named test() instead of getTest()
A quick question, can multiple players view as the same entity?
alr thank you
damn i should call my fields
getTest then
/j
?
@tardy delta I've taken to saving my cache only when a player leaves or the plugin gets disabled
what if the server crashes lol?
not too big an issue
ServerCrashEvent 😄
plugin ondisable is called on crash isnti t
rejoining resets almost all variables in my plugin
no
but still
can someone explain this?
why is it the second i actually want to know somethign this server is just DEAD
what event is that?
the event when a potin effect gets added or changed (or reset via milk)
I did
i know that because if i send a log message right before that if clause up there it shows up in the logs
No, it is not bad
I do it like this
?paste
searching thro the github repos
ye
// handle milk kekw
i dunno
is this actually a comment or did you just set it as a comment for now?
// && Echo.hasTrait(player, trait_enum.PASSIVE_POISON_IMMUNE)
well then isnt that your issue?
have you tested it with only the effect type check?
I think so. i cant do it rn but i think that one also doesnt work
@tardy delta can i ping you later when i have time?
ye
THIS IS NOT FOR YOU. :(
lol
I mean
how else do i stop them from using the method
well im only doing that in the main class
but in everything else
you only use classes inside api package
System.exit() XD
"YEA system.exit would defenetly be good"
Uhm
[15:12:51 ERROR]: [SetHome] > get result error: java.sql.SQLException: [SQLITE_CONSTRAINT] Abort due to constraint violation (column player is not unique)```
wtf is that?
public ResultSet getResultSet(String query) {
ResultSet resultSet = null;
try {
Statement st = connection.createStatement();
resultSet = st.executeQuery(query);
} catch (SQLException e) {
getDatabaseConnection();
plugin.logger.log( Level.SEVERE, "[SetHome] > get result error: " + e);
}
return resultSet;
}```
here code

sorry for bad england (XD)
why are you using SQL anyways? Can't you store stuff like that in configs or PDC?

my plugin have config storage
but an dude said to use databse
Looks like you're trying to create a column that already exists
OH
uhm
someone knows about luckperms api?
Yes
Can you help me
public void setPlayerHome(String homeName, Player player) {
plugin.sqlite.getResultSet( "INSERT INTO '" + plugin.database.table +"'(player, home, x, y, z, world_name) VALUES ('" + player.getUniqueId() + "','" + homeName + "','" + getPlayerLocation( player ).getX() + "','" + getPlayerLocation( player ).getY() + "','" + getPlayerLocation( player ).getZ() + "','" + player.getWorld().getName() + "');");
}```
I just want to get user rank
so tf should i use?


Dont use databases or files like that. You should keepe everything in memory and only use SQL for data storage when a player disconnects for example.
😭 i dont understand what you mean
writing and reading files is slow
he's saying to keep it in memory until the player leaves or the server stops
yea that i know
how How HOw HOW
why do u have sqlite field there
make a class for Storage
daaaaaaaaaaam
or make an auto save
could've used a string builder there
i think the best option is 
every 10 minutes, on another thread access the database
and write
from the hashmap
however u might wanna distribute it
should be cool
not sure, ask someone else
but i have really basic knowledge LEL
who cares
me
if u just dont do anything
because im the one who cries if something is broken
Thanks olivo
use version control?
olivio oil
so if u break ur code u can restore it
lp user <user> info shows permissions and groups
..?
Use a, Use a, use a string builder!
tf is a StringBuilder?
better way of handling strings
Use a PreparedStatement
StringBuilder sb = new StringBuilder();
sb.append("a");
sb.append("b");
```Allows you to replace the +
looks cleaner
yes i got it
and then?
then sb.toString() to get result
please use prepared statements
instead of your messy "abc" + a + "dfg" etc
MessageFormat.format() tho
...
Prepared Statements is a way to go yes
Ok
sb.append( "('" ).append( player.getUniqueId() ).append( "'," );
like that is ok?
yeah ig... just, why the spaces?
Use prepared statements
Use prepared statements
Use prepared statements
Use prepared statements
wdym it works fine for me
also this
i mean its make automatically like that lol
hOw?
where
when
Read any jdbc guide

prepare a statement, clone it and set the values
then execute it
put a ? where you want to insert the values
like SELECT * FROM my_database WHERE id = ?
and then to set it do statement.set...(position, value)
some java regex expert?
i want to convert &c&lAdmin&7 :&f to Admin (Just need the string)
forgot i just will use group name
Sounds like an xy problem
forgot
Why do you want to do this?
i will use group name instead
im doing jda bot
https://github.com/2Hex/EntitySerializer pls bully me with code reviews
I wanna improve anything possible
ChatColor.stripColor(...)
o
u
k
nice
it is important to understand why you should use PS, to guard against sql injection
Hello yall! I have a problem using nms. I need it for NBT modification. now since everything got changed I have no idea how to get the nms classes into my workspace. I only added the spigot api to my project with maven since everything else did not work for me, does someone know a solution?
NBTApi
a good api
no need for nms
Sure? I need to add CanBreak and CanDestroy tags to some items. Does it provide that?
The main benefit of prepared statements is that they dont need to be recompiled
yes
i just did that in my plugin
it's just 3 lines of code
NBTItem pickaxeNBT = new NBTItem(pickaxe);
NBTList<String> tags = pickaxeNBT.getStringList("CanDestroy");
tags.add(canDestroyTag);
canDestroyTag is something like "minecraft:redstone_ore"
Oh okay, thank you! So you did not "import" nms right? I am actually wondering on how to do that... I mean, I know we should avoid NMS but I am still wondering why it isnt working... But thank you! Really appreciate that!
no nms
either put the api as a plugin on the server
either shade it
check the wiki for more info or join their discord
whats the latest spigot version?
yes
1.18.2-R0.1-20220301.213937-3
--remapped i think
thanks
I saw there's a broadcastChanges method in PlayerChunk, is there a way to get PlayerChunk from a chunk?
The heck is a PlayerChunk?
I have no idea 😅
Its def nothing api related
I just saw this class when I tried fixing something...
you sure that is not from some other api?
Oh, it's nms 😅
uh using latest as version arg compiles 1.18.1
that is because 1.18.1 is latest stable release
ah
1.18.2-R0.1-20220301.213937-3 is the latest maven release (you should really use 1.18.2-R0.1 though)
my EntitySerializer library now works, yay
What if 2 entities stand at almost the same location? So in each other?
im dumb whats wrong with this?
public class LoginListener implements Listener {
@EventHandler
public void normalLogin(PlayerLoginEvent event) {
Object player = event.getPlayer();
for (Player p : Bukkit.getOnlinePlayers()) {
p.sendMessage("Ubrandon (aka " + player + ") has joined and gets amaswidis");
}
}
@EventHandler
public void normalQuit(PlayerQuitEvent event) {
Object player = event.getPlayer();
for (Player p : Bukkit.getOnlinePlayers()) {
p.sendMessage(player + " has left the call, no amaswidis for them...");
}
}
} i have 0 idea what im doing ._.
Object player = event.getPlayer(); < - ???
._.
A var a day makes your life easier
Did you register the listener?
true
I believe he gets an output like "org.bukkit.Player@145466 has joined and gets"
@EventHandler
public void normalLogin(PlayerLoginEvent event) {
Player player = event.getPlayer();
for (Player online : Bukkit.getOnlinePlayers()) {
online.sendMessage("Ubrandon (aka " + player.getName() + ") has joined and gets amaswidis");
}
}
sorry for bad england
get the entity
o
that makes sense
but what location
oh do i spawn it
in the sky
Idk. Try something at ~ 3000 ~
So just up. This way you dont need to load any new chunks.
lol that doesnt work it doesnt do anything when they join weird
Did you register the listener?
u mean public class LoginListener implements Listener
no
._.
ok he didnt register it
yes
i did that sry im dum
?event-api
just found smh weird
other ppl can see the message
u cant
wasting my time for ~20 minutes
@lost matrix But if i spawn it at the sky
then tp to the ground
it will take damage
wont it
ill have to set it to invincible
How can i get the direction of a sign
Not really. The damage is directly proportional to ticksInAir
I think the BlockData is Rotatable
Only a wallsign
get the BlockData and cast it to Rotatable or Sign
no
what has that to do with their issue
WallSign is Directional not Rotatable
here comes the eclipse police
yes, that is what the code is doing (and from my perspective is what it should do)
I see no issue there
ye maybe but onlineplayers... shouldnt that include the one who has logged in just now?
Oh, yeah the player that joined isn't considered online at that point
damn
You'd need an extra line of code to also include the joining player
ok
Similarly dead players will not recieve the message or something like that
ooh
It is better to use Bukkit#broadcast
?jd-s
thats why i fell back to onlineplayers in the first place
... ... ... ... ...
screw this game.
player.sendMessage((newEffectType == PotionEffectType.POISON)+""+e.getNewEffect().getType()));```
You could use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerJoinEvent.html#setJoinMessage(java.lang.String)
declaration: package: org.bukkit.event.player, class: PlayerJoinEvent
PotionEffectType is not an enum
bruh docs are like chinese how do i use setjoinmessage
event.setJoinMessage("This is the join message");
googling for how to compare potion effect type bukkit results in 0 websites
how do i do it then
declaration: package: org.bukkit.potion, class: PotionEffectType
What do you use to compare objects on equality which are not a primitive or enum?
because im used to it from block#gettype
also anyone knows when 1.18.2 will be stable?
For newcomers the documentation can be complicated
?eta
There is no ETA. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
== -> equality if primitive or enum. Identity for objects.
.equals() -> equality for objects.
== is always identity
well that solved that problem
Enums just happen to be singletons
right. Just wanted to differentiate
Generally
a == b -> true then a is b
a != b -> true then a is not b
Yeah, you should use == for enums either way. Whether it is equality or identity does not make a difference there. (though using .equals() will lead to fail-fast behaviour if the left argument is null)
Probably, though I'd avoid PlayerLoginEvent because it isn't async
it should be deprecated either way
Well first we have PreLogin which is the blocking part (thus it’s invoked async), then we have Login which is post PreLogin and more data is established, for the Join, even the player entity is fully established.
You could still nitpick that phrasing because
a == b does not mean that a is b but that a and b point to the same memory address.
is there an api method to check if a entity stands in sunlight?
probably via heightmaps
heightmaps?
Because we treat, for all b and a, b and a are values
@quaint mantle
They are not the same. If they where the same then
int a = 10;
b = a;
a = 20;
Would mean that a and b would then both point at 20. But b will point at 10.
is glass a solid block?
I’m simply stating that if a is b then a == b is true and vice versa, thus if a == b then a is b
And we’re inferring that for all a and b, a and b must be values
it is
Completely forgot transparent blocks existed
Material#isTransparent might be one, but that one is deprecated
If a and b are referring to values then this is a weird example because you cant directly compare them in java.
cannot resolve method eventsetjoin message in playerjoinevent this is proboply a very dumb question but seriously whats wrong
Show your code
You forgot the dot
@EventHandler
public void normalLogin(PlayerLoginEvent event) {
event.setJoinMessage("This is the join message")
lol
god damnit
Unlikely. Paper probably has a way of resolving the transparency via Starlight however
public static HashMap<UUID, Set<BukkitRunnable>> runningTasksPerPlayer;
public static void listTask(UUID id, BukkitRunnable r){
runningTasksPerPlayer.get(id).add(r);}
would calling listTask add the task to the set inside runningTasksPerPlayer, or to a copy?
Dont make it public. And its stateful. So dont make it static either.
which answers the question not
Either it throws an exception, or add
In the map there is a Set object stored. Your method gets that Set and adds an object to it.
It will not create any copy
ok thanks
Probably not what you want
True or false 👍
Given that I'd say that it returns false for Glass for example
?stash Actually, let'S find out for sure
For determining transparency it's either nms or the material enum
That being said - there is a material enum refector in the works, so using the deprecated method is probably "good enough" for the meantime
Add what?
You could just hardcode the transparencies, but that would amount to just being Material#isTransparent
?jd-s
:ew:
What if there is no sunlight over the block?
If this issue is of no concern, yea, go ahead
transparency is a texture and clientside render ...
?paste
It is also serverside
yes that is how the transparent or see through portals work
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/RegionAccessor.html#spawn(org.bukkit.Location,java.lang.Class,org.bukkit.util.Consumer) that method already returns the entity however
declaration: package: org.bukkit, interface: RegionAccessor
Plus you can teleport it to a location outright...
o
nah
im not spawning an entity
im placing a structure
then retrieving the entity
spawned with it
Then I'd just pass a List to the spawn method were all the entities are put into
wdym
public void spawn(Location loc) {
structure.place(loc, true, StructureRotation.NONE, Mirror.NONE,
0, 0f, new Random());
}
oh yeah, that makes things difficult
I'd still not use streams, but I think that is the best you can do
.min((e1, e2) -> (int) (e2.getLocation().distanceSquared(location)
- e1.getLocation().distanceSquared(location)));
Also, this is asking for trouble. What if e1.getLocation().distanceSq is greater than e2.getLocation().distanceSquared?
dangerous
It will probably lead to artefacts if minecraft's lighting system is still as fragile as I remember it
Well it will be not equal to the upper light level if it isn't transparent
0 means no daylight
(also beware that this method breaks at night)
0 is no light at all
are you using paper
i am using paper
and item
texture pack possibly
just found out
lol iits not that hard to figure out
can i use an if statement with pname witha string to check for specific player in the event?
Player player = event.getPlayer();
var pname = player.getName();
eg. if(pname == "name"){
ty
equalsIgnoreCase
however "Diamond".equalsIgnoreCase("diamond") returns true
and dont do checks with player names for most of the time
you wanna use uuids
How do I set the result of a PrepareAnvilEvent to nothing?
event.setResult(null);
event.setResult(new ItemStack(Material.AIR));
This is what I've tried and both don't work.
Does PacketPlayOutMapChunk send the blocks of a world when a player connects?
is your event registered
ofc
setResult(Event.Result newResult) Sets the result of this event. how about a proper result: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/Event.Result.html
How about proper research?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/PrepareAnvilEvent.html#setResult(org.bukkit.inventory.ItemStack)
declaration: package: org.bukkit.event.inventory, class: PrepareAnvilEvent
sounds good, how did we jump to anvils?
Read
this
??
Ik
i am going with teh stated event.setResult()
But how can i set the result to nothing, so the rightslot will be null?
https://i.imgur.com/ZKs2Bi8.png
oops of course haha
How would I send a 5 4 3 2 1 respawn countdown on the screen?
get the inventory
and then get teh slot
a second ive made a plugin with anvils before
ill give you some basic code
PrepareAnvilEvent is not event
Run a timer, every second display the remaining countdown
how to play sound to all online players ._.
gl with that
what r u saying bro
Wdym good luck, it’s literally a documented event
Are you high?
iterate through all the players and play the sound to them
ty
?scheduling might be to your help
probably since afaik low is an expert
e.getInventory().setItem(3, null);
Like this?
well not 3
Probably 2
its 2
Counting starts at 0
Oh yes of course...
can someone give me the command to play a sound to bukkitgetonline players
That still doesn't work tho
no
Can you put a debug statement in your listener
So we can make sure it’s being called
Done, it is being called
@EventHandler
public void onPrepareAnvil(PrepareAnvilEvent e) {
final ItemStack result = e.getResult();
final ItemMeta meta = result.getItemMeta();
if(!shouldCheck(e.getInventory())) return;
if(!isMending(meta)) return;
if(!isArmor(result)) return;
e.getInventory().setItem(2, null);
log("Called");
}
ur tryna stop mending?
then u dont need that
well u kinda do but
u can do a workaround for it
Inv click event
Delay the setItem call by 1 tick?
I’m still interested in why this doesn’t work
That’s how you make exploits lol
Well but if the inventory isn't updated when the event is called then you're setting nothing to null
e.setCancelled() if the slot is 2 and the inv type is anvil @wooden fable
Because the result isn't there yet
physically why cant i do this:
Bukkit.getWorld("world").playSound(0, Sound.ENTITY_ENDER_DRAGON_GROWL, 1000000000, 1);
bruh
I'll try that later today
100000000?
Don't use Inventory#setItem() in a PrepareAnvilEvent
it needs to go far lol
I'll send an update
u wanna kill their ears??
@wooden fable give me one sec I’m gonna figure out why setResult doesn’t work for you
That doesn't work to
It didnt work
They tried, it wasn’t working
I’m checking the spigot code now
eitherway just use the workaround i talked about earlier if u cant find another solution
Yeah if it doesn't work then either the snippet is doing something wrong or there's a bug that should be reported on the JIRA
Or another plugin is overriding it
time to contribute! (jk i dont have an idea on how to do that)
public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) {
PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone());
event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
event.getInventory().setItem(2, event.getResult());
return event;
no volume makes it go further not actually makes it louder
still
if the volume is an integer
nvm
I figured you were
But it’s super weird that setResult isn’t working
am i dum or smh becuase what
Bukkit.getWorld("world").playSound(0, Sound.ENTITY_ENDER_DRAGON_GROWL, 100000000, 1);
@wooden fable do you have any other plugins on?
Let me see if it works for me
It’s cause I have to deal with morons spending all day finding exploits
So I have to think about it
LOL fair enough
There’s one they found once where if they spam the keyboard and spin around and open the inventory it lets them dupe
All kinds of nonsense
well duh
Sounds like some sort of cult at this point lol
ur location arg is "0"
ye but what should it be like what
So you have another plugin overriding it
0 0 0?
wtf 
How do I display?
Make your event priority MONITOR just for a minute, let’s see if it works for you
You can’t leave it as MONITOR but it’ll be good to check
As a title presumably
what should i put in coords?
Bukkit.getWorld("world").playSound(????, Sound.ENTITY_ENDER_DRAGON_GROWL, 100000000, 1);
Where you want the sound to play
0 70 0
I basically want it to show in the middle of the screen, what function should I use
(middle of map sorta)
I'm not working on it right now so I'll do that later today
?jd
Whichever function in Player shows a Title
new Location(Bukkit.getWorld("world"), 0, 70, 0) then. Although your world should probably be obtained some other way than using getWorld since that can return null.
ty
That’s only going to play it to the players in that world though
Not every player online
Idk what they're trying to do so
Right
That might be fine, I’m just pointing it out in case it’s not
Ah ok
Player.sendTitle(String, String)
Player.sendTitle(String, String, int, int, int)
I also want to achieve better abstraction and design, anyone has ideas?
im not quite getting with the namespacedkey is about, and how i can set them?
from my library?
ayy yo wtf, didnt even see there was anything about that lol
wdym
it was more a general question, i did not see you were talking about that
Oh
lol
basically
a namespace and a key (a string)
a namespace being ur plugin in most cases
What are the Strings gonna be
ahhhhhh
Top and bottom text
We do have docs on these things explaining exactly what each method and its parameters do
^
?jd is relevant here. There's a search bar in the top right
I'm like 95% out of this convo atm lmao. Thanks o/
No worries
so it would be enught to just put "this" in refering to your main class, if the code was in the main class
if they are using event, they can simply deny the result, there is no need for teh itemstack
i did not say to cancel it
item result has usable enums of which DENY is one
@viral crag
Spigot does not check that for this event, it sets the slot in the inventory
hi, I tried to use this,
getConfig().getConfigurationSection("items").getKeys(false).forEach(key -> {
String s = getConfig().getString("items." + key + ".dropped-from").replace("[", "").replace("]", "");
System.out.println(s);
itemStackHashMap.put(Material.matchMaterial(s), new ItemBuilder(
new ItemStack(getConfig().getInt("items." + key + ".id")))
.setAmount(getConfig().getInt("items." + key + ".amount"))
.setName(getConfig().getString("items." + key + ".title"))
.setLore(getConfig().getStringList("items." + key + ".lore"))
.setData(getConfig().getInt("items." + key + ".data"))
.toItemStack());
chances.put(Material.valueOf(getConfig().getString("items." + key + ".dropped-from")), getConfig().getInt("items." + key + "chance"));
});```
And that is giving this error:
```[15:00:53 INFO]: WHEAT
[15:00:53 ERROR]: Error occurred while enabling MineCentralFarming v1.0.0 (Is it up to date?)
java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.[WHEAT]
at java.lang.Enum.valueOf(Enum.java:238) ~[?:1.8.0_312]
at org.bukkit.Material.valueOf(Material.java:1) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at me.waterbroodje.minecentralfarming.Main.lambda$loadVariables$1(Main.java:57) ~[?:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:1.8.0_312]
at me.waterbroodje.minecentralfarming.Main.loadVariables(Main.java:47) ~[?:?]
at me.waterbroodje.minecentralfarming.Main.onEnable(Main.java:26) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:407) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:359) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:318) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:408) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:372) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:327) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:267) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:563) [patched.jar:git-PaperSpigot-"4c7641d"]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312``` I just don't know how to fix
Seems like there’s no material WHEAT
You can see that where it says “No enum constant WHEAT”
[WHEAT]
Not WHEAT
When I try to replace it with " " instead of "" it says "No enum constant org.bukkit.Material. WHEAT "
And Material.WHEAT is a thing
Your issue might be regex, but idk
Replace doesn’t use regex
It doesn’t
replaceAll uwu
replace all uses regex heh
chances.put(Material.valueOf(getConfig().getString("items." + key + ".dropped-from")), getConfig().getInt("items." + key + "chance"));
Should be chances.put(Material.valueOf(s), getConfig().getInt("items." + key + "chance"));
You're only replacing the brackets when you're printing and not when you're using it.
Yeah it’s that valueof
hmm im trying to load a string from a presistentdatacontainer, but im getting this
You need to also pass the type
So something like .get(key, PersistentDataType.STRING), idk - all pseudocode
That worked, thanks
How do I get the NMS Level object from a bukkit world? I try the whole getHandle() thing but that returns WorldServer
That is the NMS object
^
?paste
https://paste.md-5.net/jedagojuto.java Not really sure why none of the skulls will spawn, even when i do the command.
This is some gourmet formatting right there.
Lol
What this want
[20:13:49 ERROR]: Parameters: net.minecraft.server.v1_16_R3.PacketPlayInUpdateSign@10131704[ a=BlockPosition{x=181, y=0, z=113} b={,,,}
full stack trace pls
20:13:49 ERROR]: [Auktionshaus] Unhandled exception occured in onPacketReceiving(PacketEvent) for Auktionshaus java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?] at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?] at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?] at java.util.Objects.checkIndex(Objects.java:359) ~[?:?] at java.util.ArrayList.get(ArrayList.java:427) ~[?:?] at gn.auktion.utils.SignGUI$1.onPacketReceiving(SignGUI.java:40) ~[?:?] at com.comphenix.protocol.injector.SortedPacketListenerList.invokeReceivingListener(SortedPacketListenerList.java:114) ~[?:?] at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketRecieving(SortedPacketListenerList.java:67) ~[?:?] at
Im guessing this is not from your plugin?
This is a SignGUI
eH
I tried that
But it still doesn't work
You miss your config.yml in the compiled jar
@EventHandler(priority = EventPriority.MONITOR)
public void onPrepareAnvil(PrepareAnvilEvent e) {
final ItemStack result = e.getResult();
final ItemMeta meta = result.getItemMeta();
if(!shouldCheck(e.getInventory())) return;
if(!isMending(meta)) return;
if(!isArmor(result)) return;
e.getInventory().setItem(2, null);
log("Called");
}
Event registered?
This is a older Version I want to do it in 1.16.5
debug every boolean statement
ofc
Or do u know a way how to get sign input from a not existing sign
How is that going to help? We already know it gets called by the debug at the bottom
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
this is from 2013... You should take a look at the protocol if you want to port this to newer verions
No errors, I don't know what else to say, the code is running and I've already tried PrepareAnvilEvent#setResult but that doesn't work either.
What version?
1.12.2
Why not use PrepareAnvilEvent#setResult(ItemStack) ?
Tried already, doesn't work.
e.setResult(new ItemStack(Material.AIR));
e.setResult(null);
e.getInventory().setItem(2, null);
e.getInventory().setItem(2, new ItemStack(Material.AIR));
I've tried all these but nothing works
Just tried it out. PrepareAnvilEvent#setResult(ItemStack) works fine on the latest version
He’s trying to figure out why it’s not working for him
@wooden fable try removing every other plugin and just test with yours
You do need to make it setResult though @wooden fable
So do that first
setting the inventory slot wont work at all
Would anyone want to help with a twist I am going to make for a Minecraft manhunt dm me if you would like to help. I’m new to making plugins
I tested it with:
e.setResult(new ItemStack(Material.AIR));
``` and ```java
e.setResult(null);
but it still doesn't work.
Event.Result.DENY instead of null
Right but now we need to figure out why those two don’t work
it says that it wants the type Level and not WorldServer
Whereas setItem will never work
For the last time, that does not work for this event
null is not valid for InventoryEvent
for the return yes
Dude
I looked at the code
It’s valid as null
Just accept that you’re wrong about this
okay I am wrong - somewhere null must be mapped to default
I have now disabled all plugins and it still doesn't work for me.
Pom: https://pastebin.com/MGSvNTfS
The plugin has only one class: https://pastebin.com/ANXewhLP
Some logs: https://pastebin.com/Xwrh2ajM
This may be a bug on the version of spigot you’re using then
I’ll take a deeper look later
One last thing, try setting null again as opposed to air @wooden fable
try to delay set the item
Yes, I've tried that many times
Thank you very much for still helping.
That will cause an exploit
you were not responding to me, everything i read says Itemstack is NotNull so i am looking for alex's version
Maybe I have an idea, what if I use InventoryClickEvent and check if the item is armor with mending and if it is, I cancel the event.
You still see the result item but you can't pick it up anymore and then it's fine.
ur still on tht
Thats what I suggested earlier
yeah looking for the alternate version to this: IMPORTANT: An ItemStack is only designed to contain items. Do not use this class to encapsulate Materials for which Material.isItem() returns false.
Yes, thanks again for the help
Anyone
has a code review
I wanna achieve more abstraction and a better design, any ideas
Cannot inherit from final 'net.md_5.bungee.api.chat.ComponentBuilder'
why does that not work
Right now you’re just throwing concrete implementations at the consumer
Because that class is final. Why do you want to extend it anyways?
because the class said it
?jd
da hell this suppose to mean?
Never call the constructor of your JavaPlugin class
what
ahh so it is plugin side, now i just need to remember what the constructor is lol
Im just looking at the javadocs. Where does it say that you should extend ComponentBuilder?
new YourPlugin() <- illegal
7smile can you took a look on this code? maybe tips of better design https://github.com/2Hex/EntitySerializer
if u dont have time its fine
AHH FFS I THOUGHT I HAD REMOVED THAT
how can i make it work then
How to fix this?
java.util.ConcurrentModificationException
at java.util.ArrayList.forEach(ArrayList.java:1262) ~[?:1.8.0_312]
at me.waterbroodje.minecentralfarming.tasks.ReplaceTask$1.run(ReplaceTask.java:25) ~[?:?]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:352) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:783) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [patched.jar:git-PaperSpigot-"4c7641d"]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]```
```java
public void run() {
new BukkitRunnable() {
@Override
public void run() {
blockReplaceDataList.forEach(blockReplaceData -> {
if (blockReplaceData.isCooldownOver()) {
if (blockReplaceData.getMaterial() == blockReplaceData.getLocation().getBlock().getType()) return;
blockReplaceData.getLocation().getBlock().setType(blockReplaceData.getMaterial());
blockReplaceDataList.remove(blockReplaceData);
}
});
}
}.runTaskTimer(mainClass, 20L, 20L);
}```
you can't modify while iterating
What do you mean?
Help-me here pls, what is the other agument of this method?
new PacketPlayOutSpawnEntity(entity,another argument);```
You can take that quite literally. You can not modify an ArrayList while iterating over it.


