#help-development
1 messages · Page 528 of 1
i know wait
I mean idk how ass pressure would ever not involve a block
But i'm sure you can spare the CPU cycles
muh CPU cycles
if the account name is 2008choco it might not
yeah you cause events while crouching in the air
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Block block = e.getClickedBlock();
if (e.getAction() == Action.PHYSICAL){
if (block.getType() == Material.FARMLAND) {
if (block != null) {
e.setCancelled(true);
}
}
}
}```
Move it up
Or && it
oh
Also invest in early returns
the exact code i sent
ye
Not exactly what I meant when I said && it
but yeah that works
method() {
Block block = e.getClickedBlock();
if (block == null) return;
if (e.getAction() == Action.PHYSICAL && block.getType() == Material.FARMLAND) {
e.setCancelled(true);
}
}
no you cant question the method
Why stop there
method
if i change Player interact event to entity interact works for player and other mobs ?
method() {
if (e.getAction() == Action.PHYSICAL && block != null && block.getType() == Material.FARMLAND) {
e.setCancelled(true);
}
}
Yes, it should
no
not enough cpu cycles
Wait I can do one better
Though I'm not confident that EntityInteractEvent has an action associated with it like the player event does
method() {
e.setCancelled(e.getAction() == Action.PHYSICAL && block != null && block.getType() == Material.FARMLAND);
}
:D
wrap in code block smh
lol
Also yes you can cancel trampling with the entity event
I might just have to ban you for this monstrosity
WorldGuard would like a word
and it isn't even wrapped inside a code block
Yeah it has no associated action or other data. Honestly not sure why
ill let choco win the javadoc race
getblock ?
if (event.getEntityType() != EntityType.PLAYER && event.getBlock().getType() == Material.FARMLAND) {
event.setCancelled(true);
}
}```
Tis what I use
no @EventHandler
No because it's executed as a consumer
wait so does the argument array not include the subcommand?
/command arg0 arg1 arg2
arg, another, even, more, args is the array
ok good
/example subcommand a b c
/command is still a command
yeah
lul
confusing mess
The length can be 0 if there are no args
i would like help for the codes without knowing java, am i ban from this server?
this question is weird but i banned from paperdc for this reason
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
If there is such a rule here, I will not ask questions.
No but you'll get learn Java
basic questions will get you told to learn java, build up credit type thing and you get some extra help
Wait papermc bans for that? Man they really don't fuck around
what subject should i finish in java to write code like you?
I would cover all the basic types and such
You don't need to cover all the fancy stuff like reflection just to make a plugin
arrays, lists, method types, static aboose, class types
i watched this videos 2 times
hash maps
Halo, i got this error and idk whats wrong: https://paste.md-5.net/ecolemeqet.java
Is this your plugin
You don't have a messages.yml file in your jar
there7
Or it's in the wrong place
wanna see pom.xml?
For some reason its not switching from the netherite sword to the netherite axe, all other things switch.
https://paste.md-5.net/nadoxowufu.cs
What am I doing wrong here?
lemme rebuild
Check the exported jar to make sure the file is there
how do you save the file
im taking a wild guess its loading the jar that doesnt have the file
It's looking for plugins/Fluorite/messages.yml
I'm guessing the path for yours is just messages.yml
save resource should be saveResource("messages.yml")
and you probably want to cache the file
Is anyone available to help with this?
better, but you shoud cache the file
move code
im working on that
on how to cache files
i was thinking
method like
you have a private final File file
i doesnt)?
can i make this shorter?
yes but it would almost be pointless
so this usage is true for multiple class?
sry i wanna learn coding rules
wdym
well if you dont want to learn coding rules idk why you are making a plugin xD
anyways you can just extract it into a function
but like I said, its like pointless
this is already pretty consise
mb
can someone help me with this?
your braces are wrong I think
reformat the file
youll see
ah, yeah thanks
guys i have a question
i will cancel event for cactus growth
and add delay after check cactus up if up is air will add new cactus block
now this methods works all cactus in world?
yes if you do it right
if i don't add ? check chunk or world ?
add new cactus if player in the same chunk
the grow event will be called for all cacti that are loaded if that is what you are asking
yes
Oops sorry
what is the latest version of the spigot api (plugin.yml is complaining)
is it 1.19.4-R0.1
1.19
ty
why this not work ?
public void cactus(BlockGrowEvent e) {
Block block = e.getNewState().getBlock();
if (block.getType() == Material.CACTUS) {
e.setCancelled(true);
Player player = (Player) Bukkit.getOnlinePlayers();
player.sendMessage("test");
}
}```
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
i want to disable cactus growth event
what
this is b ot
BRO i need sleep
does this code work?
player.sendMessage("test");```
when u run it does it send the message and not cancel the event or it doesnt do anything?
ik i was asking him
do nothing
He should have gotten a ClassCastException in his console
i don't
change this code to this
player.sendMessage("test");```
i try to get e.getplayer
You should. So that means e.getNewState.getBlock is not a cactus.
but didnt work
The event has no player to get. If you need a notif, use Bukkit.broadcastMessage or Bukkit.getPlayer("Name")
yea i just saw that
Since there's no player involved in the BlockGrowEvent
Also if you aren’t getting an error it may not be running at all
Is the event registered
ehh
i was wondering have better way to register events ?
thats the only way you can register them but you could do a private void and than just call it on the onEnable method
ah oke
There are more advanced ways but I wouldn’t worry about them
so like this
getServer. blah
}```
ehh
alright i understand but
just stick to the basics
I'm literally too hungry and sleep deprived to write up a proper explanation but
return true
ok
getBlock.getType will return the outdated type because the type hasn't changed internally (usually happens with cancellable events)
So get the type from the new blockdata instead of routing through getblock
for (PotionEffect effect : effectList) effect.apply(plr);
Why this no work
your effectList could be empty
you sure?
up to their coding style, brackets are somewhat debatable
it literally performs the same
just a readability thing
I personally use them but there was a long period where I didn't
Any idea?
Because I am cluesless
is there something niche with potion effects?
Well what’s in effectList
I'd just player#addPotionEffect just to be sure
other than that add a sout in each iteration just for sanity
Tried that too didn't work
Did
worked
make sure that no other effects of the same type are present
not the potion tho
Nope
Its on the same line
it literally has the same effect as adding an empty line
void method() {
for (.. : ..) doSmth();
doSmthElse();
}
//vs
void method2() {
for (.. : ..) {
doSmth();
}
doSmthElse();
}
They flow the exact same to me
ngl
Skill issue
^^
public void doSomething() {
int[] iterations = {-1, 0, 1};
for(int number : iterations) {
printNumber(number);
}
String whatever = "Joe mama";
}
vs
public void doSomething() {
int[] iterations = {-1, 0, 1};
for(int number : iterations)
printNumber(number);
String whatever = "Joe mama";
}
is mostly the same
what I am against
is
if(whatever) return; these 1 liners
but overall just follow google style and fuck off
Really not. Dude I have been programming in java not that long. It reads the exact same for me.
It is literally by definition a: Skill Issue
Chill
Bruh search up skill issue
tell me what it is
Wild
I only came here to ask why it wasn't working. Not to be called a slur
So chill out both of ya
Things getting heated over 2 curly bois
That is an opinion you're stating like a fact. If you struggle to read stuff like that it is a S K I L L I S S U E
Thats what flow is
Opinion not a fact again
Let people have their opinion. At can someone tell me why these potion effects don't work?
I dont get tabcompleters, i want the tabcompleter to set /simples toggle scoreboard but it obiouslly doesnt work
Then why are you calling me names
package commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import java.util.ArrayList;
import java.util.List;
public class MainCommandTAB implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if(args.length == 1){
List<String> arguments = new ArrayList<>();
arguments.add("reload");
arguments.add("version");
arguments.add("support");
arguments.add("toggle");
return arguments;
}
if(args.length == 2 && args[1].equalsIgnoreCase("toggle")){
List<String> arguments = new ArrayList<>();
arguments.add("scoreboard");
return arguments;
}
return null;
}
}
``` this is mi code
Quote from where?
I don't mind one-liners if it's in a switch block though
Those dudes make the code pretty. Look at the wiggles!
Lambdas are debatable themselves.
plr.setSaturation(clamp(plr.getSaturation() + saturation,0, 20));
plr.setFoodLevel((int) clamp(plr.getFoodLevel() + hunger,0, 20));
plr.setWalkSpeed(0.2f);
plr.setCooldown(mainHandItem.getType(), 0);
plr.getInventory().setItemInMainHand(finalUpdateItem);
plr.playSound(eyeLoc, Sound.ENTITY_PLAYER_BURP, 2, 1);
for (PotionEffect effect : effectList) effect.apply(plr);
To me this just seems more slik ngl
oop tab moment
Wouldn't take float
I personally dislike that bracket format. I put my opening bracket at the end of a line, never the beginning.
That’s how java does it
Java is life
Well anyone know why just potion effects don't work and everything else does?
Have you tried p#addPotionEffect ?
Yes
I've never used effect#apply
One thing though is if the player already has speed 1 and you add potioneffect speed 1, it will give them speed 2.
public boolean apply(@NotNull LivingEntity entity) {
return entity.addPotionEffect(this);
}
Alright. Still it should apply
as long as your class extends potioneffect, that will work. Make sure it is getting called and no error is thrown.
We need more than 2 lines
No thats was the spigot method
Literally nothing else could be effecting it that's the issue. EVerything around it works.
This is mine
Oh
any ideas @agile anvil ?
Well that has to be something outside these few lines that interferes
It littearly isn't everything else works...
Where is effectList instantiated?
Have you printed out the contents to be certain of that?
Yes
how can i make this updatechecker work even if the version is GREATER than the plugin one, cause rn it sends you are on the latest plugin version, only when you are on same one that on the spigot one, ```java
//UpdateChecker
new UpdateChecker(this, 109934).getVersion(version -> {
if (this.getDescription().getVersion().equals(version)) {
System.out.println("You are on the latest plugin version!!");
} else {
System.out.println(ChatColor.RED+"There is a new update available!");
System.out.println(ChatColor.GREEN+"We highly recommend you to update to the newest one here: https://www.spigotmc.org/resources/"+"109934");
}
});```
There are the potion effects.
you have to somehow parse it and compare
^
depends on what your version looks like
Is the method returning false?
Are they instant effects perhaps
No they have ticks
After applying the effects to the player, print out the list of effects the player has. That will determine whether they are being set in that instant but being immediately changed via some other software.
Doesn't have to be
The method potionEffect#apply returns either true or false, based on whether it could apply.
If it returns false, it is because something was preventing it. If it returns true, it means something changed it immediately after.
Gotta know
One of the things it took me a while to get used to when learning C# was that friggin format. I do it to remind myself it's not Java.
Keeps me from tryna use Java methods
CPP... I have opinions on that language XD
Biggest issue is they limited variable name lengths because back in the day that mattered
So now all their libraries have garbage naming
I wanna learn Rust
My friend learned it and loves it. He says its fast and versitile.
From what he has made with it I can agree with him.
No comment
Well... thing is I wanna make an OS. Not really a Go project.
I did say it was in a runnable
shoulda said async tho
You should have gotten an error
You should consider that you can't impact the game async
ty, ty. Fundamental projects are fun to me. I made a web language once with a friend, that was pretty great. Interpreted, not compiled... there are downsides but for web it's fine.
While thats new to me. Why cant I change plr than
Can you make the runnable sync?
Chat can be async but anything that can physically affect others should always be sync, keeps from screwing with the server
bliiingg
Now imma go do /reload 🤭
IT workS!
TITISadgsdf
YES!
I am not kidding that is the dumbest issue I have had in a while
Like first shot everything worked beside that
There’s actually a fair amount that can be done async
can or should?
Now I can eat an axolotl!
But if you don’t know whether it’s safe it’s best to just avoid it
Can
Things that should be done async is mostly just IO and web requests
Some things used to be async by default and they've updated them due to lag issues.
Off the main thread
Og
Server runs a main thread (sync) and a "side thread" (async), main thread runs major interaction stuffs
fair
So if I want to do tons of calculations async is good place to go?
That would prevent slowing down the main thread, but if you are just doing math then don't bother. Math is blazing fast.
No I mean like 😎
ya know
"for each" loops can be slow
cool boi stuff
When you can, I advise for(int i) style
can't remember names of things
Got alzheimers or smth idk
Worst memory
Ik its just... Ya know ):. Java made me happy when there was like. : <-- that thing in for loops
my life was complete
Called a colon
In but it deserves a more godly name than that in the context
For each vs regular for loops is a micro optimization
ily
Depends on how many iterations ig
If you're going to loop through every block in X area, I'd recommend it
foreach is using iterator internaly, so there is overhead
Can easily hit tens of millions
The overhead is incredibly small
It’s not worth the sacrifice in readability unless you are writing at an enterprise level or something
I want IDE that knows micro optimizations so I can code the way that makes me happy
The compiler knows micro optimizations
So then i don't have to worry
Depends
Pretty much
Time to put this here https://www.youtube.com/watch?v=tKbV6BpH-C8
When should you optimize your code?
Access to code examples, deleted scenes, song names and more at https://www.patreon.com/codeaesthetic
Ahh MMY EYES * hissss *
Don’t worry yourself too much until people start throwing spark reports at you saying your plugin cuts their tps in half
:p
I'll accept anything that cuts tps 50% as long as it works lol
I just need the gratification
Nots like my plugins are paid
Shoot imma bout to get dissed
Hi, for my vote listener, I'm fixing an issue where on a bungee network with voteforwarder to all subservers, a vote is queued, even though the player is online on one of the servers.
I found the onlySendToJoinedServer setting in NuVotifier on the proxy. That's nice, but if the player is not online, this will of course not work.
What fix would be best: ignoring a new queue request if the one was already made within x amount of milliseconds? Or making the queued vote unique to a server, so the rewards are not processed multiple times on one subserver (which was the initial issue)?
Thanks for thinking with me!
Pretty much anything your plugin is doing is going to be a small fraction of what the server is doing anyway
Ouch but okay & true
It's not like the paid plugins have better code than free ones
💀
SO I CAN GET PAID AND CUT TPS BY 50%?!
Yes
Paid plugin code does get reviewed but I imagine it would have to be pretty bad to get denied
Me making a paid welcomer plugin
Plus it only gets reviewed on the initial posting, not on updates
I never had mine declined and tbh given when I made those plugins... pretty inefficient. I was new.
Server Owners: its paid so it must be good
Now I just make everything free.
The fact that I can spend $20 on a plugin vs a free plugin must mean $20 is far better
You can do the same with spigot forks
McMMO is worth paying for, I will say. So is featherboard. I don't pay for plugins often but I own both of those.
Except instead of $20 it’s $200
Check my bio and don't quote me.
I feel like McMMO is just everywhere thoo.
People don't customize it enough to make it feel nice. It has stupid potential.
Really?
You should look at the like 9 config files it makes sometime XD
everything is adjustable
So basically make your plugin as dumbed down as you can well still making it as customizable as possible for a good plugin?
Customization is key. It prevents having to make little adjustments to please your users. Let them adjust it.
Eventually your plugins will be 90% just making complex inner code to handle a variety of config options so your users can essentially write your plugin for themselves.
Eventually it will just turn into another scripting plugin
I wouldn't go quite that far... gets messy and slow.
Ahh
right
@tall furnace can i just switch dependency in pom.xml from spigot to paper and it work?
I never use xml, don't ask me XD
😢
I don't use maven or gradle
U compile urself?
I use Eclipse, it compiles for me
Wait there’s a quote for this
Compiling through cmd prompt sucks
i came across a problem in my UHC plugin when i want to create .yml file for scoreboards it works great it really has been made and everything is written inside and it is saved properly but i also wanted to set in config.yml Scoreboards-set to true and save it so next time plugin is ran it wont wipe out the scoreboard user has configured and when i change it to be true that works but when i save it it wipes out whole config.yml content from before and just has Scoreboards-set set to true
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
How are you saving it?
?bebe
can you send ' symbol im using croatian keyboard
How can i create multiple configuration files with different names, and acces to them
Found it
` that one?
?don'toverusecommandssometimespeopleareguidedthroughtheprocessesbetterwithcommunication
Or not
Having to download and setup the IDE just to compile sucks
upto you
I use the IDE anyways tho
What if you have to share the project
Vexaris.plugin.saveDefaultConfig();
File configFile = new File(Vexaris.plugin.getDataFolder(), "config.yml");
Vexaris.plugin.getConfig().set("Messages-Set", true);
try {
Vexaris.plugin.getConfig().save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
i know it is weird
wasnt like this at first
but yeah
Github
Github won't make it automagically get all the dependencies and set everything up
See if you go with a paid open source plugin
Depends on whether you include the dependencies in the project files ig
You need to make sure it’s nearly impossible to self compile so you get more sales
Vexaris.plugin.saveDefaultConfig();
File configFile = new File(Vexaris.plugin.getDataFolder(), "config.yml");
Vexaris.plugin.getConfig().set("Messages-Set", true);
try {
Vexaris.plugin.getConfig().save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
^^
True
Oh... no need to get the file like that. Just use plugin.getConfig() and then plugin.saveconfig()
Remind me to manually upload any premium plugins I ever make to ShadySpigot with silly annoying stuff thrown in to annoy people
Lol
big brain
Every 10 minutes the plugin sends a link to download Raid: Shadow Legends
Just specify in latin
I think one dev purposefully uploads outdated versions to NoirSpigot
Might be the McMMO dev iirc
blancoSpigoto
hello
what s the difference between Player#updateInventory() and Player#openInventory(sameInventory) ?
Did you see my response?
yes but there is no saveconfig()
i just got the app for dev can someone help me a bit
I imagine opening the same inventory will reset the cursor
"plugin" in plugin.saveConfig(); needs to be the class that extends JavaPlugin, aka your main class.
Updating it shouldn’t
Or you can even just setContents the inventory, you generally rarely need to use updateInventory
Pretty much
ok, thanks
But we have api for that now
Woo
Iirc yes
It’s fairly recent, one sec
Ah dang I thought it was
1.20 maybe?
Just quick question if anybody knows a better way to cache player ranks from a MongoDatabase, then to create a abstract class which gets extenden by looping throught all ranks in the database?
Saw that last night actually, when I was messing with anvil inventories
That’s the cb commit, which is where all the interesting stuff is anyway
Bukkit has some code
Still not super comfy with using ? in code. idk why, I just prefer normal boolean checks.
But most of it is the the api abstraction
ye
Can't remember names of things so I gotta describe instead
I understand them, just always prefer a proper if/else
Is it faster to use ternary?
Eh I'll just stick to if else then
It’s just shorter
#lamdaisgood
Why you like the curlies...
I like to see
Runnable{ run(){} }
I wanna see THE CURLIEZZZZ
I also like curliez BUT NOT TERE
@tall furnace it is the same thing still
Yes, but v i s u a l a p p e a l
Where can i learn about configs cause iw ant to create a message.yml and dont know how 😦 ```java
//Config
//Load message.yml
messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml"));```
hahahaha yes it is much better now
but it still just wipes out everything from config.yml
and just sets that to true
Its butifull
https://www.youtube.com/watch?v=8lyaVKDshDo Skip to like 4 mins or smth
longest screenshot 2023
thanks
I have one thats 8k
Can you show your updated code?
oof
np
Thats why i wrote my own config handler cus i cant deal with yml xD
Im probably jsut to stupid, but somehow its easier to write my own than to understand it
yml is byootiful
public void setup(File scenariosFile, FileConfiguration scenariosFileConfig) throws IOException {
scenariosFileConfig.set("Timber", false);
scenariosFileConfig.set("CutClean", false);
scenariosFileConfig.set("NoClean", false);
scenariosFileConfig.set("TimeBomb", false);
scenariosFileConfig.set("SafeLoot", false);
scenariosFileConfig.set("TripleOres", false);
scenariosFileConfig.set("DoubleOres", false);
scenariosFileConfig.set("TripleExp", false);
scenariosFileConfig.set("LuckyLeaves", false);
scenariosFileConfig.set("Fireless", false);
scenariosFileConfig.set("NoFallDamage", false);
scenariosFileConfig.set("Goldless", false);
scenariosFileConfig.set("Diamondless", false);
scenariosFileConfig.save(scenariosFile);
Vexaris.plugin.getConfig().set("Scenarios-Set", true);
Vexaris.plugin.saveConfig();
}
saving a YamlConfiguration to a File without first loading your YamlConfiguration will ONLY set those specific values.
Vexaris.plugin.getConfig() != scenariosFileConfig
so i have to add ?
Basically you are creating an EMPTY yaml, setting some values, then overwriting the file with it.
So create your YamlConfiguration, load it in, THEN set values and save.
Json isn’t good for configs
Sure yaml is picky about spaces but with json you have all those wacky {}
Spigot toml support when
All valid json is valid yaml
Other way around iirc
HOCON would be the only config format I'd use besides JSON or YAML (though I'm not a fan of latter for there not being any nice implementations that I know)
Forge uses toml now
Look at it, my beatufil JSON
Toml looks nice
And it is absolutely horrid.
how do i load it in ?
Don’t ask how or why
I think it's YamlConfiguration.load(insert here)
Want to do arrays of random objects? No - not possible. Because fuck you, that's why.
use .bin sometime
well i can load file with it but config.yml is yamlconfiguration already
At that point, just encrypt your files into data.enc
You seem new to Yaml files in Bukkit, is that the case?
Never tried it, thanks for the suggestion
indeed i rather work with json
dont know why but is easier to me
well it is not easier i mean both is like simple since you have key and value right
yes
The "Key" is the main identifier, for which you can search Lists/HashMaps, the "Value" is a value...
So if you are using the config.yml file, you NEVER need to reference the file as a File object and you NEVER need to use yaml.save(file).
To get the yamlConfiguration for the config.yml file, just use Vexaris.plugin.getConfig() like you did. To save it, just use Vexaris.plugin.saveConfig().
okay but how do i load that config.yml like you said i should if i dont want to overwrite it
If you are using the config.yml, you never need to load it. It is loaded when the plugin is loaded, and it is referenced only via plugin.getConfig().
so why does it remove everything from config.yml and just saves that boolean value
Can you show me where you are calling this method?
in on enabled
if(!getConfig().getBoolean("Tablist-Set")){
try {
new SetupTablist().setup(tablistFile, tablistFileConfig);
} catch (IOException e) {
throw new RuntimeException(e);
}
getConfig().set("Tablist-Set", true);
}
This line getConfig().set("Tablist-Set", true); won't do anything because config is not saved after, jsyk
Is there not a tutorial on this in the spigot wiki?
I'm actually not seeing anything that should wipe your config file... depends on context ig. Are you calling saveDefaultConfig() in your onEnable?
Tutorials are nice and all, but personalized help is why this channel exists
ye
getConfig().options().copyDefaults();
saveDefaultConfig();
getConfig().options().copyDefaults(); does nothing
how
Notice the difference getConfig().options().copyDefaults(true);
and is there way of keeping comments too ?
will take time to read
comments have to be reset if you use set on a section
well this is 1.8.8 because who makes UHC in 1.19.4 right ?
WHY
because 1.8
how can i get the player count
.size()
thx
?paste
whats this error? https://paste.md-5.net/cobesiface.xml
Did you create a constructor in your main class
Oh yeah, thanks i checked it was wrong i dont know why, but like it was grey, i created it again and now it works
i forgot a this.
i need help with logic. I want to limit a area with water. When the player touches the water i want them to somehow be blocked, moved back or what ever
Keep track of the last land location
And when they enter the water tp them back to said location
but if they jump, it would just keep tp them above the water
Hence why I said keep track of the last land location
The last location with a solid block below
Sure
There are several methods to check if a block has collision, is a full cube, etc
Just a map is fine
How do I get the coordinates of an advancement in the advancement gui from a Packet with the PacketType PacketType.Play.Server.ADVANCEMENTS
Using ProtocolLib
Wat
AdvancementDisplay has an x and y coordinate. Not sure why you'd need to do this with packets
Hi, I have this piece of code: java ItemStack from = e.getWhoClicked().getInventory().getItemInMainHand(); System.out.println(from.getItemMeta().getCustomModelData()); ItemMeta meta = item.getItemMeta(); meta.setCustomModelData(rodType.getCustomModelDataID()); item.setItemMeta(meta); System.out.println(item.getItemMeta().getCustomModelData()); System.out.println(from.getItemMeta().getCustomModelData()); ,but from first sout I get 101, then 102 and 102, why? Where from.getItemMeta().getCustomModelData() is changed?
rodType.getCustomModelDataID() returns 102
?
You're changing it though
ItemMeta meta = item.getItemMeta();
meta.setCustomModelData(rodType.getCustomModelDataID());
item.setItemMeta(meta);```
So yeah, 101, 102, 102, 102 makes sense
Im changing the item's meta, not the from's meta
Oh. What's item defined as?
the same item from main hand as from
getItemInMainHand() returns a mirror
So if you make a change to one of the items, the other will be updated as well because it's backed by the NMS stack
If you want to update the stack without updating another, you'll want to clone it
but if I update just item, not the item from main hand
It’s the same item
ItemStack first = player.getInventory().getItemInMainHand();
ItemStack second = player.getInventory().getItemInMainHand();```
They're different Bukkit instances but backed by the same NMS instance
Changes to first will be reflected in second
so how can I make them different
thanks you
can i control world datapacks with plugin ?
example /change plains grass biome color) -> we can do this with datapacks
but i see some worldgen plugins
✨ NMS ✨
this biome makes custom biomes
what is nms ?
net.minecraft.server
so this client side ?
Any idea why event run two times?
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void FruitTreeBoneMeal(final OraxenFurnitureInteractEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
FurnitureMechanic furnitureMechanic = event.getMechanic();
ArrayList<String> RedAppleTree = new ArrayList<String>();
RedAppleTree.add("red_apple_tree_stage_1");
RedAppleTree.add("red_apple_tree_stage_2");
RedAppleTree.add("red_apple_tree_stage_3");
RedAppleTree.add("red_apple_tree_stage_4");
RedAppleTree.add("red_apple_tree_stage_5");
RedAppleTree.add("red_apple_tree_stage_6");
RedAppleTree.add("red_apple_tree_stage_7");
if (block == null || block.getType() != Material.BARRIER) return;
if (event.getHand() != EquipmentSlot.HAND || event.getItemInHand().getType() != Material.BONE_MEAL) return;
if (!RedAppleTree.contains(furnitureMechanic.getItemID())) return;
Location location = block.getLocation();
if (player.getGameMode() != GameMode.CREATIVE)
reduceItem(item);
player.playSound(location, Sound.ITEM_BONE_MEAL_USE, 100, 1.0F);
OraxenFurniture.remove(location, event.getPlayer());
player.sendMessage("elo");
switch (furnitureMechanic.getItemID()) {
case "red_apple_tree_stage_1" -> OraxenFurniture.place(event.getBaseEntity().getLocation(), "red_apple_tree_stage_2");
case "red_apple_tree_stage_2" -> OraxenFurniture.place(event.getBaseEntity().getLocation(), "red_apple_tree_stage_3");
case "red_apple_tree_stage_3" -> OraxenFurniture.place(event.getBaseEntity().getLocation(), "red_apple_tree_stage_4");
case "red_apple_tree_stage_4" -> OraxenFurniture.place(event.getBaseEntity().getLocation(), "red_apple_tree_stage_5");
case "red_apple_tree_stage_5" -> OraxenFurniture.place(event.getBaseEntity().getLocation(), "red_apple_tree_stage_6");
case "red_apple_tree_stage_6" -> OraxenFurniture.place(event.getBaseEntity().getLocation(), "red_apple_tree_stage_7");
}
The interact event is fired for both hands
I imagine the same applies to the Oraxen interact event
yes but I speciefie Hand
if (event.getHand() != EquipmentSlot.HAND || event.getItemInHand().getType() != Material.BONE_MEAL) return;
anyone wanna make a plugin together? lol
isn't there for eq just getItemInMaindHand() or getItemInOffHand?
getHeldItemslot gets offhand?
getItemInOffHand
but i want to make for two arms
yes
And if you’re in the interact event getItem is whichever hand is currently being used in the event
take both?
At least I think it’s getItem
alright i will try
I will try with this one
ItemStack item = event.getItemInHand();
if (block == null || item == null || item.getType() != Material.BONE_MEAL || block.getType() != Material.BARRIER) return;
if (event.getHand() != EquipmentSlot.HAND) return;
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
okay still same isue💀
Like I said you’re best off asking Oraxen
Most of us know nothing about their events
try this:
ItemStack item = event.getItemInHand();
.
it get whatever hand you are using
not player but event
.
how can i cast e.getitem ?
get item gets two hand but my second hand may be empty
[[1;31mERROR[m] /C:/Users/DuttR/eclipse-workspace/onutillities/src/main/java/com/onutillities/SignEvents.java:[197,51] no suitable method found for getPlayer(org.bukkit.entity.Player)```
One sec
Show plugin.yml
PlayerInteractEvent[] events = { PlayerUno, PlayerDos };
if (PlayerUno.getClickedBlock().getState() instanceof Sign && PlayerDos.getClickedBlock().getState() instanceof Sign) {
pastSign = (Sign) PlayerUno.getClickedBlock().getState();
Sign sign =(Sign) PlayerDos.getClickedBlock().getState();
firstPlayer = (Player) PlayerUno.getPlayer();
SecondPlayer =(UUID) PlayerUno.getPlayer().getUniqueId();
ClickedEvent phc = new ClickedEvent(config, logger, this.instance, sign, firstPlayer,
SecondPlayer, pastSign);```
^ the error happens here
You need to specify a command
if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getState() instanceof Sign) {
Sign sign = (Sign) e.getClickedBlock().getState();
logger.log(Level.INFO, sign.getLine(0));
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[Player1 Click]")
|| sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[Player2 Click]")) {
eventSet.add(e);
}
}
}
this.logger.log(Level.INFO, Integer.toString(eventSet.size()));
if (eventSet.size() == 2) {
logger.log(Level.INFO, "duel started");
PlayerInteractEvent[] events = eventSet.toArray(new PlayerInteractEvent[0]);
eventSet.clear();
// Player player1 = events[0].getPlayer();
// Player player2 = events[1].getPlayer();
// Create a new Duel instance
Duels duel = new Duels(config, logger, instance);
// Add the duel to the active duels set
activeDuels.add(duel);
// Call the StartEvent method within the Duel class
duel.StartEvent(events[0], events[1]);
}```
^ start
Trying to modify the shown location of the advancements
i made custom textures for leaves with distance
thats work like this
its distance is determined by how far the leaves from the wood
can i prevent to change distance ?
with any event ?
i see this method at one server
Doesn’t mean there’s an event for it
i'll try physics event
wait
how ?
can i do something without events in minecraft ?
I imagine the easiest way would be using ProtocolLib to cancel the outbound packets
does anyone have the dependency values for maven? (1.19.4)
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
there's already plugin that make it and add custom leaves mechanic
it's called HMCLeaves
Reviews say high cpu usage during worldgen
Oh no please don’t tell me they are doing what I think they are
Oh dear they are
idk actually I didin't use it, just saying that I saw the plugin for that
What
What did you find xD
could you say what's the problem btw in their plugin? Im curious
Sounds about right
Lol wtf
They are looking to replace natural leaves
I get why they do it but it’s really not ideal
I mean it's okay for me bcs anyway I just pregen world before even server start so it should not be a problem I think?
or did this still be a thing after even world is pregened?
🤔
Should be fine if you pregen
Also I wonder, sorry if its stupid question but im newbie in plugins coding
oh nvm actually
it was stupid question that I got an answer when trying to ask😅
is it possible to cancel packets like how it works in fabric
Check if you can cancel by event first. I believe that ProtocolLib allows for packet cancelling.
i checked its github seems the pom dependency dosent exist
Did you add the repo
hm
do the things that involve packet cancelling on this list look like they could be done with event cancelling instead?
if so i might as well just ditch protocollib for now
im just making this for a friend.
I only see one cancel thing, which is fire damage
Which you can do with the EntityDamageEvent
Just give it a really high attack speed attribute
oh yeah
i think i went overboard with this backend but is there a way to connect this to the actual event with the Cancellable object availible
im talking about doAction in specific*
What?
cancellable seems to be an interface not a superclass
and since im using my own interface i cant target it to any specific event
it is an interface
what’s the end goal
like write some pseudo code of the api that you would like to achieve or something
make a good custom item backend so i can speed through making this.
the backend is for myself not an api
You can just pass a generic Event
And then do instanceOf checks on that
Or you can get fancy with actual generics
generics make most sense here tbh
Probably, but they are a bit more advanced if that’s an issue
<T extends Event & Cancellable>
I’m not sure there’s anything that is cancellable that doesn’t extend event
But yeah
unsure where he would want that because I don’t understand the goal but 🤷♂️
sure but Cancellable doesn’t extend Event so just to be safe
PlayerQuitEvent, but yeah including Cancellable is safe
no he means there’s no class that extends Cancellable that doesn’t extend Event
(in the spigot API natively)
Me on my way to make player cancellable
ahh okay
Spigot 1.20: you can now cancel players (on twitter)
player.setCancelled(true);
all the tweeter birds are going to complain it took so long, after all twitter could cancel users forever now and we’re just getting the update
We’ll use the twitter api to send a tweet cancelling them for something silly
Like using Kotlin
Or using gradle
using gradle 😳
yeah they all are
everyone would use it to attack csharp users first tbh
ig in short make a simple custom item library (except its private)
look at the generic constraints I sent and let me know if that helps or if I misunderstood
as for do action most of those are either messing with cancellations or events in other ways
yeah for this case it would, but for other items i dont think so. The idea is to check callOnCancel and if its false it instead calls when the item is created and again when placed in somebodies inventory
again this may not be the best backend and there is probably a better way to do this but i cant think of anything so 🤷♂️
so only when callOnCancel is true would that work with the constraints you sent
when its false it would just be any event
thats the reason i have the CancellableItems class
then just check instanceof Cancellable at runtime or whatever
ngl I don’t understand what you’re doing still
but it sounds like you need different containers based on the return of a method?
in that case then yes you can just check instanceof at runtime
basically making a backend for this type of thing if you want me to be as broad as possible about it
an ItemBuilder?
oh yeah that would actually work fine because of the function
doAction or whatever it was
yep 👍
though wouldnt that be ugly with a bunch of casts forced
and the parameter type would be Event instead of Cancellable
yea
latest java has if (event instanceof Cancellable c) and c is automatically event casted to Cancellable
omg I just used gradle for the first time, its so much better than maven
not even latest, probs like j 14
oh thats nice
🧢
Instanceof pattern matching is beautiful
Hey Sir I think your folders are empty
a java 6 website
Naturally the best tool for websites
with .html at the end of the location href
also i actually got rid of the CancellableItem class since it felt useless as the interface had a callOnCancel bool
PowerPoint anime sounds amazing
www3.hypixel.art/cookie%20clicker.html
manga readers on bad wifi = powerpoint anime
My grandpas deck has no pathetic cards Kaiba, but it does have this. The unstoppable Bill Gates!
any chance I get @Dominick as my unique discord username
kekw
which one is it to remove fire damage only?
December 2015
Fire or FIRE_TICK
I swear to god Coll
You’ll want both
unique discord user?
if you take it out of spite
One is damage from standing in fire, one is damage from being on fire
Out of the fire and into the still fire
Choco how’s the dog
If you learned to play it with a real guitar maybe you wouldn’t be stuck as a computer programmer NERD
:(
stop bullying Choco >:(
How can I add more worlds in my minecraft server, not just the default one? programming side, not adding more plugins to the server. Thank you
I mean, I have my world created already, I just want to add them to my server in addition to the current ones on my server, like the worlds would all be: world, world_nether, world_the_end, and my_custom_world... how can I make it so the server would recognize the my_custom_world?
How could i change the server-propeties with my plugin?
You still use WorldCreator for this
