#help-development
1 messages · Page 541 of 1
?paste
https://paste.md-5.net/eborilimal.cs any idea why when the amount is around 1,000,000 it doesnt give the right amount of money?
link?
What exactly is the issue with this?
As long as you check if it is inside the inventory you want it to be, this shouldn't cause issues?
Items can be renamed and they're not checking it's their inventory
Same goes for checking inventory names
how you can to detect if the name of anvil custom are the same que “anvil custom” ? because I can to see if player are in custom anvil.
Compare instance not name. NEVER compare by name
I can dectect if the name is equal
i want dectect the instance because i want to have the name of item rename in the custom anvil
Do not compare names!
@EventHandler()
public static void onClick(InventoryClickEvent event){
Player player = (Player) event.getWhoClicked();
ItemStack current = event.getCurrentItem();
Inventory clickedInventory = event.getClickedInventory();
if (clickedInventory instanceof AnvilInventory) {
AnvilInventory anvilInventory = (AnvilInventory) clickedInventory;
player.sendMessage("name : " + anvilInventory.getRenameText());
}
}
Player gets an anvil, renames it to match yours. Now your code will see their anvil as your custom one.
this is my code for create custom anvil
Inventory anvil = Bukkit.createInventory(player, InventoryType.ANVIL, "anvil");
ItemStack paper = new ItemStack(Material.PAPER);
ItemMeta paper_meta = paper.getItemMeta();
paper_meta.setDisplayName("a");
paper.setItemMeta(paper_meta);
anvil.setItem(0, paper);
player.openInventory(anvil);
very exploitable
More advanced version is packets
because my code work in anvil but no in my custom anvil
So how I can to dectect the instance
if (clickedInventory == anvil)
== is an instance check
checks it's the same object in memory
You need to keep an instance of your custom inventory somewhere to compare to
If its just an empty inventory then you can just create it on the fly and make a copy of it for the player
like this
static String anvilName = " ";
ItemStack nameanvil = (ItemStack) anvil;
anvilName = nameanvil.getItemMeta().getDisplayName();
player.sendMessage("name : " + anvilName);
AnvilInventory anvil = Bukkit.createInventory(null, InventoryType.ANVIL, "anvil");
@EventHandler()
public static void onClick(InventoryClickEvent event){
if (event.getClickedInventory() != anvil) return;```
anybody got any tips for protocollib "subfields"
it is the only thing i'm really struggling with and i have no idea how to
link to sc https://wiki.vg/Protocol#Update_Teams
in this example int is probably the mode
string is the team name
collection is probably the subfields
no idea what optional stands for
how would i build up the "subfields" within a list
The optional should be team color
Mode is the what is shown below in that list
Depending on the mode chosen. Which is the int for you dictates the rest
Typically protocollib keeps the order of the packet the same
how would i build that collection?
make a list with values?
You should be able to set the values of the mode from inside the method
i don't get it so if i set the mode? i change the mode with the values?
The idea is that one of the fields before indicates what comes next
You should be aware that you don't need packets for teams
I generally just look at the nms impl
for my usecase it does
and what is that use case
Because you can do per player teams with the api
each team looks different for every player
just let xceing learn packets
^^
Yeah you can do that with the api
probably not the right way to do it
and there's 9/10 times existing API for it
but I didn't learn how to mess with packets by using the API
Probably still good practice regardless
but i don't want to use api's man
Well they are there so you dont have to struggle like you are
You won't get as much help but like
But its fine, getting some practice with packets will benefit you
also being api dependent seems unreliable when versions change
it's the opposite
or the owner of the api's stop updating them
Spigot api doesnt change wildly lol
you'll have to rewrite all your packet logic the moment that minecraft updates lmao
but in general you seem to know enough about java and packets and all so I won't stop you
that's how I learned
I started with client-sided blocks and entities and eventually dove deeper
Also spigot api is part of the spigot server so not like its goin anywhere either
but if you use an api you need the wait till the owner updates it
the spigot api has a decent enough scoreboard api
we're not talking about a third-party
oh you're not?
no
If spigot doesnt release an api for new version odds are there isnt a spigot server version either
there goes my argument ig
you're still good to play with packets just don't expect people to be happy and willing to help
Yep as said good practice regardless. In the case of spigot you should only resort to nms and packets if the api isnt able to do something you need or want
or if the existing api is garbage
like for client-sided blocks
sendBlockChange is a disgrace lmao
Well minus some edge case scenarios of course lol
I think we should get a group of us devs and overhaul some code in the server
or we can just work on our own stuff instead
only way I'm touching spigot is if md personally pays me
I doubt there's that many devs here that have enough knowledge to confidently work on spigot
true but usually the people chilling in this channel are pretty proficient
There is actually quite a bit
I've been doing spigot for like 6ish years now, frosty probably more
I could but all my PR's would be rejected due to formatting 😛
Most of them just dont chat often but are actually active
lol probably
Not by much more. Think 4 years more
well
Spigot servers running from floppy disks
those 4 years were enough
and my 6 years are probably the equivalent of 3-4 real-world years because I was like 12
But then i have a lot of people beat in terms of working with java as well even if i didnt touch spigot
I started coding when I was 6, my brain cells were probably made of the sand I ate
I been working with java since 1999 and java was a thing starting in 1998 lmao
I only started when I was 16 o.o
frostalf still knows the shitty GC from the early java versions
You all should be happy with modern java and never got to experience 1.6 and below
i started in 2021 😭
late 2016 gang
I've heard a lot of "good" things about the GC back in the day - that it was pretty much entirely useless
And that it was pretty much unable to detect a lot of things that weren't in use anymore
Well when the purpose of it was to free up some memory and it does the opposite because of dumb mem leaks yeah
mem leaks are so fun
Manual nulling was the way from what I've heard
anyway thanks for the advise and info
caught a memory leak a couple days ago because I was adding a single row of transparent pixels every time I did an operation on an image
Its still recommended if you fancy micro ops
I still catch myself manually null now and then
I usually manually null on my dispose() methods
Well its proper form even if the language doesnt strictly require it
But the readability :(
Well it would make it more readable if anything
having a block of var = null; at the bottom of each function?
They are not always suppose to be at the bottom
Oh you meant to null asap
Its suppose to be done when you know you dont need it anymore
If its done like that it makes it clear when you have no use for the object very handy in large code blocks
I'd still feel like bloating my code with those statements and therefore I'd then reuse variables that therefore have bad names etc.
Well if you reuse the object obviously you werent done with it lol
well lets say you have a list and you iterate it and then you are basically done with it
a few statements later you need a list of the same type
Also on some circumstances nulling out sooner lets the gc work sooner too
then you could reuse that one but the name won't match
But it saves you an additional variable and two additional = nulls
That would surely be bad practice but it would kinda push me to do that
Lol its still not bad practice but borderline unnecessary unless you managed to structure your code in a way to invoke gc to your needs
As i said if you null out objects fast enough and have enough of them you can trigger the gc to run
Does it even have to run when the objects are null?
What does it do? Just free up the memory again since it's empty?
Also with manual nulling you can never use final - kotlin would lose one of its core features lol
Yes it has to run even if the objects are null. Null objects doesnt mean the object doesnt exist. It mainly means its just empty but still taking up memory
How is that achieved in languages without GC then?
or is the = null; "more powerful" there?
Null in other languages means you are absolutely done with it remove its pointer
This is pretty accurate
I see. So you can basically never assign null to a variable as it would delete the pointer?
or are there different types of null?
It depends in which language really
Well C and C++ for example
In c it means get rid of this, in c++ it keeps the pointer around because you might want that object still and that is why you have free methods or functions whose purpose is to get rid of objects that are null
There is objective c but its slightly different
What if I want to set null as a placeholder on a new variable in C?
Or isn't that of use there?
Like you would set a variable in java to null before running a try that sets its value. Or a loop.
Isn't that a thing in C?
You have what is called defaults or empty values
But c is more functional programming then it is object programming
Yeah you can't set null to variable which is not pointer
So that being the case typically you create your variables when you need them and they only stay as long as you need them
As null is basically defined as 0 in c and cpp
But yeah usage of null is more strict in c and cpp in that you dont use it unless you are done with that thing
I see. Thanks for the explanation
Java is more about keeping you safe and thus isnt as strict with it
C and cpp dont care about safety and you know you made a mistake because everything is hitting the fan without warning
I have the economy api installed, can someone give me a basic code on how I would give money to a player in an external class
Java isnt script and not entirely sure what you mean external class
like, not in the main one
any post on spigot on how to configure a bungeecord properly?
yes
Pay special attention to the final section on Post-Installation https://www.spigotmc.org/wiki/bungeecord-installation/
Just pass the instance of the economy with dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
thanks, appreciate it
yay
can i dm you to show you the problem i has in ss? becasue i cant upload images
?img
Not verified? Upload screenshots here: https://prnt.sc/
!verify
Usage: !verify <forums username>
This account is already verified!
That happens when the proxy client is not disconnected.
oh right
how i can transfer verified discord account to new one?
my old acc was disabled
I used /server lobby
being in the lobby
how i removing that text that i mark?
if(message.contains("[item]")) {
message = "<" + player.getDisplayName() + "> " + message;
String[] parts = message.split("\\[item\\]", -1);
BaseComponent[] messageComponents = new BaseComponent[0];
for (String part : parts) {
TextComponent textComponent = new TextComponent(part);
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (itemStack.getType() != Material.AIR) {
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta != null && itemMeta.hasDisplayName()) {
TextComponent itemComponent = new TextComponent(ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + itemStack.getAmount() + "x " + ChatColor.RESET + itemMeta.getDisplayName() + ChatColor.DARK_GRAY + "]" + ChatColor.RESET);
BaseComponent[] hoverTextComponents = getItemHoverTextComponents(itemStack);
itemComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverTextComponents));
messageComponents = TextComponentUtil.append(messageComponents, itemComponent);
}
}
messageComponents = TextComponentUtil.append(messageComponents, textComponent);
}
for(Player p : plugin.getServer().getOnlinePlayers()) {
p.spigot().sendMessage(ChatMessageType.CHAT, messageComponents);
}
event.setCancelled(true);
}
Is there a way to access ticked entities to perform actions on them randomly? e.g. to make goats regrow horns like sheep regrow wool - is there a less laggy way to do it than looping all players and all nearby entities?
anyone?
heya, I wanted to ask if there's a way to call a function like String.format(...) in an annotation. All values that are parsed in are constant values, I just want the method to format it more neatly.
Otherwise I'd need to do smth like: Class.someConstantStringValue + " " + Class.someConstantStringValue + " " + Class.someConstantStringValue
how i get Player Location with bungeeecord?
Bungee has no idea what a Location is
there is another way?
Send request to get from the backend server
From backend send location to bungee
From bungee receive
The value of String.format() isn't known at compile time, whereas a String literal is.
Since the annotations are metadata on the compiled class, their values must be known by the time the compiler generates the final .class file. Since String.format()'s value will only be known once the code is actually run, the compiler won't let you use it as part of an annotation.
i don't now
can you give me a example
Then is there a way of creating a string literal at compiletime while retaining the functionality of formatting it?
Since this would only be for convenience and is not needed during runtime.
why do you want the players location exposed to the bungee server?
i am creating a bungeecord plugin
Doesn't answer the question
Why do you need the players location in your bungee plugin?
Sadfully I don't think so :/
sadge
There is a reason for the location not being in bungee cord, you should rethink about what you're about to do
And but to serve me
Right. I think you're misunderstanding what a bungee plugin actually is. Bungee is the proxy. It has no knowledge of what actually happens on the world of a server. It's just a way for players to be sent from one server to another behind the same proxy.
If you want world information, you need to have some server plugin that sends it to the proxy. But at that point... just write a server plugin
If you're not sure, just explain what you want the plugin to do and we will help you
I want it to take the player position and put it in the config because I'm trying to create a ss.
What's a SS?
Create a what? 
Listen, man. 1940s Germany tried that and failed
How do you not know! is a plugin that is used to do hack checks.
Then it shouldn't definitely be on the proxy
Yeah, that's a server plugin
Yes, EnderSS type
we still have no idea what SS is
I also made a non-proxy version but everyone wants a proxy one
oh screen share
Why are you making a plugin which already exists and is open source?
All the functions are literally server side or am I missing smth ?
is a plugin that allows you to teleport a specific person to a certain place by putting his scoreboard and creating temp-ban commands etc
EnderSS is open source, just fork it and contribute
I know, let's do it like this I'll try it, force it and then at best I'll rewrite it
Fact is: you'll still have to do a server side plugin in anyways if you want to act on the player in world
I can't build the artifact there
I see it's not really a screen share, it's allowing an admin to take over teh players connection and operate as if they were logged in as that player
if (e.getAction() == Action.RIGHT_CLICK_AIR && item1.getType() == Material.IRON_HORSE_ARMOR && itemd1.getCustomModelData() == 1){
Block tblock = player.getTargetBlockExact(5, FluidCollisionMode.ALWAYS);
if (tblock != null && tblock.getType() == Material.WATER) {
itemd1.setCustomModelData(2);
world.playSound(block.getLocation(),Sound.ITEM_BUCKET_FILL_LAVA, SoundCategory.BLOCKS, 5,2);
world.playSound(block.getLocation(),Sound.ENTITY_SQUID_AMBIENT, SoundCategory.BLOCKS, 5,2);
item1.setItemMeta(itemd1);
Bukkit.broadcastMessage("test");
}
}``` i used this
still can't find anything
what can i click water
i try with item material.glass_bottle
vcs glassbottle have interact with water
but don't worked
is this for cauldron ?
declaration: package: org.bukkit.block.data, interface: Levelled
You're ignoring fluidblocks, so how can it return water block ? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/FluidCollisionMode.html
declaration: package: org.bukkit, enum: FluidCollisionMode
Some plugin for crates keys or /pv 1/2/3
i try with "ALWAYS"
I'm starting to create my server but I can't find good ones for the version to 1.19.2
Go #help-server
Tell me if it works
not worked
why are you now tryign target block and ignoring water?
teh code from yesterday was fine
yes was better than this
but only works if i click block in water
show that old code again, it shoudl work without a target
w8
if (item1.getType() == Material.IRON_HORSE_ARMOR && itemd1.getCustomModelData() == 1) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
List<Block> los = e.getPlayer().getLineOfSight(null, 5);
for (Block b : los) {
if (b.getType() == Material.WATER) {
Bukkit.broadcastMessage("test");
break;
}
}
}
}```
here
tried again
can i use this ?
does not see water as a block
one sec I'm going to test
Anything prefixed with LEGACY_ you should avoid
yes don;t use legacy, you have an api version set
wdym
can i use two version with api ?
i mean for to use stationary water
@EventHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
List<Block> los = event.getPlayer().getLineOfSight(null, 5);
for (Block b : los) {
Bukkit.broadcastMessage(b.getType().name());
}
}
}```
works just fine, detects water with no block targeted
is this not for cauldron ?
teh above code works just fine
but this code isnt works if water
Cauldrons are a different condition. You would need to check for water cauldrons
yes that was looking into deep water
And for waterloggable blocks, you'd have to check block data
oke i will try levelled
he is tryign to detect water block when looking into deep water, or he was yesterday unless something has changed
are you no longer trying to fill your watercan in deep water?
yes i try
So you ARE trying to fill your watercan just looking into deep water? Then that code from yesterday as I just posted works fine.
no only works for
wait i will give video again
this code can check if block water ?
THAT exact code I just posted, looking into deep water with no target block. It works
you on 1.19.4?
no 1.16.5
if i do this
my code do this without equals
I think the issue is that right clicking a non-block with horse armour doesn't actually call an event
sedc I'll check with horse armour
i tried with glass_bottle
I used a stick
Right but glass bottles actually have a right click action
works with horse armor
Then yeah. Unsure what the issue is
I'll test it on 1.16.5
have to buidl spigot, don;t have that version at teh moment
my code exactly as shown works using horse armor
My bet is your code is a spiders web and it's never reaching the correct test
no need
no thats the point
i was try
he's trying to click on NO block, just water
so he has no target block
there is no block
no theres not
when there is no targetable block in click range it's treated as a click on AIR
You just tested using my exact code and it detected water
that video is not using my exact code
my code detects water no matter if you have a target block or not.
add debug
very first line
i was think
Yeah was about to say
you are only allowing it in if you clicked a block
yes i was think omg
This is why context matters and we ask for whole snippets 
This is why you should post the code you are actually using, not code you think you are
also if (block != null) { you are only allowing the code to run if a block is clicked
alright i try to fix my code
i need create new player interact event for water
?
why?
no they both run
and so i don't need use loop for control water now ?
no?
what?
you have two functions for your object...
oke i try something
if it has water and you click on farmland, you set the land watered and empty the can.
if it doesn't have water you should see if you clicked looking at water and fill it.
also instead of nesting if statements you shoudl early exit
now i just change first line and add to action.right_click_air and fix all probems
and ignore if clicking a block later
bcs i got this warnings
u guys said don't but i wonder how can i fix this warnings ?
nullable
teh code to fill teh watercan needs to not care if a block was clicked. Watering land needs a block
yep like show @tawdry echo that method is annotated with Nullable then can return null.
@SuppressWarnings("ConstantConditions") if you sure it will never be null
if it may be null, add check
alright ty gys
for use player.swinghand
?
player.swingmainhand
player.swingoffhand
you only ever do checks on item2 but you allow that code to run if item2 is null
i has video
if (itemd1 !=null || itemd2 != null) {
see if horse armor in offhand
item2 could be null
my mainhand swinging
PlayerInteractEvent has the hand used to interact iirc
u mean e.getitem ?
No, e.getHand()
But yes, e.getItem() as well
ItemStack itemStack = event.getItem(); // Check this for the horse armour
if (event.getHand() == EquipmentSlot.HAND) {
player.swingMainHand();
} else {
player.swingOffHand();
}```
your code is such a mess, sorry. You do the same thing if your model data is 1 or 2
which is the empy can, 1 or 2?
1
so you can only water if its 2
t
u
Any AWS users here?
aws is amazon servers ?
@eternal oxide
@EventHandler
public void fillWateringCan(PlayerInteractEvent e) {
if (e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
ItemStack item = e.getItem();
if (item == null) return;
ItemMeta itemd = item.getItemMeta();
Block block = e.getClickedBlock();
if (block != null && itemd != null){
if (item.getType() == Material.IRON_HORSE_ARMOR && itemd.getCustomModelData() == 1 &&
block.getType() == Material.WATER){
World world = block.getWorld();
itemd.setCustomModelData(2);
world.playSound(block.getLocation(), Sound.ITEM_BUCKET_FILL_LAVA, 5, 2);
item.setItemMeta(itemd);
Bukkit.broadcastMessage("test");
}
}
}
}```
my syntax is good now ?
is <FileConfiguration>.getConfigurationSection ment for doing this?:
- list item 1 <- scans to see if item is in the list with .getBoolean()
- list item 2```
or am I misunderstanding something
but how can i get water block ?
i need loop player sight again ?
no
?paste
https://paste.md-5.net/opohelinax.java Add yoru code in teh correct place to do your farmland watering
dan discord fixed pressing tab
smh always fun wheen youre working on a vm, it randomly powers off and you dont know the passwd
i will never get used to vmware
had 9 vms open (network architecture) and two hours later, two were gone
Would this still work or would it commit unalive?
You're not doing that sync right??
use teh AsyncPlayerLoginEvent
The Profiles are also saved in a hashmap until server restart
orcs player join event?
ocs**
orsosilrcore
ocsolircore
wait
@eternal oxide why u don't use "||" equal at here ?
Because
|| means
yep ?
go google for or and and
and second is write
correct*
it will still execute
a way to have mutliple ifs in one if
ah alright
|| means if either condition are true. && means both conditions are true.
they're called early returns
you check that its not what you want and return
oke
Or should i terutn a runnable
ic oculd also just have it execute that
thats probably simpler
futures be like
I forgot how to execute a runnable 💀
.run()
found it
just look at the impl
you say
I dont want to read on them tho 😠
bad, if you are doing that new BukkitRunnable() {}.runTaskAsync
love it how this channel is like "hey i got a question" and five people say ten different things
ping
Happy with ur lambda?
yeah
I must say, i havent used lambda before but i like it, it looks alot more clean
lambdas are nice
Is there a way to get an offline player by name without doing a blocking web request
@echo basalt are you doing anything atm
Bukkit#getOfflinePlayer();
Like for example just using the last name they had on this server
not rly
not quite
That runs a blocking web request
More often than not, yes.
But sometimes people overdo it and then you start looking at hideous "power towers" where one lambda needs to call another, that one needs to call another, etc.
it does check the local file cache
lambda illusion smearch smindex?
Oh I guess I could just make a (yml) database of the name of every player who joins and their uuid
i wonder when isi has enough in it to fully teach people how to spigot
usernamecache.json in the server folder?
That seems wildly resource inefficient
fuckin
Idk man because I’m lazy
Illusion Search Index - Lambdas
Lambdas in java are incredibly useful but a bit tough to learn. This guide aims at simplifying the concept so it's a little easier to understand.
The backbone of lambdas are interfaces. An interface can be seen as a sort of "template" of a class, with no implementation. It represents a schema that
must be overriden and implemented accordingly.
Lambdas in turn, create an anonymous temporary class that implements the required interface given it has one and only one method requiring implementation.
Let's break down the Runnable interface: void run();
The main points of interest are:
- The return type:
void - The parameters (empty in this case)
Now, facing a method that requires a Runnable parameter, we're faced with three choices:
- Create a class that implements Runnable, override its method and create a new instance
- Create an instance of an anonymous class, overriding its method
- Creating a lambda (shortened version of the method above)
Let's assume we have this interface:
public interface MessageSender {
boolean sendMessage(Player player, String message);
}
We start by creating a lambda expression, with the given parameters and return type:
MessageSender implementation = (player, message) -> { // parameters
player.sendMessage(message);
return true; // return type (boolean in this case)
};
This is a valid replacement to either:
MessageSender implementation = new MessageSender() {
@Override
public boolean sendMessage(Player player, String message) {
player.sendMessage(message);
return true;
}
};
or
public class SampleMessageSender implements MessageSender {
@Override
public boolean sendMessage(Player player, String message) {
player.sendMessage(message);
return true;
}
}
You can embed lambdas directly as any other variable, without the need to specify it's a new instance of a class.
Edge-case scenarios:
- When dealing with a single parameter, the ()'s are irrelevant (Example:
player -> player.sendMessage("Hi");) - Braces are optional if you're doing one-liners
- When dealing with a method that matches your exact parameters and return type, you can use the :: syntax (Example:
this::sendMessage)
And ymlconfiguration is easy
lol json is a subset of yaml
And I’m going to have like 15 players on this server
@wise mesa
So it really doesn’t matter
no difference in using yam or json for data, only yaml is better human readable
Is there a way i can Pass variables into a task?
Json is faster..?
no
I mean
I thoguht it was hang on
Maybe for saving and reading
reading json is easier than reading yml
But it’s not like I’m reading it every time I need a players uuid
because it specifies when a block ends instead of converting indentation
I NO LIKE FUTURE
yaml is must easier to read than json, for an end user
futures are great
you can run stuff when they complete like notify a player
Futures are awesome
Futures seem complicated, and my 2 braincells cant comprehend
json is 30x faster
How do I get the server ip from code?
pretty much impossible
Compare gson to yamlconfiguration
its 3x faster, as shown in the benchmark
As they are the two things most spigot users used
JSON IS THE SUPERRIOR ENTITY, BOW DOWN TO IT
gson is a wrapper for json..
Now he’s just joshin
Hi if i use crontab for running a task every monday it should work even if the server goes down a day before and run it as should be?
A wrapper that does things
Should
And it needs to be benchmarked on its own
Why is optic recommending yaml config over json
Just look at JSON its so butifull
because it's readable to the end user
its slow af
not for a config
that is the last concern I'd have for config
Update Whoops, misread the question. :-( Serialization can still be blazingly fast despite the large input grammar; however, browsing the source, it looks like PyYAML's Python-level serialization constructs a representation graph whereas simplejson encodes builtin Python datatypes directly into text chunks.
we are tryna store data
a coinfig consists of infewequently changing data
not make a config
Yea
Well anyways
JSON is better
if it's infrequently changing then the only thign you need to decide is if you have to serialize or not
But efficienty
And only saving infrequently and reading once during startup
For storing data I have my own solution then: DataOutputStream/DataInputStream
you're saving it in memory.. then reading it during statup
If the end user needs to read/edit it then yaml, if it it not to be edited by hand then json
after the memory is cleared..?
if it uses Bukkit objects yaml
You didn’t read everything I said
I make my configs in json, because jsoncrack.com has an editor that allows for easy editing
Im not reading the file every time I need to get a user is the important part
I read it during startup
And save when a user is added
Why not add the user to cache and write onshutdown
^
Because servers crash from time to time
what kind of data do you need for this player?
onDisable still gets called during a crash,
And new users join very infrequently because like I said my server had like 15 players
I think
yea
- if ur server crashs, that should be a bigger issue..
depending on what you need for the player you may not need a database at all
I only use a database when the data is shared across multiple servers
Or when its just alot of data like a Rank, there Level, and other stuff
spigot should add a PDC access for offline players
yes
not hard to do
coll did it a while ago but didnt pr it iirc
Could you not manually do this, by navigating to the folder and reading from the files?
yes
but if it were available via the OfflinePlayer Object it would be so nice
land ownership plugins would become so simple
How do i make a command work but not show up in that autofill box?
you'd be surprised
I've seen implementations
mostly because they tried to do all nbt not just PDC
?paste
https://paste.md-5.net/ejojataxim.cpp
Is this correct for creating an item and creating a recipe for the item?
there you go @remote swallow
.
you havet to give the player the recipe aswell
what's next? Interfaces and abstract classes?
whatever u feel like 
I've also edited the future guide to reference this one
I'm gonna start charging 20 bucks for custom guides this is getting annoying
I thought I had to just add it to the server, and it would work, but I keep getting an error saying its null, so idk if i done it right.
@ivory sleet 20 bucks
@echo basalt btw that'll be 2k usd for the guide on magmaguy
apparently, <player>.sendMessage has been marked as obsolete, what's the new one to use? Context is a PlayerInteractEvent
I still dont understand how to do it
I'd rather spend the 2k by flying to afghanistan and getting first-hand experience on fighting the taliban
lmao
wicked
lucky you I also accept you doing that as payment
yeah they're clowns
¯_(ツ)_/¯
so I can see what it's like for you to get shot
they want you to wrap it in a component
editor: THIS SHIT IS DEPRECATED
me: ok and
Listen to that event, if it's a player you don;t want to see the command you remove it from the collection
not verified
why not just NOT give the command permission to those should should not be using it?
oh
can namespacekeys have underscores or capital letters?
no capitals
and if you don't, https://www.regexr.com/
lol
Says I already am
you gotta wait for the bot to do its thing
I think its because my old account got hacked
i was afk
https://paste.md-5.net/opohelinax.java i change ur code btw
i will do water farmland at other fun
i need add returns to last ifs ?
me when color codes are also deprecated:
how the fuck are you sposed to color messages?????????????????????????
Components have color
but this is not a Spigot issue
Not in spigot
ok
beds have 2 parts just add both
place top half, set facing, get other half, change to bed and setPart
googled "spigot place a bed" and got several results
thanks
maybe check em out
looked through many couldn't figure it out thats why I asked here
but thanks anyways
i'll try this method
why is the run button grey?
what option do i do when making one?
depends on your goals
Is it maven?
yeh sure
ty
It could be literally anything
There was a mistake in the early return. Fixed https://paste.md-5.net/ivudupibas.java
block.setType(Material.RED_BED.createBlockData( Bed.Part.FOOT ));
I'm probs being stupid but I'm still having issues with setting a bed
could you give example code of how to set the head and foot of the bed
is my code fine ?
no
|| e.getClickedBlock().getType() != Material.FARMLAND
ah yes thx
your logic is not good. You should allow watering on any moisture level that is not zero
what's the best way of storing some data in a block? i don't care about it being persistent, its only temporary data
why u wan't this ?
just create some sort of map from either a location, or a key to a location to whatever data you want to store then
saving the name of a player when he charges a respawn anchor
ah understood
won't this affect performance tho? it will be adding and removing keys from the map every time an anchor explodes
how often is that happening on your server?
also is it any better than this?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/metadata/Metadatable.html
declaration: package: org.bukkit.metadata, interface: Metadatable
its a pvp event server
crystal pvp, anchor pvp
it all happens a lot
probably not enough to worry about changing a map
even on 100 player events?
a tick?
no i meant like
100 player count
and event as in ingame events, not the spigot ones
yeah, I don't think you're gonna run into performance issues with something as simple as this
you might want to set a max size for the map tho, so it doesn't get too large with they key size
oh ok, but is this any better/worse?
like how are you removing stuff from the map
the metadata map just uses a map behind the scenes
so you could use it sure
but you still have to remove the values, just like map
the keys won't be removed when the block is removed?
no
the "block" is just a wrapper for a location really
it just holds a world and a position, and any method calls on it fetch the blockstate at that position in the world
so there's no concept of "breaking" that it is aware of
So I want to do a rank system similar to this -> (https://www.spigotmc.org/wiki/how-to-make-custom-rank-system/) but the problem is that I'm going to have to allow other plugins to register their ranks
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I'm not sure how to implement it well
how do i play with my friends without port fowrwing
thank you
ensure that the entity is living
then cast to LivingEntity
because LivingEntity has that method because it implements Attributable
not entity
now you gotta use target instead of entity
numbers as keys in configs are troublesome
bonk
I'm not even sure if I can ask for help with almost the same thing the third day in a row 💀
someone told me i need to use LivingEntity ..
that was before knowing that you had it as a player
Doing event logic with Monitor priority 
well if I was going to follow the enum route like I was going to originally
I would have to create an interface for enum commonality
@twin venture what version of Spigot are you on
it would be handled in the main plugin of the server that's in communication with the core
Your IDE is depending on 1.19.4 too right? Player#getAttribute and Player#getPotionEffect should both exist.
but I also want the core to have a base enum for ranks like staff ranks
you're telling me to do what I want to do essentially
not how to go about doing it
😐
whats the issue with using an enum
I would just have permissions for each rank or whatever
and then just using those
maybe putting in an enum to easily compare ranks or whatever
if thats what you mean by using an enum
I thought about having like a rank hierarchy with an integer of permission level or whatever
yes thats fine
but then in every command I would have to check that when in my command system I already have it checking for the permission stuff
well then why check it again
no in the command system it uses Player#hasPermission(String)
you add the permission on the command in plugin.yml. It then gets checked automatically
Well see that's your first mistake lol
thats your first error then
no it is not
what I'm getting at is
if I'm already doing all this shenanigans in an enum
use the API correctly and 90% is done for you
it feels a bit silly to have the permissions in a config file
its not a config file
bro you are literally not following along
its a plugin description file
it's for the permissions on each rank
storing the permissions that each rank has access to
then assigning them via the rank system
I did read it
it tells me how to set permissions using the api
that's not my problem
ranks and permission groups are what permission plugins are for
I'm not having that problem????
I still dont get how using an enum adds double work
can you provide a code example?
ok how the fuck are you guys confused
let's start again
so I'm creating a rank system right using enums
yes
what are you talking about dude
just ignore him
it's for my server
an Enum is fixed at compile time
so hard coded
that's how an enum works
Exactly what I just said
so I need to store the permissions each rank has access to
and since in the enum I'm going to define data like
aw ye
rank color
etc.
it seems like it would make sense to handle permission stuff there
then also define a list of permissions for each rank
man making these have modular decoration elements is a pain
won't it look ugly though in the enum definition?
you're right I need to be more inclusive
🚎
do you have any alternatives
other than
luckperms
its either ugly or you dont use an enum and add way more code around it
why not luckperms?
bro please
Simple question
you clearly are the kind of person who wants me to use pre-existing stuff
which is not what I want to do
you are literally tryign to do everything a permission plugin does, hard coded IN your plugin
doesn;t matter
Why would you reinvent wheel if smth already exist lol
it does matter
experience and I know exactly what's going on
if you want to make ANY changes you have to recompile, just to change a colour setting or permission
bro why do I need to be interrogated on why I'm doing something
this is not why I came here
Gl with that attitude
its fine to start out using an enum
for some reason now I got it harder to join my localhost server
I keep getting the error of Authentic Server?
how would you do permissions
We are trying to disuade you from re-inventing the wheel when it's a pointless task
like I said, if you want an enum, I would save a list of strings alongside each rank
if didnt use enums I would do that too i guess
another man's garbage is another man's treasure
and then just have a method like hasPermission etc..
I wouldnt make an interface but thats another way I guess
so you think each rank should be its own class?
well assuming each rank will just have different properties
I mean if I'm storing permission data it would be less ugly that way
an interface is kinda annoying since you are just using a slurry of getters
I would just create instances of a rank for each rank you have or something
I don't want a command in-game to create ranks or whatnot though
I just want it to be done
so everything is final
no
the best way is to make a config for it
no, hard coding is easy
this wouldn't even be in question if my command system didn't already utilize regular permissions
Uh, what does that mean?
[19:41:42 WARN]: Excessive velocity set detected: tried to set velocity of entity #378 to (6.574896471116735,-2.4675344695432244,-3.9350362178400293).
[19:41:42 WARN]: java.lang.Exception: Stack trace
[19:41:42 WARN]: at java.lang.Thread.dumpStack(Thread.java:1341)
[19:41:42 WARN]: at org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity.setVelocity(CraftEntity.java:213)
[19:41:42 WARN]: at me.andreasmelone.gunstop.GunEvents.onPlayerShoot(GunEvents.java:69)
``` (Code: <https://github.com/RaydanOMGr/GunStop/>)
I would just make a rank priority system and be done
I would just have an enum like originally planned
but in my command system I already handle not having the permission in subcommands and whatnot
RANKS
permissions has to do with both
ranks have permissions
commands require permission
well then you need to adjust your command system to use the rank enum
we're not going back to this
well my command system is an external api
vine boom
not really
experience with hard coding
👍
ok no but like
the ranks are literally never going to change
ever
so it makes sense to have them finalized in this scenario
which is why I was opting for an enum
yeah I remember devs before 2000 never though about the date changing and to use more than 2 digits
lets say for some reason iam using version past to 1.12.2 ..?
I'm not planning on using other plugins really
well
so what are you asking again?
if you are already using another plugin for commands, then there is no way to only have 1 way of permission checking, unless you feed into that somehow
at which point you would probably use the enums in a different way
but whether or not its an enum can be debated over until the heat death of the universe
it doesnt really matter for the rest of the code structure
well
I suppose I could just like not use the permission annotation
and then an enum would be feasible
idk why I didn't realize that
ok so I'm going to go the enum route and have a rankhandler singleton
now I have to do the rank weight
thanks steaf
how do i get the perimeter of the block ?
wait
no i wanna get block around of block
ahh
i can't explain this wait i will show u with picture
example i have sponge block
and sponge it will scan the blocks around
for loop -1 +1
how can i get granite?
example this is stardew valley
sprinklers watering the around
how can i do this i mean which event ?
blockform ?
idk
and i need use scheduler for the moisture farmlands?
when you want to get the block
when do you want to water?
when there's a block I want around
Save all the blocks in nbt and load them up on chunk load
Then start a timer task
i don't need event for do this ?
what event do you want to use
Block place event I guess
if it's farmland you could listen to teh moisture change event and trigger when it goes below a certain level
if it's near a watering block
Even easier tbh all farmland by a watering block should have some form of nbt data. Then you shouldn't need timers ig. Smart elgarl
ah yes
he's not using water blocks. it's a custom water system

