#help-development
1 messages Β· Page 1450 of 1
extend EntityZombie instead of Entity
Yeah the zombie is probably a good place to start
I know that π¦ But i want to make multiple entity class it's just example
you can extend it if you want, but you also have to implement what you are extending too
okay
hmmm
So should I implements all of "EntityChicken, EntityCow, EntityZombie, EntityArmorstand, EntitySkeleton" Etc?
what I meant is if you are extending EntityZombie for instance, you need to implement your entity class at some point otherwise you won't have your custom entities
simply overiding the class won't do you any good on it's own
hmm are you saying implements EntitySkeleton?
if so, it would be very annoy
I don't want to extend each entity type, so I want to create a class that can extend all entities.
Lets say, your custom entity class is called FlamingSkeleton. Which then extends EntitySkeleton. You will need to implement FlamingSkeleton at some point to have that entity spawn. Unless you are implementing EntitySkeleton and not just simply extending it.
idk why but this doesn't work, https://prnt.sc/137x2hz
hmm yaaa but I want make a class that can extend all entities.
for example,
You can't easily
well, not sure you are going to be able to extend them all as easily as you think
sadd:(
you would first need to extend the most upper common interface they all share
and then do some magic with casting
possibly would need some reflection in there lol
all bukkit entities extend Entity. You can;t make them extend your class, so you can only extend theirs.
The reason I want to make it is because I'm making an npc plugin and I want to adjust the pathfinder to create an entity type.
so the pathfinder is going to create an entity?
hm, okay. so i can't make a class that can extends all entity?
not the way you think it would
no, you can only extend one
I want adjust pathfinder of entity
of ALL entities?
yaaa
like citizens plugin
that is easy to do, and don't need to have a class extending entities to adjust pathfinder stufff
should've just said that
rly?
Just listen to the pathfind event
can I adjust pathfinder without custom entity class?
oh
you can register custom pathfinder goals and use reflection to change it for entities
or use the API to change the pathfinder goals depending which version you are using
I'm not depending apis sorry!
think recent versions lets you set pathfinder stuff without reflection
meant version of spigot
can do some searching using the terms entity pathfinder goals
should be able to find plenty of resources on it
Hello! I think i'm missing something. I have created some custom 'items' based on the Material Paper. There are some right click actions etc and everything works fine. I got some of these items in Shopkeepers and that works fine as well with no problems.
Now my question is. Do these 'custom items' have ids or something to identify them? Cause i was looking at other plugins (e.g. GUIShop) where i have to put the items in the config and i have no idea how to reference them? Thanks in advance!
unfortunately you would need to make your plugin that creates custom items, hook into plugins that you want it to work for since the only difference between the item your custom item is based on and your custom item, is most of the time the lore or some nbt data and not necessarily the name since mc clients wouldn't know what it is.
the best you can do with naming is set a custom display name, but that doesn't change the underlying items name
some shop plugins are open source however, so the alternative if this is something you are making for your server is to alter the shops source code and compile a custom version of it.
thanks for your answer! Yeah i was thinking that the only way would indeed be display name (including color characters) or nbt? but i haven't played with nbt tags yet.
I don't mind hooking into other plugins. I indeed thought it was like how you just described it but i thought i will ask π
That could be a solution indeed thanks! I'm going to see how we are going to move forward. Otherwise i can setup my own quick gui to buy some items as a plan c.
well sounds like you are on the right track then π
hmmm I learned how to make custom pathfindergoal but how can I make entity to run this pathfindergoal without extending Entity class?
or did I learn anything that didn't matter?
reflection is a way to do that
okay
i'll learn reflection pathfinder
hmmmmmmmm
reflection pathfinder tutorial doesn't exists
you can go the route of creating custom entity classes, but that is usually easier to do if you are only wanting to modify limited entities and not an ideal way for all entities. So reflection is your best bet to limit the amount of code you have to do.
that is because reflection isn't specific to anything. But you can find tutorials on how to use reflection for NMS
and then you would apply that knowledge to change pathfinder goals on entities
hmm okay
but I couldn't find reflection pathfinder tutorial π¦
btw, I know a bit of reflection
Hey,
So basically I want to know how to give entity (zombies in this case) the noai tag. I saw this:...
this contains information on how to change an nbt tag for noai using reflection
basically, same concept for you, just you are wanting to change the pathfinder stuff
thanks!
reflection can be difficult and one of those things where you are going to have to mess with it a bit
oh! I needed noAI And the reason I needed pathfinder was because I wanted to get rid of mob AI with initPathfinder().
it's ok
i'll try hard
lol well then looks like I found the perfect resource for you then π
but, if the reason you wanted to alter pathfinder stuff was to get rid of mobAI
just know the spigot API has methods to do just that
and pretty sure they exist in 1.15
declaration: package: org.bukkit.entity, interface: LivingEntity
just have to check that the entity is an instance of living entity and if so, use that method to turn off the AI π
but thanks you. i learened so much about reflection!
that is the best way to look at it π
how can I change mob(entity but not player)'s uuid? (to get uuid, we are using "entity#getUniqueID()"
in google, people says it's Possible, but they doesn't tell how to do. and they only say "don't do that"
UUID is created when the entity is spawned thus that is where you would need to change it and it shouldn't be changed so as long as the entity is alive otherwise you will most likely introduce memory leaks since the server would lose track of it.
hmm
usually there isn't a reason to change it
I want to change it cuz i'm making npc
you can use the force parameter to have them display at a longer range iirc
okay, that means I need to provide a data parameter, can I just set that to null?
tbh i don't know, probably yes
@quaint mantle just keep track of your npc's UUID's. no need to change it or attempt to change it.
store it in the PDC instead maybe ?
mutating the UUID might have some nasty side effects
oh great it worked ty!
Surely the UUID will be filled in when you create teh Entity on the server
as you extending existing Entity classes
oh
yap, but it's random π
yes its always random
yaa so I want to make my own npc's uuid
why
Just use the UUID the server gives you
but it always random
it may be random, but you are going to have to keep track of your NPC's anyways. That means somewhere you should be logging your custom NPC's to a file with their location and you can then store their UUID as well.
UUID's don't change once they are created
yes, update teh UUID you have when you spawn it
you are meaning for tracking it across server starts?
just use the uuid you get from the entity
Yes, just update your UUID reference when you spawn it
yaaaaaaaa
the point of an uuid is to be universally unique
you reusing the same UUID multiple times is countercurrent to this maxim
you can listen for the spawn entity event, check its your NPC via various things and then grab the UUID of said entity
oh okay
thanks you guys.
i'll change uuid when server reload.
wait
hmm
nvm!
UUID's persist between restarts, so once you have it, log it and log the location of said NPC as well
now, you can reference your entity unless it dies and gets regenerated
are your NPC's actual entities?
like player entities
what is actual entite?
Like are they actually entities?
Usually NPCs are spawned via packets so they aren't actually registered @quaint mantle
I'm spawning with world#spawnEntity
Why was I pinged
what is the proper way to get the server time in ticks (that doesnt break with daylightcycle off etc)?
I mean idk but papi works XD
who is papi lol
A plugin lmao
Placeholderapi
There's a api for it so u can use and make placeholders lmao
Docs?
docs?
I'd rather not rely on an API when not needed so i think I'll go with incrementing a variable in a runnable (that already exists anyway cause I need to do other stuff every tick)
Sounds like a bad move for performance
its just a single int operation plus I need the runnable anyway so I dont see how it would affect performance
I could only find world.getTime() and the built-in java time that is independent of ticks
that wont work with variable tickrates unfortunately
plus that would actually be less efficient than incrementing a counter
if there's no builtin way to directly get ticks then ig the counter is my best option
uh don't use papi for this lmao. that is for players in game not for code
papi stands for placeholderapi, a pretty popular plugin for its placeholders
its well documented and stuff, but not viable here
Well yeah but I mean it has a server time placeholder i think
I settled for this: https://imgur.com/a/MYRrJEB
oh
public class VanillaUtils {
private static int tickTime = 0;
public static void incrementTickTime() {
tickTime++;
}
public static int getTickTime() {
return tickTime;
}
[...]
in onEnable:
new BukkitRunnable() {
@Override
public void run() {
//run these every tick:
VanillaUtils.incrementTickTime();
ProjectileManager.onTick();
}
}.runTaskTimer(this, 0, 1);
i know its a utility class, but why not just use a manager instead
is there a difference?
Yes, your use of static here is not proper
static is used for constant variables
like enums are just public static final fields
but you are making the counter mutable
VanillaUtils is a static class but java does not support static classes (in the traditional sense)
?
How could I add a cooldown to the command here, sothat players can't just spam it before all the messages have been sent?
if (cmd.getName().equals("npcleo") &&
sender instanceof Player) {
final Player player = (Player)sender;
player.sendMessage("Progressing through your Collections unlocks new crafting recipes, brewing recipes, trades, enchantments, and more!");
Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin)this, new Runnable() {
public void run() {
player.sendMessage("Visit resource areas like the and Mine gather items for your Collections!");
}
}, 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin)this, new Runnable() {
public void run() {
player.sendMessage("There is a of the you can gather Oak Logs.");
}
}, 60L);
Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin)this, new Runnable() {
public void run() {
player.sendMessage("The world is full of resources. Explore the island to discover new items that you can collect!");
}
}, 100L);
return true;
}
static makes it accessible on a class-basis rather than an instance basis
In incrementTickTime why do u need a static ??
thats what I meant my bad
for the case of ints it is equivalent
You have to keep track of the time and check the difference between two times I think
since they're primitives, a non-reassignable int is effectively immutable
Idk how to do it but yeah
but returning to your original point, static is not used for constant variables
that is static final
or just final if you want it to be constant for an instance rather than for the whole class
static is used to make a field instance-independent
uh no
static itself
the concept itself
is supposed
to be used for constants
even though final could do that, static is supposed to be used for constant variables
that will not change constantly
regardless final or not
That is the proper use and when you should use it
its a variable that can not be re-assigned, so it must be set either in the declaration or in the constructor
Β―\_(γ)_/Β―
I am referring to properly using static correctly...
ok idk how to explain to this kid
@granite stirrup do you know how i could rephrase this
lmao
Why are u guys fighting about static lmao
Because he is using it incorrectly
I disagree. You are being cocky. There is a difference between static and static final for a reason.
Yes there is. But static itself should really only be used for constant variables
I am not trying to be cocky here, I am trying to tell you why you shouldnt use it here
then what would be the point of static and static final being two distinct concepts if they should only ever serve the same function?
Because sometimes you define it later but never change it, and not directly in the static block
static variables should remain constant
there is a reason why if you look at the bytecode for enums
its the exact same as public static final, it remains constant
you cant modify an enum class at runtime, right?
Therefore, this is why enums use static. It's because they are constant
@quaint mantle help me out here
lmao
reeeeeeeeeeee
Example for a non final one would be the server instance stored in Bukkit.
Pls
that doesn't imply anything about static, it implies something about public static final which is a separate concept from just static or public static. Plus, sticking to this concept provides no benefits and makes using utility classes harder to work with
tldr me
Uh yes it does
okay explain to me this:
You have a utility class which provides many static functions. Say one of them is used often with same parameters and takes a long time to compute, so you want to cache the last result. How do you do this without using mutable static fields?
but it isnt a utility class
it should be a manager class
and you arent even caching at all
what is your definition of a utility class
so idk what you are saying
yo, hows everyone doing
its an example for why mutable static fields are useful
Neither should a utility class maintain a cache π
maybe we have different concepts of utility classes
no there isnt different concepts, you are just simply in-denial and need to change
Utility classed should (imo) be purely functional and have no side effects
I wouldn't personally consider a cache as a side-effect as it is purely internal
???
but I see what you mean by no side effects
that makes sense, utility is used to calculate stuff while a manager manages (therefore should have side effects)
"There is no good reason to have a mutable object as the public (by default), static member of an interface. Such variables should be moved into classes and their visibility lowered.
Similarly, mutable static members of classes and enumerations which are accessed directly, rather than through getters and setters, should be protected to the degree possible. That can be done by reducing visibility or making the field final if appropriate.
Note that making a mutable field, such as an array, final will keep the variable from being reassigned, but doing so has no effect on the mutability of the internal state of the array (i.e. it doesn't accomplish the goal)."
If you wanna cache some results do so in a designated class
it's a side effect of the function but not a side-effect of the class. If I had a program which needed to retrieve images, I would have an ImageUtils class which would have a function that retrieves an image from a path and a cache (HashMap in this case) to store previous results. In my eyes, the image retrieval function modifying the cache is not a side effect of the class but just a side effect of the function, so it's contained enough to be valid for a utility class.
Your top two paragraphs strengthen my point and the bottom paragraph we have agreed on already
Mostly it boils down to the reasoning of "does it make sense for this to be static?", things like data managers and carriers (google DAO & DTO) are instance specific. It kinda defeats the whole purpose of OOP if you have a static "StorageProvider" with a single storage system, that will not turn out very well when you decide to allow for other methods, e.g you primarily allow for something like json only, then expand to sql, then mongo, then all of them with a mix & match for certain parts of the system (e.g. you store logs in sql but user data in mongo), that's gonna get messy fast from a design perspective, 100% resolvable with abstraction and using static in a mutable element like that completely defeats the purpose of OOP
https://stackoverflow.com/a/2671636/8083725
Utility classes and functions are at the end of the day "convenience methods", "shortcuts", they don't handle anything in particular that is going to affect the rest of the system, they are a shortcut to something you provide
@quaint mantle for context, here is my use of static
What?
did you even read it properly?
Such variables should be moved into classes and their visibility lowered.
yes
say I started with an interface
I then move my field to a class (VanillaUtils)
and I lower the visibility (private)
now I am at the point I originally posted
Wait tickTime doesn't even need to be static lmao
same for the 2nd paragraph, it is indeed private and accessed through getters and setters π
I never make an instance of VanillaUtils so thats why it is static
when they mean "move to a class", they mean towards an actual instance, not classfield level
if they wanted it to be moved to an instance, they would specify to remove the static keyword
you should, it's specific to your plugin startup
Then make a instance of it ;-;
"There is no good reason to have a mutable object as the public (by default), static member of an interface"
i beleive interface in this context is referring to the class
like interface of a program
this class is not, but true I should do it for ProjectileManager so ty
the class isn't (you made it static.. ) but the tick time is
what is the crash log?
I think he means when you actually create the circle object
like new Circle()
that part of the code
for (int n = 1; i < partic + 1; n++) { You never change teh value of i
infinite loop
Coding is fun :)
i agree
Lmao
true, that's a good point.. You made me realise there would be problems with this approach even if it used server's time since restarting the server would reset the time to zero
and then time comparisons would break since I'm using the time for a cooldown
doesnt /reload reload the static fields?
mmm classloaders :^)
If you're working with cooldowns and want it to be time based instead of tick based I strongly suggest you use Instants
what is InstantS?
Or a plain ol' long gotten from System.currentTimeMillis()
50 milliseconds is one mc tick
I prefer it to be tick based as all other game logic is also tick based
ideally
ah I see
till lag kicks in lol
- instants have a lot of methods if you want to do math with them pretty easily, get a
Duration(which also has lots of nice methods) etc
dont change item nbt every tick
please no
just dont
thats a horrible solution
that would be very inefficient
my initial solution would only change NBT when you shoot and the new one would decrease a counter when you hold a weapon that's going through a cooldown but I see thats not a good idea
solution to what?
I need a cooldown for an item
use a hashmap
if tick based proves too inefficient then I'll go with this
and runnable
hm now that I think of it, I'm gonna need a hashmap + runnable combo anyway for automatic weapons so could squeeze that in there too
you shouldn't have a decreasing counter/latch
wdym
Can somebody give me an json example of bungee's click and hover event?
question - if the player moves an item in their inventory or drops it to the ground, does the ItemStack reference become invalid?
you should store the start time and then check
if (now - start > cooldown) {
// cooldown's over
} else {
// cooldown is still in effect
}
tick based sounds suitable still
yeah that was my original idea
probably, itemstacks are copied and cloned left right and center
but say I shoot on tick 1000 and then restart the server
that will cause problems
maybe initialising the tick counter as current unix time / 20 could do the trick
and store it as a long
worried that a player could just move an item quickly to cancel its cooldown
say offhand hotkey
so I'd have to track the stack with events which is a PITA
gonna have a hashmap for players to figure out if they're holding down the mouse or not, cause the item use event is only received every 4+ ticks
Thanks
Create your own :)
Btw, if I want to send a kind of this message with bukkit's sendMessage, is this possible?```json
{"text":"Test","bold":true,"italic":true,"underlined":true,"strikethrough":true,"obfuscated":true,"clickEvent":{"action":"open_url","value":"test.com"},"hoverEvent":{"action":"show_item","contents":"cake"}}
So I have to fill something in at text?
mhm mhm
Ok, and can I pass this to bukkit's Player#sendMessage ?
I don't think so, you can turn that into a BaseComponent[] with the ComponentSerializer and then send it
Ok
Because what I am trying is I want to create my own TextComponent class, but I don't know how to send the json to bukkit
Because what I am trying is I want to create my own TextComponent class
why tho?
Then I can control it
Ok, but I want to see if it's possible
Uh sure..
In case you are not aware, Spigot includes the bungee chat api
I don't think Bukkit supports json components
hm?
Yes I try
what?
you've waited a whole minute, have some patience
not everyone is here every single second of their lives to help
Hello emoily
hello Conclure's dog
does this type of documentation have a name and a list of all the @ that you can have
?
javadocs
lol
hi can you help me to know how to get, add or remove a tag from an entity?
wdym?
like I need to add an nbt in a villager (with the Tags list) to open a gui
(in 1.8)
you want to change an NBT tag right?
yes
thx
np
with?
send it
package test.Procupune.helloworld;
public class Main extends JavaPlugin {
}
i cant send image
you want to do what???
what exactly do you want to accomplish?
You have no imports so your project is probably setup wrong and it will not know what JavaPlugin is.
we need to know whats wrong though to help XD
you can;t type the same message twice or the bot removes it
im in the website
What IDE are you using? Eclipse or InteliJ?
Ecilpse
well swap to Intellij to start
Don;t,. ignore anyone who tells you to swop
It comes to personal preference, use what you will
Anyone who blankly tells you to change IDE with no valid reason is a fool. Ignore them
^
If at some point you dislike the IDE you choose, then change. Or change if you find an IDE you prefer better
InteliJ has shit that HIDES bad programming practices for a beginner
I'd say InteliJ is better for people who already know how to write plugins. Having everything done for you behind the scenes is not good for learning.
i will still use Eclipse
Good. Follow that tutorial I showed you. It explains every step of making a plugin
[15:58:04] [Spigot Watchdog Thread/ERROR]: Current Thread: Server thread
[15:58:04] [Spigot Watchdog Thread/ERROR]: PID: 15 | Suspended: false | Native: true | State: RUNNABLE
[15:58:04] [Spigot Watchdog Thread/ERROR]: Stack:
[15:58:04] [Spigot Watchdog Thread/ERROR]: java.net.SocketInputStream.socketRead0(Native Method)
[15:58:04] [Spigot Watchdog Thread/ERROR]: java.net.SocketInputStream.socketRead(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: java.net.SocketInputStream.read(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: java.net.SocketInputStream.read(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.security.ssl.InputRecord.readFully(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.security.ssl.InputRecord.readV3Record(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.security.ssl.InputRecord.read(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
[15:58:04] [Spigot Watchdog Thread/ERROR]: sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
please help me
?paste
so many issues, but you seem to be in teh wrong channel. You need #help-server
Sorry, was in a Tetris game so couldnt respond, but Intellij diffidently has wayy more built in features to help with development. Also, hes new and seems to want to code Minecraft plugins (he could just use the Minecraft Development Kit and it will set most everything up for him). Also, Intellij will tell you when you are fucking up and when you are writing useless code better than Eclipse will. On top of that, on Intellij will better predict what you want to write next and have better auto completions for you. Thats why I think as a beginner he should 100% start on Intellij.
https://paste.md-5.net/uqonufeqez.cs why i gett this error
You have some points, but I wasn;t trying to be rude, however, shortcut features will not make him a good programmer. Especially using the InteliJ MC plugin.
As for auto prediction, if you give that to a beginner its all they will ever use and learn almost nothing from it.
Its better to program in NP++ than to have things automated for a beginner
Idk, i mean when I started I attempted to use Eclipse and honestly it made me feel like giving up because it was so confusion, Intellij helped a lot.
let me take a look
which line is 41?
I remember when you came in and started with questions. You were not a total beginner.
i started like 9months ago or so probably
Yep
honestly, at this point i dont really get stuck anymore
so i just try to help other people XD
I saw that you cannot access APIs from an asynch task. What exactly does that mean? Iβd like to save log files every time the the server itself saves, which I tried using a world save event for, but is that allowed?
Basically you are not supposed to access Bukkit methods in an async task, just use a normal task
You can generally read data fine Async, you can not write. ALL file access shoudl be Async if you can.
Even reading is a bit concerning from time to time
Tho FIO (actually, IO in general) should be async here
Yeah, Iβm not worried about IO, Iβm more concerned about whether I can run an async task from within a world save or I should schedule it independently
I didn't coded it
@EventHandler
public void weather(WeatherChangeEvent e){
e.getWorld().setStorm(false);
}``` This will keep the weather clear right
just cancel the event?
Yeah but then if it's raining before the plugin is loaded :smug
oh no nitro emotes
@EventHandler
public void weather(WeatherChangeEvent e) {
if (e.toWeatherState()) {
e.setCancelled(true);
}
}```
should do the trick
Does anyone have or know of or can tell me a way of making + registering custom Entities
As in a custom mob
you can spawn entities if thats what ya mean
I would like to be able to make a custom Mob, and be able to register it with NMS so that it would appear with, for example, /summon
I don't believe you can modify the list of entities used in summon, I'm not sure if it uses the enum name or not
you could intercept the summon command in the pre event
I believe you can if you register them correctly
However, is there like a resource for making custom entities, i cannot really find an up-to-date one
mythicmobs not suit you?
Anyone know why I would be getting an "Invalid Book Tag" error whenever I open up this book? I'm trying to make clickable text. I've pretty much copied the code from the guide that's straight from spigot. https://www.spigotmc.org/wiki/interactive-books/
Here's my method:
private void writeInGrimmoire(PlayerData playerData, ItemStack grimmoire){
BookMeta bookMeta = (BookMeta) grimmoire.getItemMeta();
BaseComponent[] page = new ComponentBuilder("Click me")
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://spigotmc.org"))
.create();
bookMeta.spigot().addPage(page);
//set the title and author of this book
bookMeta.setTitle("Interactive Book");
bookMeta.setAuthor("gigosaurus");
grimmoire.setItemMeta(bookMeta);
}
Someone know if a big quantity of mob spawner in a chunk with a lot of meta data for each can generate lag ? (arround 120)
there is no entity inside it but i got more than 50k entity on my screen for any reason (don't know if player head is like an entity but there is not a lot)
could you show the full error?
how can i get the persistentDataContainer of a block that's already placed down? Someone said me it's possible
that's the full error, there's no stacktrace
it just says what they put in the book
ohh
since this video that i found on google exists, probably you can https://www.youtube.com/watch?v=oy7R-v7H17w
Time to learn Persistent Data Containers! This tutorial goes over a very basic persistent data container that holds the owner of a chest and does not allow other users to open the chest. I hope this tutorial helps you all understand PDC. More to come about Persistent Data Containers, but I figured since this in my first tutorial about it we shou...
i have a github repository and i want to edit it live with intelliJ is it possible and if so how would i do it?
live?
i just wanna be able to make changes and have them uploaded on github
not necessarily live
@outer crane
Yea, there is no error. It quite literally just says this
are you using 1.16.5
hmm how do i add a new string to an existing yml sector?
config.add is not a thing
does this work?
if(event.getBlock().getType() instanceof Container && event.getBlock().getType() instanceof Lockable)
?
it says that it's always true
use instanceof on the block not the material type
how is that not giving you a straight up error
1.16.4
well i have this now
if(!(block.getState() instanceof Lockable && block.getState() instanceof TileState && block.getState() instanceof InventoryHolder
)) {
return;
}
...
ow Block block = event.getBlock();
checking tilestate twice?
what's the grimmoire itemstack?
ymlfile.get().add is not valid either
is there a way to add a new string to a exiting yml sector?
It's a written book with lore and display name changes
also did some stuff with pdc
I've gotten the text to show up before
but every time i try to do stuff with clickable text it breaks
For example, this code works:
private void writeInGrimmoire(ItemStack grimmoire){
BookMeta bookMeta = (BookMeta) grimmoire.getItemMeta();
bookMeta.setTitle("Blank");
bookMeta.setAuthor("Destiny");
String firstPage = "";
String firstPageHeader = StringUtils.colorString(config.getDisplayNameColor() + getCenteredHeader());
firstPage += firstPageHeader;
//20 characters wide
String underHeader = "&0-------------------\n";
firstPage += underHeader;
BlackCloverPlugin plugin = (BlackCloverPlugin) CoreLib.getInstance();
String plusSign = "&2[+]&0";
String manaLine = plusSign + " " + plugin.getMaxRegen(getTier()) + " Mana\n";
firstPage += manaLine;
// The spells
for(SpellWrapper spell : spells.values()){
String spellName = org.apache.commons.lang.StringUtils.capitalize(spell.toString().replace("_", " ").toLowerCase());
String spellLine;
boolean isUlt = spell.getKEY().isUltimate();
if(isUlt){
spellLine = "\n" + plusSign + " Ultimate: " + spellName + "\n";
}else{
spellLine = plusSign + " Spell: " + spellName + "\n";
}
firstPage += spellLine;
}
firstPage = StringUtils.colorString(firstPage);
bookMeta.addPage(firstPage);
grimmoire.setItemMeta(bookMeta);
}
config#set
but it removes the older info
@digital plinth so ig you want to like update it right?
It would remove comments
but it shouldnt reset the whole file
okie lemme test it
you could do something like
String valueFromConfigToEdit = getConfig().getString("valueToBeEdited");
valueFromConfigToEdit = valueFromConfigToEdit + "abc";
getConfig().set("valueToBeEdited", valueFromConfigToEdit);
@digital plinth ^ That is exactly what you would do (but just make sure you save it after ofc)
it will work just fine
but all comments will clear
yeah, the version of snakeyaml spigot uses, like all things spigot uses, is like half a decade out of date
so it'll nuke all comments if you save anything in any way other than with saveDefaultConfig
playerHandle.e(((CraftBlock) player.getLocation().getBlock()).getPosition())
val pose = DataWatcher.a(Entity.class, DataWatcherRegistry.s)
val data = DataWatcher(playerHandle)
data.register(pose, EntityPose.SLEEPING)
playerHandle.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(playerHandle.getId(), data, false))
Trying to make the player appear to be sleeping, any ideas why this doesn't work? Right now it just makes the screen fade for a few ticks then goes back to normal
does List support null elements
depends on the List impl
generally yes
there are some like linked blocking queues or something that don't but most standard impls do
thx
yw
lmao
i dont think so
will matchMaterial return null if it doesnt know the item?
declaration: package: org.bukkit, enum: Material
thats just about material
hey, i made a custom spectator mode and i am struggling to cancel sounds that are coming out of the players in that mode
i have tried cancelling the packets using ProtocolLib but it says the Named Sound Effect packet is ready-only and shall not be cancelled
any ideas?
how can I get the first player inside a boat (the boat operator)? I have the boat entity e
Entity#getPassengers returns a list of the passengers so you can get the first passenger from there
Where are the docs for this?
i can have a look
?jd
package index
oh protocollib docs sry
nope this is original https://ci.dmulloy2.net/job/ProtocolLib/javadoc/
Idk why you day it cannot be cancelled
i have looked at the docs too and it's weird
because the error says that the packet is read only
Can i see the error?
And the code please
hmm
i mean, the error does kinda tell you the issue
You may need to send a packet to stop the sound, instead of cancelling it
alright let me try that
can i clone a stream somehow? if i try to do multiple operations on the same one, it tells me it's already closed
anyone up for a challenge?
no
depends
23 - 0
22 - 1
21 - 2
20 - 3
19 - 4
18 - 5
17 - 6
16 - 7
15 - 8
14 - 9
13 - 10
12 - 11
i have these numbers but every 6th element i want to start fom zero (transform the numbers to start from 0 again)
is it possible to do this with some kind of math logic and without if statements
can't believe i missed that, thanks lol
for example
17 - 0
16 - 1
15 - 2
14 - 3
13 - 4
12 - 5
i can do this with for loop and incrementing the i by 6 to tget this result, but im thinking a way to do this algebraic.
How are you inputting numbers in / when are you getting info @mortal hare
the sending message is bcz you have there player.sendMessage
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.bukkit.Material (java.lang.String is in module java.base of loader 'bootstrap'; org.bukkit.Material is in unnamed module of loader 'app')
π¦
from what i understood, youre trying to make string a material for it you need to do Material.valueOf(stringValue)
a
Stream.of(Material.values())
.filter(Material::isBlock)
.collect(Collectors.toSet());``` π
no idea if anyone has tried this but I'm trying to put a spring boot application into a bungeecord plugin and it keeps removing the bungee.yml when i package the jar how do i stop this?
or do this java Set<Material> blocks = new HashSet<>(); for (Material material : Material.values()) { if (!material.isBlock()) continue; blocks.add(material); }
enumsetreee
why would you use the name
that is literally the worst performing way of possibly doing it
you do not need order
you do not need duplicate elements
therefore you do not need a list
what a way to remove something in https://paste.md-5.net/uvaqijohod.bash like if i want to remove location.1.loots.1.items.2 i would normally take the data from the next one until i reach the last one and then delete that one, but is there a better way?
EnumSet.of(Material.STONE, Stream.of(Material.values())
.filter(Material::isBlock)
.collect(Collectors.toList()).toArray(new Material[0]));``` here
like rename locations.1.loots.1.items.X
those are all maps
no actual lists are involved anywhere there
i'm not sure what your question is
just take the value you have at path a and set it to path b
but i need to remove and rename the section
move the last section in the place of the section you removed
or does the order matter
it does
if the order matters you need to shift all of them
set 2 to 3, set 3 to 4, set 4 to null
aside from actually using list types, not really
but if the order doesnt matter
i could replace the last one
with the one im removing
no
the one im removing
with the last one
yes
ideally you would use a list but map lists look kind of cancer in yaml and most end users don't know wtf to do with them
and the whole serialization thing with lists is kind of shit tier
using lists and leveraging on serialization would look like this
locations:
- world: world
X: -331
Y: 107
Z: 153
spawned: false
unlocked: false
clicked: false
timeleft: 0
loots:
- ==: com.mydomain.myplugin.MyLootClass
items:
- ==: org.bukkit.inventory.ItemStack
type: QUARTZ_BLOCK
- ==: org.bukkit.inventory.ItemStack
type: CHEST
- ==: org.bukkit.inventory.ItemStack
type: WOOL
damage: 14
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: Β§rΒ§6Β§lSuper Wool
lore:
- Β§rΒ§rthis is a test
- Β§rthis is another test!!
enchants:
LURE: 0
ItemFlags:
- HIDE_ENCHANTS
- ==: com.mydomain.myplugin.MyLootClass
items:
- ==: org.bukkit.inventory.ItemStack
type: IRON_ORE
not exactly legible
do u guys know why when i do /reload confirm my memory usage goes up
because it leaks a ton of shit
lmao
there's a reason why using reload isn't recommended
like, aside from all of the shit that just generally blows up
uh then how do i reload my plugin to work on it ;-;
no it doesn't
cant it takes like 5 mins
though you will want to first unload the plugin
then switch the jar
and then load the plugin back in
what server jar you using if it takes ages to restart?
switching the jar on the fly can cause issues
but when i do /reload confirm it works
i dont have to unload the jar
and i tried that in plugman didnt work
well, idk what you're doing, but it does
i use plugman everyday for reloading my plugins on my test serbur
nah i did unload the plugin put new one in then load it again
and its the same
;-;
not the new jar
and how are you determining whether it updated or not
i tweak shit to test
i dont have plugman ;-; rn
plugman might also not be the best
it's kind of shit
i know red the txt man has a plugin manager but idk how good it is
i did see a version of plugman that was like a community made one i think
to do the serialization/list based approach above, you would make your MyLootClass implement ConfigurationSerializable, and then set things to List<MyLootClass>
or not idk
you'd then have to getList from the config, and cast the List to List<MyLootClass>
which is gay
but also the best you're going to get with the bukkit config api
without making a dedicated MyLootList class
plugwomen is better I think
It's not even bad?
but, regardless of the plugin manager plugin you use or whether you use /reload or a plugin manager
you don't want to switch the jars on the fly
not all of the plugin's classes are loaded from the jar into memory at startup
if your onDisable or whatever causes new classes from your jar to be initialized after you've swapped the jar, your server could hard crash
as in total and complete fucking instant death where the JVM explodes
neither it's guaranteed all references to classes are discarded everywhere
that's where the jvm gets dumb
jfc what a nightmare
on bukkit's end, the classloader is dropped
dont use plugman
why
but if anything refers to any of the classes from that classloader, the classloader will still be strongly referenced
Plugman doesn't reload well, but we don't either...
plugman likes to break things lol
yea
which will keep all of the classes belonging to it also in memory
which will keep all static fields and shit in memory
it's like jumping into or jumping out of a moving car
plugman does not "very often fail to reload even the simplest of plugins"
but i dont want to have to restart the server every time
literally never seen it fail to reload a simple plugin
only things it has issues with are plugins with dependencies
I wasn't saying it's perfect they were not wanting to restart the server every time so might as well use the better of the two.
Yup. ^
And isn't it a sign of a good plugin that is able to handle things like reloads?
my server takes like ages to start so i dont want to have to restart
even the ones with dependencies
its not even the plugins its mostly the worlds
it just takes forever
to load
1 world
a plugin shouldn't need a dependency manager to reload all of its dependents/dependencies
the plugin should be able to handle that itself
all of my plugins are reloadable too but its generally bad practice
even tho i do it myself
I mean, some plugins will expect that the server is empty when it is loaded, but that is rare
Should be like a usb that extends the servers functionality
viaversion is even reloadable but it can still break lmao
f.e if you're hooking to worldguard, instead of registering a new flag and exploding because the registry is closed, you should try to obtain your already-registered flag
oh i have a reference to my onJoin on a player loop in my onEnable
you don't need to reload worldguard to reload your plugin
which would be the naive assumption made by a plugin manager
I have many of these fields static final and won't change that
likewise, if you absolutely depend on a plugin, you should listen to plugin unloads and disable yourself when that plugin disables
my only dependency so far has been vault
i have a plugin that depends on towny, worldguard and slimefun and it's still reloadable
which is something of a fucking miracle if you ask me
my plugins depend on ColorLib
but that should be a library and shaded in
oh so do i
the number of "x API" and "x Lib" plugins that are actual plugins with plugin.ymls is insane
Wait, what is ColorLib?
where they could just as well be libraries
Does it free me from my 1k line Monolith full of switch statements?
colorlib has a plugin.yml
but thats mainly because it can be ran as a plugin to test
tho i should probably make it output a test jar for that
somewhat dubious but as long as it doesn't need to be loaded separately as its own plugin to be used, it should be fine
@quiet ice 1k line monolith of switch statements?
nah it doesnt
holy shit geol
why aren't you just like
yea 1k lines xd
colorlib only handles text colors
so you can use 1.16's RGB colors without breaking 1.15 and older
I would have tried, but there is no better way (at least back when I made it)
like, iterate over all materials with a color name in their name
if (toString.contains("RED"))
and based on the remaining parts of the name, add them to separate maps
yeah
f.e GREEN_CONCRETE would be of type _CONCRETE and of color GREEN
then populate an EnumMap<Material, EnumMap<Color, Material>> with them so you can do lookups from material -> group -> other color in that group
Well, that is a better idea I guess
the only issue is that you will get weird partial groups if some materials contain color names but aren't actually colorable
like uh
red rose or whatever
declaration: package: org.bukkit, enum: Material
yeah
but, imo that is still more manageable than this
you could still hardcode an enum of colorable types like you're doing right now
and that'd solve it
but then it wouldn't be completely dynamic
how would i make something like this?
lets say i have a list of objects, and a player can have multiple objects related to it, how would i set like this?
I would need to refractor that class either way given that It will be a pain to update
f.e a ColorGroup enum with a constant called BANNER with a constructor of (Material.RED_BANNER)
String ver = a.substring(a.lastIndexOf('.') + 1);``` wait is there a better way to get the server version? this is all i could find XD
You can have a List of yml sections.
the ctor would then find the associated colors
like what you mean?
Why does the if statement return even if I'm looking at one of those blocks?
Block b = player.getTargetBlock(null, 5);
if (!(b.getType() == Material.DAMAGED_ANVIL) || !(b.getType() == Material.CHIPPED_ANVIL)) return;
But that plugin doesn't acknowledge the existence of 1.13+ food types, so I could declare that a feature
users:
uuid:
locations:
- location1
- location2
- location3
If you do not know it, try to simplify it by breaking it down in multiple if statements
Do you want to read stuff writte by a user or do you just care about persisetence?
i just need to save each 5min and load when plugin enables
Bukkit.getVersion() i think
oppure getServer().getVersion()
idk
why do you have two DAMAGED anvil checks in the first place?
Then you should probably just make your whole class ConfigurationSerializable
Spigot automatically deals with collections of other ConfigurationSerializables like
List<ItemStack>
u sure those are things cuz rn i haveString a = Bukkit.getServer().getClass().getPackage().getName(); String ver = a.substring(a.lastIndexOf('.') + 1); it works fine but idk if its the best way
i just found it on some forum post XD
You should probably use the API when possible. So getServer().getVersion() and then parse that
yeah but i didnt know if there was a thing in to get the version
made a typo, it's CHIPPED_ANVIL in the second one
ah if im gonna use that im gonna have to pass in the main class oof cuz its not in the main class XD
i-((i/6)*6) would repeat the range
because i/6 is integer based divide and it will drop the decimal point value
Then
if (b.getType() != Material.DAMAGED_ANVIL) || b.getType() != Material.CHIPPED_ANVIL)
return;
See the issue?
a block can't be both a damaged and a chipped anvil at the same time
one of those conditions will always be true
if it's a chipped anvil, it's != damaged anvil
if it's a damaged anvil, it's != chipped anvil
yup, thank you!
In brief, always simplify your if statements to the bare minimum, otherwise you will get confusions
feel free to play around
just lmk if you find anything dumb in terms of use lol
does anyone know what &id003 in https://paste.md-5.net/ayocejubok.bash could be?
current code:
Main.get().getConfig().set("locations." + locID + ".loots." + lootID, Main.get().getConfig().get("locations." + locID + ".loots." + totalLoots));
Main.get().getConfig().set("locations." + locID + ".looots." + totalLoots, null);
Main.get().saveConfig();```
What is the difference between setBoots() and setItem(int, item) ?
One sets the slot in the boots slot the other sets an item in any slot
Repeated nodes are initially denoted by an ampersand ( & ) and thereafter referenced with an asterisk ( * ).
I mean if the setItem slot is the same as the boots slot
none
but setBoots is more verbose, so unless you need to dynamically switch which equipment slot you are setting, use setBoots
and for dynamically choosing the slot you might want to use the equipment slot enum
pathetic, i have a keyboard which's cable has been eaten by my dog, yet im still using it without insulation lol π
you should give your dog some 250v cables to chew
Also that keyboard costed like 10$
He ate my earphones too π
these were good bass earphones
sadly
this
shitty
monster chewed them
if my dog eats my keyboard that all im gonna feed him with from now on
plus my keyboard from time to time does this little double press like instead of typing "hello there" it types "hello there"
if i would shoot a picture of my setup you'll be laughing how the keyboard is still alive.
If the house burns down in the next few days we will know why
sounds like worn out butterfly switches
I do such things with my phone charger
maybe and just maybe, a new keyboard could help
It's impossible to connect that thing properly
yall dont get tilted by that
i've never gotten any charging problems with cables after switching to usb c
everytime i have to put my charger or any cable "in an angle for it to work", then thats the last time im using it
phones should just use standard usb a jacks
it's not like you can't fit one of them on the thing
lol
what's the difference between USB A and C?
a is the one you plug to your pc
c is the tiny fucking little shit that breaks it you look at it wrong
you could totally fit a usb a jack on most mobile phones, it'd just involve shifting some components around
like phones now days , i used to have " a brick ", one of those old nokia phones, i swear i put a pencil across it was just fine
but no everything needs to be tiny and slim and delicate and fragile
just like the people
oh
yea
i think i broke my plugin π
it errored to disable my plugin and errored to enable it XD
i suppose you could do that but that'd be pretty confusing
you'd have 2 of 3.5mm jacks and you wouldn't know which one is for the headset and which one is for charging
usb is good because it's already been standardized
issue just is that all of the smaller models are super fragile
USB C is a big improvement compared to Micro USB
tbh the round plugs used back in the day were very good
in terms of durability
that shitty Micro USB is such pain in the ass compared to USB C
C is still pretty shit
it's gonna break if you look at it wrong
A is like a heavyweight champion compared to it
so if I open a custom inventory with player.openInventory how can I detect when that's closed? do I need to use the InventoryCloseEvent and compare if the inventory is the one I opened?
that is the simplest way yes
ok I'll just do that
I just dislike the idea of technically having to check on every single inventory close
i suppose
but, that's what you will be doing with event buses designed like bukkit's
all events are global
bruh plugman fucked up my plugin i think XD
there are no events you can subscribe to in a particular context
you just listen to all of the globally happening events and check if the context matches
that is, you can't listen to InventoryCloseEvent in the context of a specific inventory
you'll have to listen to them all and check whether the context is the one you want
as is using legacy chat to paper
well, paper's reason for that is that they don't want to support the old shit
which is their problem
it's not an issue with your project
i don't remember for what reason you shouldn't use the inventoryholder for detecting the inventory though
so it could be a valid reason
but, people do it anyway so probably not
do whatever
who canb call me and completely spoonfeed me the dictionary of mysql skills
officially stated somewhere that implementing classes not specifically designed for implementation is not supported
i vaguely remember someone saying something about its persistence not being guaranteed or something
but seeing as it works just fine and people do it anyway, that's probably a hypothetical
if it didnt work people wouldnt use it π
hey @warm galleon you're and completely spoonfeed me the dictionary of mysql skills
?
you asked me to call you and completely spoonfeed me the dictionary of mysql skills
watch codedreds youtube video on mysql @warm galleon
i am
top-tier
is it possible to reorder the args in onTabComplete?
I don't want them alphabetically
they're sorted by the client i'm pretty sure
i don't think they are
They're not. They're sorted by whichever strings are put in the list first.
based on the question i'd think they are but tbh i haven't tested
what if you put some invisible colors in front
like Β§gOwner
Β§hAdmin
etc
Β―_(γ)_/Β―
can some1 reccomend me a series of tutorials or tutorial that will help me get going on coding plugins, I found some yt ones but others have said they have problems
the only one i've found so far is outdated
youtube guides are generally cancer
π
What is your chosen IDE?
intellij but that shouldn't matter right?
it matters for the tutorial
I only see blank plugins tut