#help-development
1 messages · Page 1730 of 1
ItemStack itemstack = event.getRecipe().getResult();
itemstack.addEnchantment(...);
event.setCurrentItem(itemstack);
i will try
omg it worked... thxxx
np
hey can any1 help me im trying to make a kit and when i do it says that kit is improperly defined contact administrator
Hey, i have a menu setup so when the menu opens it sets all the skull owners async. (So it doesn't block server thread), now i believe spigot caches the skull owner once. I was wondering if anyone knows if i can access it at all?
oh god
please
please at least use a switch and case 😭
or that yea
@EventHandler
public void onCraftItem(CraftItemEvent event){
switch(event.getRecipe().getResult().getType()) {
case IRON_PICKAXE:
case DIAMOND_PICKAXE:
case GOLD_PICKAXE:
case STONE_PICKAXE:
case WOOD_PICKAXE:
ItemStack itemStack = event.getRecipe().getResult();
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.addEnchantment(Enchantment.DIG_SPEED, 3, true);
itemstack.setItemMeta(itemMeta);
event.setCurrentItem(itemstack);
}
}
i mean
thats much better than before
😭
i dont think you can access the cache what do you plan on doing with it?
Instead of setting the skull async, it'll just set while the menu has opened so it doesn't have a quick ugly switch delay
huh
it already gets it from the cache if its loaded?
you don't need to do it manually
Yeah i know, but as you see here ^
I set all the skull owners async after the menu is loaded
so i wanna check if it is cached, if it is it wont set it async
correct me if im wrong but even if you do set the owner async it will still fetch data on the main thread
interesting
As you can see, i load up the menu first and it takes a bit. thats fine thats the requests
Then when i refresh it has that quick blink of the skull changing owners, not sure if you can see that?
yeah i can
and when on the main thread it just freezes?
wouldn't think that little amount would
Well
I'm talking about like each skull there being a different skin (other servers reported it)
yeah
https://cdn.discordapp.com/attachments/893399001972502598/897035646739308604/Huke.gif this is what it looks like from different skulls pov
and thats when spigot already has it cached
so i wonder if i could check if it is cached from spigot and then it wont load async and not have that loading effect when the menu is open
i mean if not you could always make your own cache
Yeah i could, that is correct just dont wanna use much ram i mean if it is possible to access spigot cache then that would be the most suitable even if it has to use reflection i'll cache that obviously
Or maybe, just keep the loading effect after its cached. i'm not sure if i like that though haha
Just store one itemstack?
Itemstacks will change
i mean the texture value and signature is only a few hundred chars
its not a huge amount
Yea, i've decided i'll cache it myself just wondering thats how they do it right. Something like a map of uuid and skull texture?
nice just crashed my intellij lmao of opening the implmentation of SkullMeta
just decompile lmao
(thats what i did)
not in intellij lol
nom nom
I can also recommend just having a local copy of the spigot workspace
god damn 5.4gb
yeah lmao
okay so i can just cache the game profile and uuid in a map
or not even that
so so i'll use mojangs PropertyMap object then
btw: this didn't work because you didn't set the itemmeta back to the item
i told them to do that ^
plus naming conventions too 😩
Which of these two would be faster / the preferred way to check for a player?
e.getEntity() instanceof Player
e.getEntity().getType() == EntityType.PLAYER
instanceof
Makes sense, thank you!
easiest way to run a method every hour in java?
runnable
Use Bukkit scheduler for spigot though
bukkit.getScheduler().scheduleSyncRepeatingTask()
ty
runTaskLater
what
If you want it to run at a specific time (real world) don;t use the scheduler
if you're comparing an enum
it has to iterate the enum constants
iirc
It doesn't
But also just use whatever
I'd use instanceof if I'm casting it, but otherwise doesn't matter
Wait is that .name()
no
swear i heard that somewhere, eh oh well
but really dont microoptimise code like this
Code stuff that’s readable and maintainable
but instanceof is 100% cleaner
Optimise when its noticeable
This will probably never become noticeable. But still a good feeling to do it in a performant way 😄
Okay so I think I found a bug either in the API or in the javadocs
CraftItemEvent
Description in Javadocs:
Called when the recipe of an Item is completed inside a crafting matrix.
Actual behaviour: gets called when the player takes the item out of the result slot. But the description says it should be called when the last ingredient gets put into the matrix
Yes values() kinda does some iteration
As it has to copy the internal array iirc
Javadocs issue, PrepareItemCraftEvent is called when the last ingredient is put it
Is this a mistake in the API, or simply a wrong description in the javadocs? Because I just spent 20 minutes on preventing certain crafting recipes until I discovered it lol
PrepareItemCraftEvent gets called for every ingredient added or removed, regardless whether it results in a valid crafting recipe
Really?
yep
I haven’t checked but that seems weird
I just debugged this for 20 minutes so I'm really sure^^
Hi there, is anyone here experienced with Kotlin and annotation processing (with Maven)? I am building my own annotation processor, but it only works with gradle. But unfortunately my plugins were built with Maven.
actually it still should work, since both work with .m2
A maven plugin requires their dependencies to have a pom I thought.
APs should work regardless of maven/gradle
how to make cobblestone generator slower in the end world? anyone knows?
hey i cant found in 1.16 Material.DAYLIGHT_DETECTOR_INVERTED
some block-update stuff i guess
you gotta check the block data
since inverted is a state, not a block itself
How can i put all the blocks of one type in a hashmap when i have an chunksnapshot?
stream
?
get all blocks and chunk and then stream
this doesnt seem to do anything to prevent mob collision
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntity() instanceof LivingEntity)
((LivingEntity) event.getEntity()).setCollidable(false); // todo remove?
}
both entities need to not be collidable
is there an easy way to get distance between chunks?
Math.hypot(chunkOne.getX() - chunkTwo.getX(), chunkOne.getZ() - chunkTwo.getZ());
Yeah nw
i'm confused i don't see a pf
i think players are always collidable
advise VDS or VPS in order to start the server there.
Is there a way to put a code even before onEnable?
What is the best way to serialize my inventory wrapper https://haste.devcord.club/epawanelul.java ?
@Override
public void onDisable()
{
for(Guild guild : this.getGuilds())
{
for(GuildChunk guildChunk : guild.getOwnedChunks())
{
guildChunk.getChunk().load(true);
this.getLogger().info("Chunk loaded successfully!");
for(Entity entity : guildChunk.getChunk().getEntities())
{
this.getLogger().info("Located entity");
if(entity.getCustomName() != null)
{
this.getLogger().info("Has custom name");
if(entity.getCustomName().startsWith("Verteidiger von "))
{
entity.remove();
this.getLogger().info("Is a guardian: Removed!");
}
}
}
}
}
}
[16:41:50] [Server thread/INFO]: [CCRP] Chunk loaded successfully!
[16:41:50] [Server thread/INFO]: [CCRP] Chunk loaded successfully!
[16:41:50] [Server thread/INFO]: [CCRP] Chunk loaded successfully!```
Please help. There are 3 Zombified Zoglins, which should get despawned by server shutdown, but they don't. Why?
Zoglins
and if for some reason you need it before onLoad, try initializing variables in the scope 🤡
I really don't understand why sometimes I'll get an index out of bounds error with this line: queue.remove(0); when there's a check directly prior.
if (queue.size() == 0) {
break;
} else {
queue.remove(0);```
then also check if queue.get(0) is null
if (queue.size() == 0 || queue.get(0) == null)
break;
else
queue.remove(0);
Ye that is the simple solution, but it's so weird that I get an exception there XD
Also it's like 1/100 times it gives an exception which doesn't really hurt the code, but it's very strange and spams console.
I'll just add the null check.
because hashmaps don't always have to have a key/value pair at index 0 to have an element at some other index
Try sortedmap = treemap
oh no no it's an arraylist
make a new itemstack with one item of the type e.getItem().getType() and remove that
sorry arraylist, concept is the same though i believe
Ex:
SortedMap<K, V> map = new TreeMap<>();
meh its easy and safer to just add the null check
The only think I do with the ArrayList is .add, .get, and .remove which is why this puzzles me
yeah it's just like breaking my head
The treemap can use toArray
I have no idea how it can get past that size check XD
Why don’t u give it a try
The ArrayList does it's job great, just logically, I can't wrap my head around why it's giving the out of bounds exception.
Yeah a null check is a simple solution, I'm just wondering why
I don't think so
It's very unsafe, stick to the main thread onDisable
i also think theres a way to remove only a certain number from inventory but yeah
So you want to run all of the SQL commands onDisable?
maybe you could run a synchronous task in which you can run async tasks, wait for parent synchronous task to finish and then allow server to disable
idk tho
It definitely sounds like you will need to restructure
Consider not sending all SQL commands onDisable, rather send them to an async thread as new info is needed to the SQL
java.lang.IllegalArgumentException: Plugin already initialized! how would you fix this?
im assuming this happened because im making another instance of the main?
i did something like MainFile main = new MainFile;
so that i could do main.getconfig()
Yeah don't. Use DI or Singleton if you need your plugin instance
how about make a static method in my main file like "getInstance"
then i can call it in another class
is that a good way
That's what Singleton is
why do you want people to test your plugins for you lol? nobodys gonna do that
test them yourself?
I mean thats when an alt is useful lol
ok thanks
read the error message
new ItemStack(e.getItem().getType(), 1); Before you test for null
this
I advice against that
?di idk if this might explain a bit why just passing your dependency down to ya fella component is somewhat better
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
what should i do
You test every method return that can be null before using it.
ok thanks for the resources
getItem() can be null
I already told you
e?.item
my eyes
dont even need to call the getter
you are using getItem().getType() without checking the return of getItem()
it just does
no but types can be T? to mark it Nullable and T! Or if it was T!! Which declares it as unknown nullability
Reinvented regex mybud
(:
From inventory?
easy way
Loop through the inventory contents
An inventory is O(1) is it not? Inventory size can't be higher than 54
binary search ?
still O(n) but with a max of 54
Well iteration is O(n)
so not bad and not worth trying to optimize tbh
Depends
Ik Bukkit loves to clone ItemStacks
So might be worth optimizing if possible
iirc some method clones the item stack 2-3 times
you can do that in java???
huh xd
oh in lotlin
kotlin
Well smtng like
Inventory inv = ..;
for (int i = 0; i < inv.size(); i++) {
var item = inv.getItem(i);
if (item.getType() != Material.WOEE) {
continue;
}
int amount = item.getAmount();
if (amount == 1) {
inv.setItem(i, null); //might have to use an air stack idr
break;
}
item.setAmount(amount-1);
inv.setItem(i,item);
break;
}
@quaint mantle iirc something like this should work
On phone so something might be a bit yeah
i started using kotlin like a week ago and its SO MUCH BETTER
on mobile, thats dedication right there
i mean like how different
GODDAMNIT RIGHT IT IS
did u get used to it instantly
its like java if java was written in 2021 and not 199whatthefuckever
god no lol
Kotlin is pretty different
damn
Just
Optional.ofNullable(x).isPresent(y -> {
});

it's much more concise of a language
how did u learn it exactly
took me about 30 mins to learn and a few hours writing to get used to
meanwhile, Kotlin:
x?.let {
// it = lambda param
}
Kotlin is quite similar to Java so just learning the Java equivalent is easy
yt tutorial, also a lot of help from (dont wanna ping) but Princee
absolutely
yoo
But it has a lot of additional features which you’ll have to learn
Yeah kotlin is way more functional than Java
Also coroutines 😌
is reflections easier 😔
Yeah
COROUTINES
ye
About the same
everythings easier
c# type of vibe
😩
yoo
i just do @hoary knollthrows 😅
bruh
are u kidding
who tf is @ sneaky
if you do need to declare exceptions for a method, just apply the @Throws annotation to a method
Well ofc java shit might enforce you to try catch
but that's mainly for interop
i meant @ SneakyThrows in lombok
But other than that
oh shi
😬
does kotlin basically have lombok shit for u
I personally dislike sneakythrows
Actually yeah kinda
😔
data class
Kotlin avoids checked exceptions
oo
So no need for sneak throw
Getters/setters are obsolete
Properties 😌
properties ?
Since all public values, AKA properties, compile a getter/setter
o
^
And data class also compiles equals and hashCode by default
And it’s interoperable with java getters and setters
Oh ye also primary constructors
So you can simultaneously use both Java and Kotlin although that’s like wanting to shoot yourself in the foot
data class Person(
val name: String,
val age: Int
)
which you call like Person(">:)", 499065)
yeah, there's no new, constructors are treated like methods... bc they are
also everything immutable by default 😌
oooooo
.
nah
kotlin is just sm better in every way
there's var and val
var = variable (mutable)
val = value (immutable)
then for collections, you have List and MutableList (plus the mutable/immutable versions for everything else)
If everything is immutable then it’s free thread safety 😏
i was thinking of arrayOf and the mutable version nvm
y'know, Rust does thread-safety pretty well
Rust is amazing
basically an object can only store one mutable reference to itself at a time
which stops data races
Yep
as only one source can modify the reference at a time
Oo yeah then we don’t have generic wildcards in kotlin which is quite nice
Site declaration variance (:
Class<*> (star projection)
although, I'm curious to know how they differ
Oh yeah *
Probably what it means is that Kotlin doesn't have wildcards in the same form as they are present in Java. Instead, Kotlin uses a different concept of mixed-site variance, which adds an option to specify the variance at declaration-site, that is something you cannot do with Java wildcards.
Well you can’t use * out T or * in T
I fucking hate wildcards btw
just out T and in T
for like really big, complex projects, IDEA loves to give you the weirdest errors
- Error -
Expected: Class<T>
Result: Class<T>
something like that ^
which, T is different in both contexts
Yuh
the expected T comes from Class while the resulted T comes from a method in Class that shadows the name of T
(although I don't think Class does this bc OpenJDK aren't fucking idiots except for when they broke everything again)
I’ve got the classic sometimes
Required <I,O>
Provided <I,O>
but yeah
rip
Though kotlin to the rescue!
Just provide it better smh
Yeah jfc I’m a dodo

how can I get the string content of a textcomponent?
Probably need to use a legacy serializer
sorry I had a component not a textcomponent
I'm a bit new to plugin-making and I have a plugin Halara-Core that'd I'd like Halara-Lobby to have access to. I've already added the dependency in Halara-Lobby's plugin.yml and was wondering where I go from here.
I've tried just adding it as a library in the project but I don't believe that's the way to go about this- I could be wrong.
Has anyone experienced issues with not all portals working after last spigot update?
Some portals will teleport, and some work. No errors in console, i can't figure out what is the difference. Even portals side by side, only one will work.
what version was your world generated in and what version is your server?
guys , difference between CreatureSpawnEvent and EntitySpawnEvent?
one is triggered when an Entity spawns, one is triggered when a Creature spawns
if I had to take a shot in the dark at what you're using it for, use EntitySpawnEvent
what would be the difference between a 'creature' and an 'entity'
stupid question but hmm whatever
is there any good tutorial about mysql?
A creature is the type of entity
And vriend, map was generated this last mc update 1.17, spigot is currently CraftBukkit version 3257-Spigot-dc75aca-960f310 (MC: 1.17.1). Im puting in some debug messages to track down where it stops working.
What would be the best approach to check if a zombie i have stored the entity UUID of has spawned or not ?
using entityspawnevent?
I don't think 1.17 worlds are compatible with 1.17.1 servers
that might be your problem
wait ill send a pastebin of the code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@EventHandler
public void onZombieSpawn(EntitySpawnEvent e){
if(e.getEntity().getType() == EntityType.ZOMBIE && e.getEntity().getUUID() == myUUID){
//it has spawned
}
}
syntax might be wrong because I use kotlin but you get the idea
yes legit what i did
are you getting the CraftEntity uuid or just using java's uuid lib to generate a new uuid tho?
check the pastebin
but for some reason the >--< doesnt spawn
Is there any way to change which direction an entity is looking without having to teleport them to a location with the direction changed?
have you registered the event listener in your main class?
basically since im custom spawning the mob
whenever i custom spawn the mob , i store its entity in a uuid thing
and this uuid works for the other stuff i use it in like removing the mob by uuid and all that
and yes its registered to the main class , this whole class is
actually you can eliminate the checks for entity type because the uuid is unique
vriend, when going through portals that wont work, the PlayerPortalEvent triggers but then PlayerTeleportEvent never triggers.
do you have some kind of plugin or configuration that would affect this behavior?
didnt work 😦
didnt print the >--< when the zombie with the uuid spawned
You are spawning the mob then storing its UUID
I would use getLogger.info(">--<"); for now to debug, one less thing to troubleshoot
Not that i see, i put debug messages in each event to see what was being triggered.
let me recheck if thats the case.
not sure why the event wouldnt be firing then
unless PlayerTeleportEvent isnt usually called when entering a portal
which seems like it might be the case
no like i want a way to constantly check if the custom mob i spawned is dead or alive on the server , thought this would be the best way to do so.
?
That still applies
If you really want to check every tick just make a runnable
then when an entity spawns do the check strubbe said an when an entity dies do the same check
this is way less efficient
well uhh for a database for my plugin should you guys recommend postgreSQL or sqlite3?
Yes I understand that, im saying if they really wanted to check every tick
How do I prevent this?
Just store every custom mob's UUID in a list, then use EntityDeathEvent and remove it if the entity that died's UUID is on that list
Guess i will have to wait for md5 to find and fix the glitch.
sqlite is my choice
i just looked at that site 👀
that seems too excessive for what im actually trying to achieve
What exactly are you trying to achieve?
@cinder plume do this
If they have the circumstances to spawn the entity they should know whether or not its been spawned
Im not entirely sure how they're getting the UUID of a mob that has not existed as an object or not been created yet
im trying to ensure the custom mob i spawned , spawns only one of its kind
Oh, just store the UUID somewhere and default it to null
If its null, then no entity, when you spawn one, fill it with the entities UUID
When it dies (Checked using EntityDeathEvent), set the UUID back to null
ok wait ill send a pastebin of the functions wait a second
https://hastebin.com/anaxefiyim.csharp @wispy bridge
Did you happen to switch from LUA to Java?
no i did not
Oh haha, it just looks like it
ahhh , nah man xD
Just set the UUID to null
when?
Whenever you're doing your odd integer thing
@EventHandler
public void bossSpawnStateSetter(EntityDeathEvent event) {
if (event.getEntity().getType() == EntityType.ZOMBIE || event.getEntity().getType() == EntityType.SKELETON) {
if (event.getEntity().getUniqueId() == boss_uuid) {
bss = 0;
Bukkit.getServer().broadcastMessage("<--->");
}
}
}
??? nah u got it correct
ok so when it dies i set it to null ?
right
Yes
Also you should follow some naming conventions for the future
Like, your variable name for the Boss' UUID should be called bossUuid or whatever, _ are not really cool
Mhm
okay , wait.
no no , if i do that then , i wont be able to use the boss_uuid for other things
because it will set it to null
i use the boss uuid for other things too
and it works for them
just doesnt detect spawns
Yes but you dont need to use it when it dies I assume?
no i also set when i spawn it
wait
Yes you dont need the entity spawn event thing
line 56 of the pastebin
You already know the conditions of the zombie spawning
Its when you call the method
Like, you dont need to check if the mob has been spawned if you set the UUID of the mob after it has been spawned by your method
no , i need to ensure there's only 1 of them in the server/world so i use the bss thing which stands for boss spawn state , and if its 1 that means a special zombie exists , if its 0 that means it doesnt and then another special zombie can spawn
Just remember to set it back to null when you're done with your mob, so you know the space is available
Yes, I know
okay , wait.
The UUID would be filled in when it spawns, then set to null when it dies
yes
Therefore, checking whether the UUID is or is not null will tell you whether the mob is or is not alive
but my doubt was , why is it not detecting the mob by uuid when its spawned
my issue arises in the entityspawnevent thing
its not working
You dont need to do that
Theres no need for entity spawn, you have already spawned the mob, through your method
hmm true.
No need to check whether it has spawned through the event because the only circumstances where it might spawn are circumstances which you control
true true
so should i make the bss thing 1 in the function ?
it would be better that way , right?
You dont need your integer thing
instead of doing it in some exterior body
Just set the UUID to null
boss_uuid = null whenever it dies
Im assuming your integer is for telling whether its alive so its not needed anymore
no its to ensure another custom mob of the same kind is not spawned when the bss integer is 1
okay , ill consider that.
I feel like you are not fully grasping the UUID null idea LOL
hey can some1 help me with kit improperly defined contact administrator
yeah most probably not.
owh , i think i grasp it now.
i use that instead of the bss thing.
Yes
You should ask this in the Paper discord, not this one
Ohk
Your method names are flipped btw @cinder plume
Doesnt matter but just to let you know
The spawn one is called bossDeathSetter or whatever, this ones called SpawnState
ye , will change it up
sorry mb if it caused u probs
It didnt haha its just for neatness
👍
how can I update a chest gui?
like
I have this variable named "cat" for example
i need it to be named "dog" on click
i know how to setup hashmaps and stuff btw
just asking about the way of updating the gui
without having to re-open the gui through command or whatever
how can I update it so it shows the new value of name/lore of clicked item
Im pretty sure setting the ItemMeta of an ItemStack will real time update it
no no
I use serialized data that is linked to the gui
so when you click it writes data and saves it
now i want to know how to update it to show new VALUE not update name of the item manually
;-;
its not really dog and cat
those are examples
its something bigger but eh
If you close the inventory then open it a tick later it shouldnt be noticable
how to wait lmao
BukkitRunnable
this is the only thing that stopped me from using cooldowns
waits and timers
lol
hmmm ima google that
hi, how would I make a chest GUI like an echest plugin open with a command I guess
like just a virtual chest that is openable with a command and keeps items in it without deleting
oh wait I just found a wiki post
use serializer or some data storing way to store them onDisable
and use hashmaps i guess to use echests linked to each player
PersistentDataContainer
store ItemStacks*
Easy storage in every mob and itemstack
Alfie
Anyone have an idea wtf is this crash log message supp to mean https://hastebin.com/taborimevi.yaml
Terminated by watchdog o-0
Something in your Endless class on line 240
Can I see it?
sure
line 240 is just this
allPlayerss.addAll(Bukkit.getOnlinePlayers());
this rarely comes
and then i restart server and then all works well
this crash
i restarted and tried all , it worked well
Mhm, your crash relates to your allPlayers list, I cant really get the full picture of why it might be crashing but im pretty sure you are constantly adding players to that list like multiple times
Or, an infinite amount of times
wait how did u pinpoint it to line 240
Java logs are extremely useful
ye but which part of the hastebin log had the line 240 thing
me.trg.theraidgame.events.Endless.ZombieTeleportAbility(Endless.java:240)
doesnt it say the same for 255 256 etc too
Yes but those are the tiers which lead to that line
Or the specific reason of the crash
oaky
does it keep data after server restart?
Yes
lemme think
Its stored in the NBT
It is extremely useful to learn
Hmmm ima look into it
should i use it or serializer tho?
Well, whatever you want? Haha
ok i have taken a general all players list instead of taking al players again and again from the server
that should fix the inf looping prb
well technically i can use whatever
but what do u think works more efficiently/easier to access?
@cinder plume Did it crash when the Zombie tried to teleport
PersistentData
not exactly
serializer hard to use but extremely useful
Because it looks like if there's not a valid spot for it to teleport, it's an infinite loop
Since safetpc is never 1
so the problem didnt stem from the allPlayers thing?
I guess not
it shud become 1 when the function isSafeLocation finds a good one
Does it ever find a good one?
oh wait
Yeah, and if it can't find a good one you're in an infinite loop
lol
You should get a random location then do more with that location rather than using that random location and getting another one
Like if its in the ground try to find a high available place rather than picking a new random place
Or an adjacent free space
.csharp????
no ts not idk why its in that lmao xD
xd
I dont see anything different
no
What changed?
the thing is , the while loop had the whole thing inside
like
the whole function
now its not inf loop
It looks exactly the same
well the zombo doesnt use the tp ability always
the stop condition is safetpc = 1 right
Like, if somebody is in a hole it will forever try to choose a new location
so when it becomes 1 , the while loop stops
Yes, but what if it never becomes one?
If you set it to do so, yes
no it wont hm.
But as of right now, it will check forever
Just have an integer tick up everytime in your while loop
if it checks 10 times then tp to the player and punish the loser for caving in
thats the idea right
Yes
true that should fix this
10 times might be too low
ye
30-50 should be alright
whts the tick speed of a general compiling procedure in java?
like
isint it instant ?
like if im in a hole , wont it like hit 50 in like an instant
loops are fairly optimized so yeah some nano seconds if not lower
The invention of computers is the pinnacle of mankind
one way to look at it
It didn’t happen over night, and it’s hugely based on mathematics. I think it was gonna happen eventually regardless. We tend to continuously find more and more efficient methods of communicating and solving problems.
Computers are just lots of light switches crammed together.
indeed
just thinking about how one day man thought 'ima make a computer' is just crzy
https://hastebin.com/xelaqociqa.csharp check this out @wispy bridge
Well like this person said it was alot more than that but epic regardless
You need to add the stop condition in your while loop
Because the program wont exit the while loop until your safetpc == 0 condition is met
Thats not in your while loop
while (safetpc == 0 && tpchecks != 50)
wont that stop it ?
Thats outside of your while loop
what are you trying to do?
They want to do recursive checks for random locations but their while loop has no hard stop condition
no no no , on the contrary , shouldnt safetpc become 1 when it checks 50 times for a safe spot and doesnt find it ?
line 22 is in the while loop tho?
ah so in worst case it could cause a freeze I presume then
Oh shoot
ye xD
Well you should probably put it here anyways
Yes, it crashed before
ok thats fine too ig
Yes your way is fine
epic so this shud work cools
Wait
if(tpchecks == 50){
spploc = allPlayerss.get(bossSpC(allPlayerss.size())).getLocation();
}
if(safetpc==1 || tpchecks == 50){ //checks 50 times and then straight up teleports to the player
zombieboss.teleport(spploc);
Bukkit.getServer().broadcastMessage(ChatColor.DARK_BLUE + "[Sug]: " + ChatColor.GRAY + "I'm coming to kill you! Skadoosh~!");
}
Dont need the or
What a peaceful zombie boss
hahhahah u wish dudes fast af and deals a lot of dmg
yep
Too ez
is this a public plugin of yours or just something else?
public plugin ?
nah im just developing it to pass time
ill upload it once im done
alr
ah thats pog
yep yep
in school we just learn silly python
yeaa, I mean oop kinda sucks but its a nice paradigm to know
easy to understand and used for a lot of things these days
on the contrary i love the concept of OOP
I love OOP
arguably the worst thing that was created imo lol
I think I might just have bias because I learned OOP first
but at the same time Ig its somewhat good of a style in certain scenarios
I just like functional more
¯_(ツ)_/¯
sure state is nice but damn it messes things up also imo
its a fun and new concept
I like mixing the two
i dont understand why people say stop using a lot of statics
doesnt static actually work with the state of memory ?
OOP is great for making an easy-to-understand structure
Functional is great for making easy-to-understand implementations
I think its about performance if I recall?
really?
Dont quote me on that
I don't use static a lot of time bc of extensibility
invokestatic is somewhat faster than invokevirtual
yaaa you xD
xd
i like statics , but i never understood the reason people say stop using statics
a person ik said statics undermines the reason of OOP
That is probably the most based take I have heard on the matter
I can kind of see that, yes
yep
because u can just make everything static
and , just call by A.number
no need to create an object
just makes life easier in a way
I wouldnt abuse it though
yep i just wanna understnd the reason why not to abuse it
like is it technical or just a silent rule
to never use it a lot
Its one of those things that people say but nobody knows where it started I think, its just not very good practice for the future
problem with static is that you cant achieve any sort of inheritance, abstraction or polymorphism
yep , the based take
Based
but what about the technical side, does it mess with memory?
and its a problem especially in test driven development
well everything messes with the memory more or less?
no as in , like how bad is using a static
bcuz sometimes i feel , its needed
bcuz some variables are most of the times needed to be static
It should never be absolutely needed
in terms of speed its not bad
its faster than general oop (in java)
but you will suffer with tightly coupled code etc
as in ?
tightly coupled ?
your code becomes rigorously dependent on specific instances
which makes it hard to test
and since you dont have classes for things (assuming you only use static) you wont be able to mock your stuff either
i would also assume beginners like me would have found statics easier to use to transfer values between classes initially , and then found out and understood oop very well and stopped using statics , right?
this will also cause fragility and immobility
yeah
usually thats the case
makes sense
first over use static then drop it
then overuse lombok then drop it
then overuse generics then drop it
etc
lol
lombok ?
uh yeah google it
its some automatic shi
it tries removing boilerplate code
wow
lmao
anyways ill head out for now , will test all in a while and let yall know tomorrrow its late for me here
thanks for all the help guys 😉
good luck
Lombok epic
useless
imo
and if you really hate boilerplate code and verbosity kotlin suits you much better
If I need to rush a commission it literally saves my life
wet
dry
ya
people say that singltons are not recommended
but what if you wanted to make some kind of service
and have that accessible to the outside
if its an api yes
you will need inheritance from some base class which is not possible with static
but you have to inherit from a base class
yeah
probably an api context object
@EventHandler()
public void onInventoryClick(InventoryClickEvent event) {
if(!event.getInventory().equals(inv))
return;
if (event.getCurrentItem() == null) return;
if (event.getCurrentItem().getItemMeta() == null) return;
if (event.getCurrentItem().getItemMeta().getDisplayName() == null) return;
event.setCancelled(true);
Player player = (Player) event.getWhoClicked();
if (event.getSlot() == 0) {
player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You are now Super Steve!");
}
if (event.getSlot() == 8) {
player.closeInventory();
}
return;
}``` does anyone know why it doesn't do anything?
that doesnt matter ?
shouldnt matter
have you tried debugging by maybe printing after every if statement?
yeah i've tried, nothing works in that whole thing
it doesn't give errors too
it was working in main.java before i added it to the gui.java
have you registered it as a listener?
this is the whole file
wdym
yes
mhm
this is the only method?
yep
as far as i know, it doesnt
anyways I'd very much like to disagree with "people" whoever they might be. It can be the wrong design but dissuading it and saying that it isnt recommended is straight out wrong.
yeah
static is good for constants and simple utility methods in my opinion
but i never put data fields in there
yeah
as i might want to inherit it later
well I do use static for some other stuff like factory methods
yeah
like methods that dont depend on data outside of parameters
and maybe some other static constants or stuff
i do keep static fields for storing instances of course
thats basically my reasoning but there are of course exceptions
they are easier to debug though
because you dont need to keep track of instances
harder to test
nothing was outputted
well then it doesnt run
its hard to automate a unit test with static
automated tests which test individual instances
junit yeah
How can I get a spawner block entity type?
intellij supports it excellently also
do you know why? I am confused asf
iirc BlockState
send main
or a part of main
make sure onEnable runs completely
package me.aly.heroes;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import Gui.gui;
import superjump.superjump;
public class Main extends JavaPlugin implements CommandExecutor, Listener {
@Override
public void onEnable() {
this.getCommand("superjump").setExecutor(new superjump());
Bukkit.getServer().getPluginManager().registerEvents(this, this);
this.getCommand("hgui").setExecutor(new gui());
}
@Override
public void onDisable() {
}
}
until the point where you register it
that is main
bro
u forgot to change the listener this in registerEvents with the gui class
doesnt matter
ofc
i have that all the time
stupid mistakes that take me like an hour to figure out
legit took 3 hours no joke
._.
ive had like 2 days once
was horrible
it was my first plugin so i got tired of it and i moved on
i can never seem to finish projects
rip
the configuration section is null
the art to keep going is by not doing everything from the beginning
or you are querying it from the wrong config file
extremely true
i always try to do everything at the start
because i am so excited
for instance luckperms was once in a time where it was inferior to pex lol
yeah thats the issue
because things take much longer than what u plan on,
nice
yeah
have cthat with school too
lmfao
for instance tie shoes take like 5 seconds right?
but how long does it take to write the instructions for the dumbest being on earth?
means you're effectively calling Bukkit.getWorld(null)
Anyone?
have you tried googling?
cuz I believe there exists a quite solid thread on that topic on the forums
public abstract class Service extends Thread {
static ArrayList<Service> services = new ArrayList<>(10);
String name;
public Service(String name) {
super(name);
this.name = name;
services.add(this);
}
public void destroy() {
this.disable();
services.remove(this);
}
AtomicBoolean enabled = new AtomicBoolean();
public boolean isEnabled() { return enabled; }
public void enable() {
this.enabled.set(true);
this.start();
}
public void disable() {
this.enabled.set(false);
try { this.stop(); } catch (Exception e) { e.printStackTrace(); }
}
@Override
public abstract void run(AtomicBoolean enabled);
}
look at this epic service class
aight bye
oo
I did try googling but I didn't really understand some stuff
Does someone know why this error comes? https://hastebin.com/ebugutoloj.md
did you save your config with saveDefaultConfig() ?
Manager.arenas is null
read the error
you defined it as a LIst but never initialized it
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.ArrayList.iterator()" because "com.hitman.minigame.Manager.arenas" is null
.
code?
._.
private static ArrayList<Arena> arenas = new ArrayList<>();
and fixed
and why static
why is everything static
create singletion
then only create 1 instance in the command class
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if(!event.getInventory().equals(inv))
return;
if (event.getCurrentItem() == null) return;
if (event.getCurrentItem().getItemMeta() == null) return;
if (event.getCurrentItem().getItemMeta().getDisplayName() == null) return;
event.setCancelled(true);
Player player = (Player) event.getWhoClicked();
if (event.getSlot() == 0) {
player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You are now Super Steve!");
}
if (event.getSlot() == 8) {
player.closeInventory();
}
return;
}``` this doesn't work, nothing is being done. and yes it's registered this time
i've tried to test by printing on start and it worked
if(!event.getInventory().equals(inv))
return;
if (event.getCurrentItem() == null) return;
if (event.getCurrentItem().getItemMeta() == null) return;
if (event.getCurrentItem().getItemMeta().getDisplayName() == null) return;
one of these is getting triggered
sysout after each test to see where its failing
^
plus it let's me take stuff from the gui
ok
if you cancel the event then you cant use all the other stuff
put the setcancelled before the return
also i dont think you need a return statement either
its really annoying to view it in here like that
read the error
getArena(int) is returning null
Manager
it says it in the error, in the caused by line
read the because part
by: java.lang.NullPointerException: Cannot invoke "com.hitman.minigame.Arena.getState()" because the return value of "com.hitman.minigame.Manager.getArena(int)" is null
thats the most important part
@quaint mantle you need to learn how to read exception messages
If you understand the syntax its quite easy
Since java 16 it gives even more information
You can see exactly what caused a nullpointerexception adn what was null
Also a CommandException is thrown when an error occurs while running a command
Youre going to have to look at Caused by: to see the actual exception
both because getArena(id) is returning null. Likely the List is empty. You have no arenas
For example:
An exception occured: org.bukki.command.CommandException:
at org.bukkit.... // this is the stack trace
Caused by: java.lang.NullPointerException: // this is what we are after
Could not do something because Test.hello is null // detailed error message, very useful
at com.example.Test.main (Test.java:66) // tells you exactly where and at what line the error occured (file name:line number)
Late answer but im on phone
I had to manually type that
Np
sysout your arenas as it checks them
