#help-development
1 messages · Page 1440 of 1
also what's this
an enchant plugin
is it shit?
i need a not shit enchant plugin
you should make it not shit so I can use it
RedLib makes enchantments easy to make
i'm sure it does
I think gecko's plugin uses it
I can't even copy the text on github mobile
lol
by checking every item in every slot 20 times a tick
and cloning them 5 times for each check
and then comparing them to a string in a .txt file
I actually focus pretty heavily on performance
lmao
r/onejoke but for redlib

suslib
guys
Cinnamon roll time
anyway, i find just listening to the relevant events to be sufficient for maintaining which enchants are active on a player
Goodbye
like yeah, I do check each slot every few seconds
how can i take it out the <> when i chat on my server
And that's fine
it doesn't really matter that much if a player has some enchant active for 2 seconds after somehow being stripped of items by a third party plugin
Checking it every tick is really not that heavy though
it's still 20 times heavier than checking it every second
Much more expensive things than that happen every tick
depends on what you're comparing it to
chunk loading B)
for example... are you comparing it to a craftitemstack or a bukkit itemstack
ItemStack is the superclass that Craftstack extends
Craftstack is a wrapper of the nms stack
the implementation of each differs
comparing a bukkitstack with a craftstack causes 4 itemmeta clones
whilst comparing a craftstack with another craftstack causes none
yeah what if one is a 1.15 item and the other is a 1.16 item
Lol
item stack extends nothing, i think you mean the itemmeta?
itemstack is a concrete class
craftitemstack extends itemstack
bukkit itemstack is the superclass that craftstack extends
CraftItemStack wraps NMSStack and extends ItemStack
it's a strange design choice that is in place to let you instantiate new ItemStack even though it is an API class and should contain no implementation
GUYS, Lets calm it down
can i get some help tho
i have no clue how to send a packet with this:
PacketContainer sandPacket = this.protocolManager.createPacket(SPAWN_ENTITY);
sandPacket.getIntegers().
write(0, 500).
write(1, (int) EntityType.FALLING_BLOCK.getTypeId()).
write(2, (event.getLocation().getBlockX())).
write(3, (event.getLocation().getBlockY())).
write(4, (event.getLocation().getBlockZ()));
sandPacket.getDataWatcherModifier().write(0,sandWatcher)
``` but it doesn't work, i dont know how to spawn a falling block entity
I tried looking at this as well but it didn't help:
https://minidigger.github.io/MiniMappingViewer/#/spigot/server/1.16.4/PacketPlayOutSpawnEntity
MiniMappingViewer
lmao
my point is that a seemingly trivial check operation can become very expensive if the itemmeta is very large and you have to clone it 2 times just so that you can compare it to another item
wait you're right
I had to hunt down a ton of superfluous itemmeta cloning when I unfucked slimefun cargo networks
shit was cloning like 3 gigabytes of itemmeta clones onto the heap every time it ran
jeez
call me traumatized but I know that comparing itemstacks can be explosively expensive in the worst case scenario
Oh yeah doesn't getItemMeta internally create a clone of the item tag every time it's called rather than caching
myes
🙃
it can get pretty bad but i think there's a bit of optimization going in i bet
Love that
and isSimilar calls it twice
once for getDurability and a second time for comparing the meta
Wow
why is this a thing?
because bukkit is shit
Hmm
it's literally a 1 line fix but nobody does it
I have my own method for comparing items
I can make it cache the ItemMeta for different trait comparisons
sure you want to prevent wrong user input but the item meta is safe from altering or is it not?
unless it uses the underlying nms stack and you are not involving bukkit stacks in the operation, you will still be cloning itemmeta for each check
It lets you choose which traits to compare, i.e. name, lore, amount
the issue is that just looking at those is going to have that shulker box full of max size books cloned for every check
even if you cache it, you have to clone it again the next tick when you look at the slot again
Yeah I get that much
which can still be relatively expensive
which is why i'd rather have it 20 times less expensive
at the cost of some enchants very rarely lingering for an extra second
you don't know that
Hello !
I will have a few questions for static methods ...
Why are they bad?
In which case can I use them? In which case not?
thank you for your time
I do know that
what if I want to enchant my shulker box
??
Oh that
not the armor
I mean, I've used it on a server with 100+ concurrent players and it never caused issues
There were other things that caused issues which I then optimized
i'm sure those 100+ concurrent players weren't concurrently holding shulker boxes with max size books in them
Unless it starts even showing up in timings I think it's fine
Hm
I'm pretty sure it won't compare that directly through bukkit
Can't say for sure
But I'm pretty sure BlockStateMeta is similar to ItemMeta in that it creates the BlockState when you request it rather than storing it internally
thing is that the entire meta gets cloned when you access any part of it
checking the name of a shulker box will convert all of those books from nms NBTTagCompound to bukkit itemmeta
that's on immutability programing
it's either all or nothing
is there a
i'm working on a live-view itemmeta impl for myself but working with nms is cancer so it's on hold
ItemStack#isSimilar(ItemMeta)?
there isn't, and even if there was, it'd still clone the meta of the other itemstack
no
twice
yes, it'd still clone the itemmeta of the itemstack you're calling it on
that'd clone the itemmeta twice for both of them
the isSimilar impl of ItemStack calls getItemMeta twice
it is however overridden by CraftItemStack which compares the underlying NMS ItemStack if the other itemstack is a CraftItemStack too
you should push a fix on git for md5 to notice
so comparing two craftstacks is significantly cheaper than comparing a craftstack and a bukkitstack
or a bukkitstack and another bukkitstack
still even if it's fixed, the old versions will still have the problem
old versions can suck my dick
words to live by
I have always fought the bukkit api's myself whenever I coded my plugins
bukkit is pretty good in comparison to quite a few things but it does have its own share of problems
there are some areas where it's next to unusable
like world generation and the new data-driven stuff like loottables from datapacks
there would be an easy fix to this problem
biggest issue with bukkit is that it refuses to go forward and refuses to drop backwards compat
a private, read only way of checking the meta data
yeah, it would be super easy to fix this one
where there is no immutability involved
i have no clue why it is the way it is still
nobody seems to care about it
but like redempt said it really isn't a big issue for most servers with most plugins
so i guess nobody cares
it might have been skipped due to the excesive comments
for my slimefun fork i wrote a new itemstack implementation that's expressly designed to be used for repeated issimilar comparisons
it caches equals relations and shit
and caches both bukkit meta and nms meta and compares whatever is present to avoid cloning shit whenever possible
i'll eventually hook the live-view itemmeta impl to it and it'll be pretty nice
i'll call it HitlerItemStack
and release it as a lib on splögget
and watch it get taken down in .4 microseconds
what's your fascination with hitler? 🥶
hinlor
i am annoyed, i don't think we should promote such a guy's action
amuse me
who is hunker
PacketContainer fallingBlock = protocolManager.createPacket(SPAWN_ENTITY);
fallingBlock.getIntegers().
write(0, 26);
fallingBlock.getDoubles().
write(0, player.getLocation().getX()).
write(1, player.getLocation().getY() + 5).
write(2, player.getLocation().getZ());
WrappedBlockData data = WrappedBlockData.createData(Material.STONE);
fallingBlock.getBlockData().write(0, data);
try {
this.protocolManager.sendServerPacket(player, fallingBlock);
} catch (final InvocationTargetException e) {
e.printStackTrace();
}
Anyone know why i get this error?
if i ever release the source code for anything i'll insert holocaust jokes into all of the comments
i've even bought a 200 page book just for holocaust jokes
it set me back 20 bucks
FieldAccessException: No field with type net.minecraft.server.v1_16_R3.IBlockData exists in class PacketPlayOutSpawnEntity
but set you forward time in prison 😎
muh free speech
but according to https://wiki.vg/Protocol#Spawn_Entity
it does exist? maybe?
wait no
i'm not seeing it
i think you need to like send an entity metadata packet or something after creating the entity
Cringe
like i said just using serverside fallingsand would have been a ton simpler
well, if it fucking worked, anyway
exactamundo
can i ask a question about the indexing of these,
do i literally just count down the integers
there is no such lib at runtime @lyric grove
for the index to write to
at runtime
The server doesn't have that lib
there is no such lib at runtime @lyric grove
should i shade it into my plugin not using maven?
i'll not suggest doing that
Hello. Can someone show me how to make a scoreboard, which updates without flicker in 1.8? I've tried multiple ways, which aren't working 😦
instead look on what spigot has
use 1.16.5
1.8 not supported here
Nope I cannot
then seek help in a 1.8 discord
ok
3ZNuncGJ
looks like its getting it from my jar
can't you just use the data format bundled in the standard library
How do i get the EID of a new entity
What, that it isn't in use
i don't suggest looking at the protocol wiki
instead look in the nms
I dont want to use nms tho
Hi I need help the server is saying it won't pass the event anybody know what the error is with this code:
im trying to stay away from it
code block
?paste or this
oh sry
lol
omg
well the simplest way would be to spawn an actual fallingsand entity and then destroy it and cancel the destroy packet and pray it works this time
What?
Try 3... Hi I need help the server is saying it won't pass the event anybody know what the error is with this code: https://paste.md-5.net/zovupetocu.java
what is the error
Can't pass event blah blah blah
yeah that blah blah blah bit is important
It literally just says cannot pass event no more no less
Entity class has a private static final AtomicInteger that represents the next eid
you'll need to reflect into it unless there is an api way of getting its value
there is also a nms way of creating an entity without spawning it in a world physically, which would probably be the simplest way
there is no more
bitch
Ahahahaha
it uses reflection as well, very nice
apparently choco has commented on it saying that there'a a PR open for it
might want to check whether that pr ever got merged
Anybody?
no stack trace no help
no exception message no help
ah well I guess I will have to find one, hidden in the depths of some files I can't access
try restarting the server
If I wanted something that'd allow zombies to spawn with red leather gear for 8 minutes and then after 8 minutes it were to stop after 8 minutes, what code would I need for that?
I still dk if i have managed to spawn a block
@quaint mantle what kind of an answer are you expecting
there are two ways
either you have a start timestamp
and then in your listener or whatever you compare the current time to that timestamp
and if it's over 8 minutes, abort
the other way is to use the bukkit scheduler to run a task that aborts your thing after 8 minutes
how would i do the second option
Bukkit.getScheduler().runTaskLater(plugin, () -> {
//code to make your thing stop
}, delay);
plugin is an instance of your main class
Why does e.getPlayer().getInventory().getItemInMainHand().getType() return AIR on PlayerDropItem :bruh:
delay is the number of ticks to delay the execution by
get the dropped item from the event
so "delay" is in ticks?
I want to check if the dropped item was from their main hand though
delay is in ticks yes
ty
i have no clue which one of those it is
probably the one from protocollib
the one in WrappedDataWatcher
so would i make the red armour chance outside of it and then after that many ticks i put the code inside saying to not make a red armour chance and it stops it?
uh i guess
ah okay thank you
you make the code in that block stop the code that's spawning them
as for how you do that depends on how you're spawning them
flip a boolean or something
this is what i have, does shit all tho
@EventHandler
public void oncrouch(PlayerToggleSneakEvent event){
Player player = event.getPlayer();
EntityCreator entityCreator = new EntityCreator();
Entity fb = entityCreator.create(EntityType.FALLING_BLOCK,new Location(player.getWorld(),player.getLocation().getX(),player.getLocation().getY() + 5,player.getLocation().getZ()));
PacketContainer fallingBlock = protocolManager.createPacket(SPAWN_ENTITY);
fallingBlock.getIntegers().
write(0,fb.getEntityId()).
write(1, 26).
write(2, 70);
fallingBlock.getDoubles().
write(0, player.getLocation().getX()).
write(1, player.getLocation().getY() + 5).
write(2, player.getLocation().getZ());
PacketContainer meta = this.protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
meta.getIntegers().write(0, fb.getEntityId());
WrappedDataWatcher watcher = new WrappedDataWatcher();
WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class);
watcher.setEntity(player);
watcher.setObject(0, serializer, (byte) (0x40));
meta.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
try {
this.protocolManager.sendServerPacket(player, fallingBlock);
this.protocolManager.sendServerPacket(player, meta);
} catch (final InvocationTargetException e) {
e.printStackTrace();
}
}
ik that i haven't set the correct meta objects
im just gonna use some nms shite for meta for now:
net.minecraft.server.v1_16_R3.Entity nmsEntity = (net.minecraft.server.v1_16_R3.Entity) fb;
final PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata(nmsEntity.getId(), nmsEntity.getDataWatcher(), true);
could do that reflectively ig
please camelCase method names
generally the . on newlines is also on the new line rather than at the end of the old line
thing
.thing2()
.thing3()
you don't always need the parenthesis
not my code
ah
rather than
thing.
thing2().
thing3()
yeah sure
so we're c/p'ing
yeah
i'll leave
i have spent all day trying to get this to work
your previous avatar was more handsome
yeah
I apologise
Can i make this entity from the EntityCreator you sent me
@wraith rapids
with nms
yeah probably
no need to ping him he's right here
sorry
shiiiiit what is this
oh oh oh
this is just this shit
now, how the fuck do i get the UUID and what is it anyways
yeah
how do i get it
entity.getuuid or something
rip
what is the float?
i'm not seeing a float
should use mini's mappings tool
there's 2 floats
where
right next to each other
oh, yeah
thats the problem
i don't know what they mean
/ where they come from
it isn't in the constructor?
how does one set the join message again? i forgot lol
PlayerJoinEvent -> setJoinMessage
I believe it would be
event.setJoinMessage()
Yes on the PlayerJoinEvent
Well I thought that, but: Cannot resolve method 'setJoinMessage' in 'PlayerLoginEvent'
Okay: So it turns out error is null on line 3, 9, 18, 25 Pastebin: https://paste.md-5.net/kivovebuye.cs
I have absolutely no clue please help
give a stack trace
What is that
NullPointerException
at line 3
then something on line 3 is null and you're calling a method on it
I know I assume its e.getItem().getType(), but I have no idea on how to not make it null
you can't make it not null
anyone know why im getting a null pointer?
null means there is nothing
the only way to make nothing not nothing is put something in it
but since you have nothing you can't put anything in it
the only thing you can do is abort
the player is not holding an item
the held item is null
absent
empty
devoid of value
check whether e.getItem() is null and if it is, return before calling any methods on it
so i want to send operator commands when a certain command is sent
how would i do that?
like i want console to send a command
that hurt my head
LMAO
guys I tried to make a shulker backpack but it didnt work why
this is the code https://paste.md-5.net/ocimupelas.java
Isnt a shulker a backpack by itself?
its an Inventory, yes
I mean players will open the shulker in their inventory
I tried to create the config in another class. But I don't understand how I can get this from here, can anybody help?^^
I know it looks very confusing but ignore the system.out.println's, they are just debug code
you create a public getter that returns the yamlConfiguration and then you call it
in main class right?
in this class
otherwise there is no way for you to get the YamlConfiguration out of this object
the field is private and there is no getter
you need to expose it somehow, f.e with a public getter
What's the best way to store a list of entities to kill them when i want? (all of them)
and do other things with them
new List<Entity>
more specifically armor stands
It took me a little longer to understand the language difference sorry xD
You were talking about that right?
public YamlConfiguration getYamlConfiguration() {
return yamlConfiguration;
}
yeah
and now I need to call it on the main
I remembered this but I forgot. Shit. Can you tell me how to call xD?
assign the ConfigManager you are constructing here into a field/variable
ConfigManager manager = new ConfigManager(this);
then call the method
manager.getYamlConfiguration()
thanks ^^ le me check
ups, JAVA java.io.IOException: The system cannot find the path specified
https://paste.turingarch.com/paste.php?id=98
Paste can store text, source code or sensitive data for a set period of time.
i already have code to create the file
🤔
I guess not, it's just ignored -_-
what line threw the exception
file.createNewFile requires the directory to exist
to create plugins/yourplugin/config.yml
you need plugins/yourplugin/ to exist
create the directory if it doesn't exist
File::mkdirs
oh i thought the folder would be created automatically
I created plugins/<name> and it's fixed
So do you have any idea why the file doesn't occur automatically?
if your original yml file is in your jar you can simply use saveResource to get it out
if its the default config use saveDefaultConfig(). It will create the folder and save the config.yml from the jar into the folder
createFile doesn't create the directory, that's just how it works
you'll need to use mkdir or mkdirs to create the directory first, if it doesn't exist
but yeah saveresource is your friend
so i want to make it when a player sends a specific command it makes the player execute //replacenear 50 blue_stained_glass,red_stained_glass air
how would i do that
can some tell me agein why arraylist can be bad in some case?
i believe 7smile7 told me about it but i can't find message
appending on the list at the end may be O(n) complexity and contains is also O(n)
get and set by index is O(1) for ArrayList
LinkedList has O(1) for appending elements to it iirc
But ArrayList is arguably the best list data structure for arbitrary stuff
It generally has faster iteration time than both LinkedList and CopyOnWriteArrayList
But also should be worth mentioning ArrayList uses System::arraycopy for resizing its array making the add operation quite fast
Edit time complexity is generally something we consider when our data structures become bigger
Thanks alot! i were looking for that infomation!
did you look on wiki?
pls send me source link
what about hashmap?
if you need a list to load and have fast shearchs you usar one tipe
if you need a list too keep changing it all the time, other times are better
just looking at time complexity
yep, but doing what?
contains O(1) put O(1) remove O(1), iterate O(n)
just trying to learn more
k k
still feel noobish
But remember time complexity just tells u the worst amount of operations sort of
that is it
For instance IdentityHashMap is better (faster) than HashMap although they have the exact same time complexity
uh
sometimes it is better if we doo some testing with several strutures, to find out what is more suitable
Yeah

IdentityHashMap is just a normal HashMap that uses Object.equals/hashcode rather than the subclass ones
i still use hashtables
No it uses System::identityHashCode
but now days there are improved strutures over that
efficient holograms with armorstands guide? 😀
go on
just looking for exemple
to take note
or what you can tell me about it
i really should learn more about data and data structure
to make better code
it works but it is right not sure?
Well unless you have an example it’s hard to just pull out all the concrete information you want to know
ok can i find some exemple somewhere or some infomation?
sorry if i'm asking alot i'm very curious
about 20 years ago, ye that long, I made a sort of winzip, using wolfmans algorithm
Is there like any projects you’re working on right now?
so with that project I played with vectors, linkedlists, hashtables, binary trees
lots of stuff
Vector Hashtable lol
and learned quite a lot from it
nothing propper well written
but i had a item sort plugin
there sort to another inventory instance
cool
note: i had no real experice making that
it like i can visualize things in my head
Note: i have Autism
so true
I am making and improving some existing pluggins
learned quite a lot from it too
just for fun, actualy
anyway, we should be always learning, so our brain doesnt get lasy 🙂
i felt like spigot course scam me for a chance to learn
i could have used those 100$ on something else
or better
it is not even service for it
you spent money on it?
i didn't know back then
i'm dying
That’s like rip
he was so promising
lets make it worth it 🙂
well, as they say
now it just feels like a schem
it depends
i should have bought java books for it
anyways i'm off for realises now before i get anal cancer
or paid someone to teach me
jike best of luck
You learn most stuff for free nowadays
sus
forget about it, just look at the future
yeah you learn from the past
if that is your greatest mistake, then you are ok
probably doe
I have made greater ones along my life
always learning
i spend 800$ on super learn course
Bruh
more oof
Stop it
hhhhhhhhhhhhhh
🙂
but that was the past
it same time i bought spigot course
so i were dumb back then
ok i'm actually terminating ripcord this time so I don't accidentally look
Lmao
how do i set the time to the very start of night in a world called "10"
0_o
hope this can help you
guys I want to seperate something from my main and I created a new class for register the events to main but I cant use public void shulker(InventoryClickEvent e)
this is the code https://paste.md-5.net/iwitozasig.java
did you register that class for the events on your main?
yes
implements Listener missing
getWorld("10").setTime(Number Long)
declaration: package: org.bukkit, interface: World
I am new at java
World world10 = Bukkit.getWorld("10");
can you give an example how can I fix it?
ty
World10.setTime( );
@winged mica thanks thats worked
if you wanna use that
but now how can I Fix this
public class ShulkerCanta { should be public class ShulkerCanta implements Listener {
first start
yes I did it that way
wait is Class Mob constructor use for Custom mobs?
maybe.. oh
not having this, i think you event register shouldn't be working
k
PluginManager.registerEvents(new ShulkerCanta(), this);
on your main?
show us
just put it outside
But if I put it outside how can I register the event
Is there a packet for the item held aniamtion?
its still registered then
as long as you keep it marked with @EventHandler
and let your class implement Listener
and register the class in your onEnable
getServer().getPluginManager().registerEvents(new ShulkerCanta(), this);
like this?
my other class name is ShulkerCanta
okey I got it
and on https://paste.md-5.net/iwitozasig.java take out the constructer
you puted the event inside of the construcor
try this
public class ShulkerCanta {
@EventHandler
public void shulker(InventoryClickEvent e) {
if(e.getClick().equals(ClickType.LEFT)) {
if(e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta()) {
ItemStack box = e.getCurrentItem();
if(box.getItemMeta() instanceof BlockStateMeta) {
BlockStateMeta blockmeta = (BlockStateMeta) box;
if(blockmeta.getBlockState() instanceof ShulkerBox) {
ShulkerBox shulker = (ShulkerBox) blockmeta.getBlockState();
Inventory inv = Bukkit.createInventory(null, 27);
inv.setContents(shulker.getInventory().getContents());
e.getWhoClicked().openInventory(inv);
}
}
}
}
}
}
?paste
how do i make ward play at 0, 0, 0 in a world called "10" with a radius of 1000 blocks
while(chestsi.hasNext()) {
Map.Entry e = (Map.Entry) chestsi.next();
Hologram hologram = HologramsAPI.createHologram(SWXChestHolo.getInstance(), (Location) e.getKey());
hologram.appendTextLine("This is a test.");
SWXChestHolo.holograms.add(hologram); //line 46 SWXArenaStart
}
public static List<Hologram> holograms; (in main class)
what did i do wrong?
wut you mean by ward?
ward the disc
Oh.. like how to play The music ward at 0 0 0
how do you force a player to execute a command in java?
i tried doing this but something tells me its wrong
declaration: package: org.bukkit, interface: World
make sure Elim is null
@maiden thicket like this?
i meant isnt null haha but yeah
and uh
add a logger in there like
Bukkit.getLogger().info("dispatched cmd");
aaaaaa why is your variable capitalized
🥲
tbh idk
when u use command.getName() to check the command being called and not separate classes
🥲🥲🥲🤚🏽
also pretty sure there is player.dispatchCommand or whatever
just search command in the methods
AsyncPlayerChatEvent::setFormat
I have a custom event thats being called asynchronously but I cant cancel it, all the other code in the event works fine
@EventHandler
public void flagEvent(FlagEvent event){
event.getPlayer().sendMessage("e"); // works
event.setCancelled(true); //doesnt work
}
and this is it being called, its called from an async thing
FlagEvent flagEvent = new FlagEvent(player);
Bukkit.getPluginManager().callEvent(flagEvent);
if(flagEvent.isCancelled()) {
return;
}
thats calling it sync?
well it doesnt cacel then still
send the method maybe?
i guess here
public void fail(Player player) {
FlagEvent flagEvent = new FlagEvent(player);
Bukkit.getScheduler().runTask(FlappyAnticheat.getInstance(), () -> Bukkit.getPluginManager().callEvent(flagEvent));
if(flagEvent.isCancelled()) {
return;
}
and its called here
@Override
public void onPacketPlayReceive(PacketPlayReceiveEvent e) {
//bunch of code here
fail(player);
}
public void fail(Player player) {
FlagEvent flagEvent = new FlagEvent(player);
Bukkit.getScheduler().runTask(FlappyAnticheat.getInstance(), () -> Bukkit.getPluginManager().callEvent(flagEvent));
if(flagEvent.isCancelled()) {
return;
}
still not entire method
the only code after that is sending messages
so cancelling ur event will just avoid sending messages?
basically
ok, how would I get it be canceled?
implements cancellable
if event not cancelled then call event
send FlagEvent class
public class FlagEvent extends Event implements Cancellable {
private final Player player;
private boolean isCancelled;
public FlagEvent(Player player) {
this.player = player;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return this.isCancelled;
}
@Override
public void setCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
}
private static final HandlerList HANDLERS = new HandlerList();
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
public Player getPlayer() {
return this.player;
}
}
youre returning the task lol
i didnt change anything for this calss
thats not going to cancel sending the messages
you need to send the messages within the task in order for the return to do anything
TheDoominator that packet receiving is async right
additionally async events should have super(true)
so i should do
if(!flagEvent.isCancelled()) {
//code
}
otherwise you'll get error
yes
also do super(true) in the event constructor or you cant call it async
doesnt work
ill add the super thing now
Yeah the super isnt really relevant rn since you're calling the even sync atm
have smtng like this then:
public void fail(Player player) {
FlagEvent flagEvent = new FlagEvent(player);
Bukkit.getScheduler().runTask(FlappyAnticheat.getInstance(), () -> {
Bukkit.getPluginManager().callEvent(flagEvent));
if(flagEvent.isCancelled()) {
return;
}
Bukkit.getScheduler().runTaskAsynchronously(FlappyAnticheat.getInstance(), () -> {
//handle event async
};
}
but yeah idk depends on what u exactly want
the super thing worked
^
thanks
if youre just sending messages, i dont really see a benefit of that being async
that too
the packet plugin i use makes it async
why not continue event flow async?
this is calling the event sync
ok
nice
have a good day
I made it call async now
thanks for the help
pog
how do i make a music disc play with a radius of 1000 blocks in a certain world
you uh
dont
sounds have a radius
but the problem with sounds is that once they start in a location, they will continue to play there
so even if you play a music disc for all online players at their locations, once they move or teleport far enough away they won't hear it
Yeah
Well my world has a border of 100
and a build limit of 128 blocks
getWorld("10").playSound( Sound.MUSIC_DISC_WARD, 3);
ive figured this out but
it requires a location and i don't know how to save the co ords 0, 0, 0 in a location
use the Location constructor
whats the location constructor
hey what is the generally used entity to make floating text? like on a server lobby which would have a mob nametag as text without a mob (well, invisible)
oh okay ^^ thank you!
armor stands were usually the way to do it, recently the meta has become area of effect clouds
weird question but uh
is it possible for a PlayerInteractEvent to not be cancelled properly if the server is lagging
does the mob matter for performance reasons?
also im seeing only the nametag of the top level passenger mob, is there any way i can show nametags on all passengers? (trying to make a healthbar + name above a mob)
im getting this error but I dont use the eventdamagebyblockevent
[22:01:43 ERROR]: Could not pass event EntityDamageByBlockEvent to Tutorial v1.0
here is the code it has an issue with:
@EventHandler
public static void onDamage(EntityDamageEvent event) {
LivingEntity entity = (LivingEntity) event.getEntity();
if (entity.getName().equals("DefiantBurger")) {
if (entity.getHealth() - event.getFinalDamage() < 1) {
event.setDamage(entity.getHealth() - 1);
entity.sendMessage("§c§l(!) §cYou almost died!");
}
}
}
here is the error below it:
java.lang.ClassCastException: org.bukkit.craftbukkit.v1_16_R3.entity.CraftItem cannot be cast to org.bukkit.entity.LivingEntity
but im not casting an item to a living entity as far as I know
i want to set the itemstack amount to 3 how would i do that?
you're literally casting it on the first line of the method
you need an instanceof check
& look at the parameters available for new ItemStack
EntityDamageByBlockEvent is a subclass of EntityDamageEvent as well
and yeah when an item is destroyed EntityDamageEvent is called
you need to check that the entity is a living entity before you cast it
since an item is not, it errors
the order of an enum's values() never changes, right?
isnt it ordered by the enum ordinal
probably
file = new File(plugin.getDataFolder(), "friends.yml");
try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
} catch (IOException e) {
e.printStackTrace();
}
saveFile();```
if so then yes it changes, every time the enum order is changed
lmfao'
spamming the chat
xd i find the error xd
did you shade spigot
returned false
nope
forgot to register it
if I wanted to save some data for when the server next starts up, would it be dumb to just set that data in persistent item data when a player logs out, then read it when the player logs back in?
So I have this really weird bug where if i hold down right click with a stone hoe and then spin around in circles, a random PlayerInteractEvent containing LEFT click is sent... does anyone have any idea on whats causing this lol
that is a really weird bug
How would I serialise an item stack?
it happens on one of my production servers but not my localhost lol
How comes ItemStack isn't Serializable?
to yml? probably XItemStack
im guessing this is either some weird ass plugin calling the event with "left click air" out of nowhere or a server lag or ping thing?
cant possibly think of what could be wrong inside my plugin lol
It seems that spinning in circles while looking at just blocks is fine, spinning in circles while looking at just air is fine, but if you start moving your mouse really fast over blocks and air the event just comes out of nowhere
Does the api have a method to determine the top Y pos based on a given x and z pos?
World.getHighestBlockYAt()
If anyone else needs it
after further debugging, the event ALWAYS fire give or take 60 millisecons after the previous interact event, and the click type is always LEFT_CLICK_AIR
is it only with a hoe? does it happen with only a plugin to broadcast interact events?
Im kinda having the issue of having to make everything 100% futureproof and "perfect" as i can, it kinda prevents me from just making things and i lose motivation because i spend days or weeks on a single small thing
Does anyone have tips or the same issue and what's the best solution? I've managed to make things now but it'll probably happen again where i'd lose motivation because of it
i've lost the drive to make anything at all before, where i just sit for days thinking about the project but not actually doing anything
i think it's totally normal, just comes and goes
and i think with practice it has gotten easier to know exactly what is required to make everything as needed
and yknow bugs do happen thats just a part of development
Yeah its really annoying, i tried to minimize and focus on not doing that with my current project and so far i've been able to actually make things work, quest system, mob spawning, custom mobs, dialogue etc
Well its not bugs, but more of things like "i wonder how a plugin the scale of hypixel would do this" and well that's where it goes downhill and i get stuck trying to make it "professional" even though it works just fine
dont futureproof
just make it work
i subconciously branch off my classes
(in this example JavaSource and JenkinsSource both extend Source so i can cast without issues)
yeah like, idk how i do it
i need something? ill make a class for it
then like, 10 minutes later ill be like "tf am i doing lmao, oh well might aswell finish it"
Yeah writing too much code is a curse
I just need to get on with it, make it happen and move on to the next thing
https://gitlab.com/TheArcaneBrony/essentialtools/-/tree/master/src/net/thearcanebrony/essentialtools
take a look at the classes in there
it really is a curse but it works well
like, all of the events i use are separate classes
following a ~set structure
I still have this issue with quests, and dialogues where i want full customization (like idk, when you kill 3 zombies your sword gets dropped, then an xp orb comes flying at you idk, just any customization) which j do by creating a class for every quest i make, so im not loading quests in but end up having a cluttered package with quest classes
ah yeah
thats fun
maybe you should have an enum or something with goal types
idk
lambdas and callbacks lol
at some point i wonder, "which part of this has to be hardcoded, and which part can be in a config?"
I'll copy the link and take a nice look tomorrow since im in bed rn and trying to read that on phone is eh
eh it was just an example of my class structure
Yeah i was thinking of initializing the quests with like quest1.class or using an enum etc, but that's for later
Ohh alright
im not saying its good, but it well, just works
Well it looked good from what i've seen
My code has structure but looks messy because i make the quests and mobs, dialogues too in separate classes (all extending from a parent of course though)
well having differnt quest classes is fine
as long as all the data related to them is stored within
Meh just stuff the big blocks into separate methods and call them like registerEvents(); that's what im doing
fair
Has to be done at some point, so might as well make it look nice since you cant avoid it
ignore the mess that is that onCommand at the bottom
moving those into classes is still on my todo list 😅
i think its a huge rats nest
the main class is probably the best class in the entire project
Yeah same here
Im constantly switching ways of doing things in my head like sending a class reference or just making a new instance already, stuff like that
Well one question i actually have
So i just made it so that i can create spawn points for mobs, where every x seconds it'd act like a spawner
But idk if i should add a new async repeated schedule thing for every "mob spawner" or if i should have one timer which just calls every "mob spawner"
hm
good question
i'd say look into how vanilla does it
wait
youre saying async
hmmm
I also want some spawners to spawn only every 60 seconds, some 10 seconds etc but i might have a solution for that
Yeah yeah
So ending up with 70+++ might be a bad idea in the long run
you'd have to ask around because i think thats a matter of opinion
and implementation
ah yeah @untold kernel
ofcourse
this is my main hub for plugin dev questions lol
i used to
I have mastered the art of doing that
i dont even need javadocs anymore lol
Can't read experience off of javadocs ;)
So I no longer need ask xD
ah
Well no
i dont need the javadocs anymore
because most thigns are autosuggested in intellij anyways
Really bad performance
trying to modify world async?
So true.....
Just wanted to check a players balance every few minutes
And put it in mysql
Somehow lagged the server
;/
One time I was so brain effed that I was performing 5 database things on main thread
there are so many things wrong with this screenshot
On playerjoinevent
Yeah so i think i'll have an async repeated task which runs every 5 seconds which will be the min amount for a spawner to activate, and then maybe i can add a counter for each spawner which only gets triggered at every 20 seconds (every 4 calls if the async takes 5 seconds)
checking the balance itself is fine, i do that multiple times per tick for every player
well
you'd need it to be a multiple of 5 seconds then
shut up i know lmao
Yeah i think 5 is a good number
specifically I'd like to point out that you're using what looks like a util class to get core things
that was an example of bad code
alright alright
Nice flexibility without too heavy of a load
uh yes im using a util class to get core thigns
Dont bulli me :(
😂
Well for me I start out with let's make this clean
mine doesnt look like that anymore
@cinder thistle https://gitlab.com/TheArcaneBrony/essentialtools/-/blob/master/src/net/thearcanebrony/essentialtools/Util.java
util class in question
20 minutes later I challenge a friend I can make the whole plugin in a single class
🙃
coding everything in one line be like
/// LINKS ///
// Discord // https://discord.gg/Wb2HhExrqf
// Twitter // https://twitter.com/n8dev_yt
// My Isometric Mobile Game // https://www.youtube.com/playlist?list=PLjnGtp1-JGh8lyOoiSIXoe8HZYAvnGiZW
----------------------------...
kek
I got a degree in web dev, im a full stack who kinda learns quickly so now i also make plugins. But one thing i always wanted to try was to make a big ass website just on one line of code
yes
well actually no
why would you use zero-width spaces
i think the compiler would get angry about that
just replace it with nothing
dont you need something to replace with
1 class is no fun.
1 class 50 lines is fun
guess not
no you dont
that is the ugliest util class I've ever seen
gotta still have things legible, can't just chuck it all on 1 line and call it a day
there was a bukkit thread for it once
ngl @cinder thistle
Here I am compiling a list of super simple plugins (maximum 50 lines). Use this for amusement, for learning, or whatever, but please do not release...
my util class is epic
not really
@sullen marlin you posted on here 10 years ago, you must remember this, right?
System.err.println("[BananaBonus] "+"iConomy not installed!");
}```
cs.sendMessage("Invalid player");
}```
Yeesh
What did you use back then anyways?
I assume netbeans
how do i get a playerconnection
EntityPlayer.playerConnection
wacky stuff
uhh another thing
i found this code on the internet somewhere
lmao
but
ScoreboardTeam team = new ScoreboardTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), p.getName());
team.setNameTagVisibility(ScoreboardTeamBase.EnumNameTagVisibility.NEVER);
ArrayList<String> playerToAdd = new ArrayList<>();
playerToAdd.add(p.getName()); //Add the fake player so this player will not have a nametag
connection.sendPacket(new PacketPlayOutScoreboardTeam(team, 1));
connection.sendPacket(new PacketPlayOutScoreboardTeam(team, 0));
connection.sendPacket(new PacketPlayOutScoreboardTeam(team, playerToAdd, 3));```
it aint working
