#help-development
1 messages · Page 2205 of 1
basically desetializing in spigot is nothing more than
Class<? extends ConfigurationSerializable> clazz = Class.forName((String) map.get("=="));
return clazz.getDeclaredMethod("deserialize").invoke(null, map);
well of course it's a bit different but this is basically the whole idea lol
yep
that's how it works internally
don't worry about it
getDeclaredMethod is a declared method in the class Class
lmao
That wasn;t for you @kind patrol
Class.class.getDeclaredMethod("getDeclaredMethod", ...);
lol
Every time I try and build a jar file for this project, for some reason the plugin.yml gets replaced by the plugin.yml of one of the plugins being used an external library. Like IntelliJ seems to be just created a duplicate of that plugin and I can't get it to not do that
you are shading the other plugin
<scope>provided</scope> on any dependency you don;t want included
No. I really don't understand shading. Is that what it does? Tells the compiler to ignore it?
are you using maven?
if not you'll have a bad time compiling ANYTHING that's using any libraries
Gradle
Yh I was worried
send your build.gradle
plugins {
kotlin("jvm") version "1.5.31"
id("com.github.johnrengelman.shadow") version "6.1.0"
}
tasks.compileJava { options.encoding = "UTF-8" }
group = "com.jaoow"
version = "1.0"
repositories {
mavenCentral()
maven("https://jitpack.io")
maven("https://libraries.minecraft.net/")
maven("https://repo.aikar.co/content/groups/aikar/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
dependencies {
compileOnly(fileTree("libs"))
compileOnly("com.mojang:authlib:1.5.21")
compileOnly("me.clip:placeholderapi:2.10.9")
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
implementation("co.aikar", "acf-paper", "0.5.0-SNAPSHOT")
implementation("com.github.Jaoow", "sql-provider", "1.3")
implementation("com.github.ben-manes.caffeine", "caffeine", "3.0.4")
compileOnly("org.projectlombok:lombok:1.18.22")
annotationProcessor("org.projectlombok:lombok:1.18.22")
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}```
Kotlin 😌
and what plugin's plugin.yml is included?
Buycraftx
but you didnt even define that as dependency?
It's a plugin hard dependency
I didn't write this but the jar worked before, I'm just fixing a bug for a server
hard dependency? you mean you added it manually? as its not in your gradle
are you actually even using gradle to compile, or are you doing some weird stuff in your IDE to compile it?
Yes, I added it manually. I haven't touched the original code, which had buycraft in the code but not in gradle
you cannot just add add some .jar file "manually" and then use your IDE to compile o0
Building artifact in intellij
that is the opposite of what's correct
you are using gradle, so you should actually USE gradle
Oh I figured it was. I'm used to maven which works with the IDE build thing
no that doesnt really work well too
you should always only use maven or gradle instead of the ide
Okay, thanks. I'll look into doing it properly through Gradle
I'm just confused tho. Like the original plugin worked and didn't mention buycraft in gradle
?notworking
oh yeah the bot is down
okay let me rephrase
"dont work" is the most useless description ever
all I can reply do that is "yes work"
and what is not working?
public static boolean affectsTopInventory(final InventoryDragEvent event) {
int minSlot = 999;
for (final int i : event.getRawSlots()) {
minSlot = Math.min(i, minSlot);
}
return minSlot < event.getView().getTopInventory().getSize();
}
public static boolean onlyAffectsPlayersInventory(InventoryDragEvent event, Player player) {
if(!event.getView().getBottomInventory().equals(player.getInventory())) return false;
return !affectsTopInventory(event);
}
no, it works 100% fine
yes
whut
how are you creating the "invsee" inventory
and did you test that on yourself?
then create a new inventory and copy the stuff from their inventory into that, and show that instead
or show your full code that you're using in the drag event
well you didnt say that it should automatically update
after all you said "invsee" and now "invopen" or sth
invsee sounds like "read only"
the FULL code
okay and what exactly are you trying to achieve now?
?
bro i'm tired. you have not even once mentioned what you are actually trying to do. do you want to prevent the player from putting stuff into their own inventory? do you want to prevent them from putting stuff into the others inventory? all you say is "I want to make it working" and "xyz is not working" but you simply don't tell what you want it to do exactly
no need to reinvent the wheel https://github.com/JEFF-Media-GbR/ArmorEquipEvent
Sounds like you need a better armor equip check.
Cause it should only fire when, ya know, you actually equip the armor piece instead of dragging it in the inventory.
and why are you calling the event manually then?
could delete the file
sigma
tamron
a doubt how you can upload a plugin as a dependency in intellij in eclipse it only uploads in properties but here I have no idea haha
maven
Im having a problem, I am looping through blocks in an arraylist, and for each itteration i select a random number, then get the corresponding color for it from the list, except instead of each block being different colors, its all the same, anyone have ideas? (code below)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
what is plugin.colorsDropper?
ArrayList with strings of colors
for (ItemStack i : rewardContents) {
if (i == null) continue;
chest.getBlockInventory().addItem(i);
chest.update();
}
Anyone know why this does not actually add an items? The i is not always null
couldnt it just be the actual chatcolor instead?
It looks like you only generate the random one time, try moving the Random generation into the else statement, probably inside of if (block.getBlockData().getMaterial() == Material.DROPPER)
@silent vigil ^
Hey Guys i have a problem: When i generate a new End World there is no ender dragon. If i spawn one right after generating the world no DragonBattle will be created, regardless of the Phase the Dragon is in
How are you generating the end world?
MVWorldManager.addWorld(name + "_the_end", Environment.THE_END, null, WorldType.NORMAL, true, null);
or without Multiverse:
World theEnd = new WorldCreator(name + "_the_end")
.environment(World.Environment.THE_END)
.generateStructures(true)
.createWorld();
And neither work?
I have a listener for the PlayerPortalEvent and when it fires i use event.setTo(new Location(Bukkit.getWorld(group.getName() + "_the_end"), 100.0, 50.0, 0.0));
Do you have essentials installed?
The world generates and i can use the Portal to get there, but the Ender Dragon wont spawn and if i spawn him with the plugin and set his Phase to CIRCLE he spawns and flys around but no DragonBattle will be created
No just my Plugin and Multiverse
Try spawning him with the plugin using the following code:
EnderDragon d = p.getWorld().spawn(p.getLocation(), EnderDragon.class);
((LivingEntity) d).setAI(true);
Let me know if that works
Ill try thx
Actually looking a little more into it that won't work, you'll have to use NMS to simulate the dragon battle
Yea I was reading more and realized it doens't actually work
Ah okay
For some reason when i use paper spigot 1.18.2 it creates a dragon battle for me, but not on paper spigot 1.19 or any other normal spigot version
And since it should run on 1.19 im kinda stuck
1.19 isn't very stable right now anyways
Chances are if you make the plugin for 1.18.2 it will be compatible with 1.19
So you should be fine realistically
It only works on 1.18.2 because of paper spigot, they have a config flag named "scan-for-legacy-ender-dragon" and it creates a Dragon Battle when a Ender Dragon and a Player are in the same World. But it doesnt work on 1.19 anymore
I tried they also have no idea how to make this work :c
I hate reflections ;-;
public static ItemStack recipeHolySword() {
ItemStack holySword = CustomItemsT2.holySword();
ItemStack magicPowder = CustomItems.createMagicDust();
ItemStack magicBlock = CustomItems.magicDustBlock();
ItemStack magicSword = CustomItems.magicSword();
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("holyswordt2"), holySword);
sr.shape("BWB",
"WSW",
"BPB");
sr.setIngredient('B', new RecipeChoice.ExactChoice(magicBlock));
sr.setIngredient('W', Material.WITHER_SKELETON_SKULL);
sr.setIngredient('S', new RecipeChoice.ExactChoice(magicSword));
sr.setIngredient('P', new RecipeChoice.ExactChoice(magicPowder));
Bukkit.getServer().addRecipe(sr);
return holySword;
}```
is there something wrong with this code? the recipe doesnt get registered in game and i dont get any errors either
wdym
I didn't know you could make custom recipes with exact choices like that I thought it was only with materials
yep, its in an init method whic gets called in onEnable
you can, ive done multiple recipes with it, this is the first one causin me an issue
seems abt right
maybe u cant add to the minecraft namespace
not sure
unless u did that before and it did work
i did do it b4
can you show others that worked ?
sure
public static ItemStack magicSword() {
ItemStack magicSwordItem = CustomItems.magicSword();
ItemStack magicPowderItem = CustomItems.createMagicDust();
ItemStack magicBlock = CustomItems.magicDustBlock();
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("magicswordt1"), magicSwordItem);
sr.shape("DBD",
"BGB",
"DBD");
sr.setIngredient('D', new RecipeChoice.ExactChoice(magicPowderItem));
sr.setIngredient('B', new RecipeChoice.ExactChoice(magicBlock));
sr.setIngredient('G', Material.WHITE_STAINED_GLASS);
Bukkit.getServer().addRecipe(sr);
return magicSwordItem;
}```
sure there are no errors?
yeap, checked multiple times, no errors
how do you call magicSword() in the magicSword function and not create an infinite loop
Hello. I am trying to use Protocollib and I cannot figure out why this happens. I was guessing that this server would help. I did some research and I find out that you need Spigot and Spigot API, which I dont know what spigot API is and I cannot find where to download it.
It wont let me upload image
where did i call magicSword?
first line
ah well, this magicSword() method is in a class called ItemRecipes, that one is the actual item in the CustomItems class
oh okay
https://paste.md-5.net/sanalukohe.cs send help
also are you sure that methods are called in the right order for the thing that doesnt work ? you're not trying to make a recipe for an item that is not yet defined ?
otherwise i have no idea
if that were the case, my other recipes wouldnt work\
how would i set durability now that its deprecated
which is why there is an else
I think you meant 16 not 18
oh shoot you're so smart
you can also do player.setHealth(Math.min(playerMaxHealth,playerHealth+4));
instead of the if else
@quaint mantle
Hey I'm trying to make a plugin that respawns the dragon egg if it is destroyed but I'm having issues detecting when it's destroyed
I have no idea if there's a way to know when an item dies from void in the end for example
@EventHandler
public void dragonEggDestroyed(EntityDamageEvent event) {
if(event.getEntity() instanceof Item) {
Item item = (Item) event.getEntity();
if(item.getItemStack().getType()==Material.DRAGON_EGG) {
Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
if(item.isDead()) {
Bukkit.broadcastMessage("§cDragon egg destroyed");
}
}, 1);
}
}
}```
Also for some reasons I get the message twice when the item is burnt in fire but only once for every other death reason
brutha i couldnt tell ya either ngl, im still very much new to java
it's okay I @ you just for the message with math.min
Is the dragon egg an item?
Items are the stuff you drop on the ground
Can u destroy the egg? I thought it tps away
Is there a way to set custom nbt in 1.19 with nms? I've searched for tutorials but they dont seem to work in newer versions
yes I'm taking about the dragon egg item
what are you trying to do
dragon egg can be an item if you get it in your inventory yes
just an idea, what if you check for when the dragon egg item is about to hit y level == whatever the level is where the void starts
yes I guess i'm gonna have to do that
use pdc
?pdc
ok
but it doesn't solve the fire issue
thats true
also if you're crazy enough you could throw the egg in the void, wait for it to be below y-64 and then fly and get it with your elytra to dupe it
would be extremely risky and difficult but theoricaly you could
You can kill it when you detect it's too low
cant u listen to entitydeathevent?
Thats only for LivingEntities
why tho
wont work nvm
but why can't we get the health of an item in spigot
like
an item has a health value in minecraft
so there must be a way to get it right ?
yes
they have 2.5 hearts
that's why it doesn't die instantly in fire
if I can access the health of items I'm done but idk how
check out NMS
as longa s you have a healthy layer of abstraction it should be easy to update too
I have no idea how that works
public static void recipeHolySword() {
ItemStack holySwordItem = CustomItems.holySword();
ItemStack magicPowderItem = CustomItems.createMagicDust();
ItemStack magicBlock = CustomItems.magicDustBlock();
ItemStack magicSwordItem = CustomItems.magicSword();
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("holysword"), holySwordItem);
sr.shape("BWB","WSW","BPB");
sr.setIngredient('B', new RecipeChoice.ExactChoice(magicBlock));
sr.setIngredient('W', Material.SAND);
sr.setIngredient('S', new RecipeChoice.ExactChoice(magicSwordItem));
sr.setIngredient('P', new RecipeChoice.ExactChoice(magicPowderItem));
Bukkit.getServer().addRecipe(sr);
}```
why doesnt this get registered as a recipe? no errors either
did you try to put sysout everywhere thunder ?
nope
well, the recipe is being registered, i added a sysout right after the .addRecipe
and if you do /recipe give @s * do you not get the recipe in the book ?
i have to manually add a bit of code to each method to register it in the recipe book no?
idk I thought that NamespacedKey.minecraft("holysword") did that
fixed it by friggin restarting my server lol
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:poisonblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:thunderdustblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:magicpowerblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:poisonblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:thunderdustblock removed now.```
https://paste.md-5.net/owagewuxiq.java
wtf
so.. apparently the 1.19 removed commons lang? sad :(
you should switch to guava
or shade in a more recent ver of commons lang3
i believe they announced that it would be removed in 1.18
in 1.18.2 it was still there
yeah they announced planned removal in 1.18
wat so StringUtils.replace no longer works?
😮
yeah one of my plugins broke cuz of that
gonna release an update now
Hello am I the only one since the 1.19 that has issues with colors in the server console or does this also occur to others just trying to find the issue at the Time?
anyone? im on 1.18.2 for reference
anybody know how I could run player.getNearbyEntities() in a thread? getting an exception b/c it's async
18.2 btw
i dont know how i'd be able to do that
why are you running it async?
I'm writing a plugin that checks every second for creepers
so I thought to use a timertask
?scheduling
Why though
bot down :(
you mean checks around a player every second for creepers?
I'm a noob ig
use bukkit runnables
The question is why do you want to find creepers around the player
but yeah why
Can't even ?xy 😭
lol
I'm deaf & cant hear the hissing, so im writing an enchantment that will make particles when theyre near
cuz i get bombed without hearing it
beep boop
https://xyproblem.info/
Asking about your attempted solution rather than your actual problem
Minecraft has the deaf mode that ads stuff for that
lol sorry
it does??
oh the chat thing
yeah but that has a lot of extraneous stuff
@undone axle when
I mean its not particles but it let's you know what's going on. If you really want to do particles whenever a creeper is nearby scheduling it would probably be the best way to do it.
so use BukkitScheduler & BukkitRunnable?
you mean when the creeper starts going expanding to explode?
yes
I thought it'd be a fun project to try, kinda like sting from LOTR/hobbit with orcs
BukkitScheduler?
how did you do your async task?
ok thx I'll try it
timertask and timer lol
scheduler & bukkitrunnables are the same its just preference
What is the difference between new BukkitScheduler and Bukkit.getScheduler().blah blah?
you mean new bukkitrunnable?
yes
Well if the creeper is about to explode isn't there an event for that?
brain damage
they are basically the same
one returns a BukkitTask and theother returns an int
basically the only difference
the int is the id
so it doesnt matter if I use one or the other
so both can be used to cancel the task
no but usually, i use the bukkitrunnable when i wanna cancel
and scheduler when i dont care
based
well yes, I don't want it to trigger when it's about to explode though, I want it to trigger when creepers are nearby, so I can get the hell out of dodge
since BukkitTask has a cancel method
Yeah, then just schedule every 20 ticks
awesom thanks
imagine not having a tick conversion method
u do?
yes
Why though. Math ain't that hard
its more time conversion but one of the methods is ticks 😛
if i wanna schedule every 15 mins i do 15*60*20
but it's easier to keep track of when u leave it like this
this method has been waiting to be written for 3 days
well the else statement
still not feeling like it
it's a 1 liner
ya
idk how the code looks just abt how well it runs
that else statement requires so much logic i swear
that's why ive been putting it off
i probably need to plan it out
yeah
unironically helpful
too lazy tho
get motivation
i'd rather just work on storing the data or something
myself
nah frick that
yes it does
someone today was having the same issue u were and i copy pasted the code to them
oh man
what’s ur spigot mc
mc?
imma make a tutorial and credit you
i mean it's hard to use
ok I got a new issue lol
so my current solution is that I have a PlayerJoinEvent listener which then schedules the sync task, passing in the player to the method that checks for creepers
the error i'm getting is Could not pass event PlayerJoinEvent to SoD_Plugin v1,1.0
org.bukkit.event.EventException: null
oh
that's a weird error
actually it isnt
change new BukkitRunnable
to new Runnable
and it'll be fixed
^^
giving it a shot
what is the difference here?
u cant use the scheduler with a bukkitrunnable idk why
only runnables
seems to be working, i think i set it to 1K ticks tho lol cuz i was thinking ms
so I'll try again
20 ticks = 1second
how would i format a time duration in milliseconds
like 62340 ms would be 1 hour, 2 minutes, etc.
public String format(long value) {
int seconds = (int) (value / 1000) % 60;
int minutes = (int) ((value / (1000 * 60)) % 60);
int hours = (int) ((value / (1000 * 60 * 60)) % 24);
int days = (int) ((value / (1000 * 60 * 60 * 24)));
String time = "";
if (days != 0)
time = days + " day" + (days == 1 ? "" : "s");
if (hours != 0)
time = time + (time.equals("") ? "" : " ") + hours + " hour" + (hours == 1 ? "" : "s");
if (minutes != 0)
time = time + (time.equals("") ? "" : " ") + minutes + " minute" + (minutes == 1 ? "" : "s");
if (seconds != 0)
time = time + (time.equals("") ? "" : " ") + seconds + " second" + (seconds == 1 ? "" : "s");
if (time.equals("")) {
time = value + "ms";
}
return time;
}
Lol formatting date/times gives me the ick
It's working! Just need to play with particle concentration & frequency til I'm satisfied
Thanks for helping! New to spigot plugins. Learned something new today
np
what 2 emojis do servers use to display progress bars
theres this one emoji which is like a shaded box and another emoji which is partially shaded
thanks
i did it
it took me 10 mins
wasnt even hard i was jus toverthinking it
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:poisonblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:thunderdustblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:magicpowerblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:poisonblock removed now.
[23:08:59] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:thunderdustblock removed now.```
https://paste.md-5.net/owagewuxiq.java
wtf
its not an error
just do /rl
is that the same as reload
mood tbh
well, it didnt register after reloading multiple times
Hello anyone can help me since 1.19 i don´t get any Color in my Console anymore - Not really a big issue but sad and a bit hard to identify Plugin info from other info in Console.
Using this tried also ChatColor but changes nothing.
The §4 and §b is getting removed but the Console stays Black and White except Warnings and Errors or do i do something wrong here with the new API?
Bukkit.getLogger().info("§4" + "-----------------------------");
Bukkit.getLogger().info("§4" + "|" + "§b" + " Started Plugin " + "§4" + "|");
Bukkit.getLogger().info("§4" + "-----------------------------");
Whats the best way to save data (like items and inventories)?
long-term storage or shortterm
you could do config-serialization of Items in an inventory
than just reiterate to put them back into the inventory
idk if its the "best" way persay but its a way to achieve the goal that does what its supposed to in a good manner
Kody Simpson has a solid video on it
Anyone know how to cancel a Respawn Anchor's explosion?
declaration: package: org.bukkit.event.block, class: BlockExplodeEvent
ma boy
nvm i thought you wanted something different :kekw:
public void RightClick(PlayerInteractEvent event){
if (event.getAction() == Action.RIGHT_CLICK_AIR){
Player player = event.getPlayer();
player.sendMessage("Air right clicked");
}
}
why does this not work?
did you register it?
in the main class?
and annotate it?
public class RandomFun implements Listener {
@EventHandler
public void BlockPlaces(BlockPlaceEvent event) {
Player player = event.getPlayer();
Material type = event.getBlock().getType();
if(type == Material.DIAMOND_BLOCK) {
int XCoord = event.getBlock().getX();
int YCoord = event.getBlock().getY();
int ZCoord = event.getBlock().getZ();
player.sendMessage("X = " + XCoord);
player.sendMessage("Y = " + YCoord);
player.sendMessage("Z = " + ZCoord);
}
}
public void RightClick(PlayerInteractEvent event){
if (event.getAction() == Action.RIGHT_CLICK_AIR){
Player player = event.getPlayer();
player.sendMessage("Air right clicked");
}
}
}
should be
first one works
second doesn't
Oh, I need one per method?
Try it and see
still nothing
tried logging?
you mean checking logs?
i mean, it just tells me it loaded the plugin and thats all
no errors or anything
[08:10:32] [Server thread/INFO]: Using default channel type
[08:10:33] [Server thread/INFO]: [Plugin1] Loading Plugin1 v1
[08:10:33] [Server thread/INFO]: Preparing level "world"
[08:10:33] [Server thread/INFO]: -------- World Settings For [world] --------
adding logging to your method to see if it's firing.
Huh. I fixed it in a way
I need to right click with an object in my hand
if i right click the air, with nothing my hand it won't work
pretty interesting
Probably because the client doesn't send a packet unless you're attempting to right click with an item.
That was my thought too
right clicking with nothing, into nothing has an output of nothing
but if you right click with an object in your hand i guess you're doing something
how can i reset a config file?
Delet it
how?
ok this single line?
does it has to be in the main class?
So if it's outside ur main class replace with plugin instance
For?
Also when u save it back, u will have to reload the config
so save it?
oh okay thx
And if you have the config variable stored anywhere update it with the new plugin.getConfig since the config instance it has is outdated
okay
Not 100%sure if this is necessary but won't hurt to do
U can also test if it's needed
this produces an error because it does not found the file why ever...
this is the error
Can i also give the exact path there?
I think it's reading the "config.yml" file from your jar file, did you pack the config file into your jar file?
no
it looks like this
i think i know what the problem is but should i just rename the jar file?
if your config file is not in the jar file, rename your jar file may not work
yes because it searches for a jar file in the path... this is the problem
but how could i change this?
okay i did it nevermind thx for the help 🙂
i have another little question why does the player.sendTitle() function not work sometimes... it is crossed out
check the event for a player getting damage
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
there you go...
SaveDefaultConfig()?
it works now thanks
but do you know why i cant use the sendTitle() method sometimes it says it is deprecated
How could I start making the following:
When you break a block, TNT spawns and launches itself upwards as a cool effect?
how to use minepacks plugin command without op
bro you have to figure it out yourself this is to complex to explain
what is minepacks?
how can i stop a specific bukkit runnable?
Any ideas on how to check for the health of an item?
You can't use gethealth on an item entity because it's not a livingentity
But it still has health
its under Player not Entity
Detect teh Block break in the event, then use teh Spawn method which accepts a Consumer adn set teh velocity of the PrimedTNT.
e.getEntity() returns and Object, Cast to Player
((Player) e,getEntity()).spigot().sendMessage
cast its meta to Damageable
There is a damageable for Entities and for meta
put it in the correct place in yrou code
Which event are you using?
yes, but its ok, I looked at your code
Item is not a subclass of damageable
Works fine ```java
@EventHandler
public void test(EntityDamageByEntityEvent event){
if (event.getDamager() instanceof Player player) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Test"));
}
}```
ItemMeta
for not Java 16 ```java
@EventHandler
public void test(EntityDamageByEntityEvent event){
if (event.getDamager() instanceof Player) {
Player player = (Player) event.getDamager();
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Test"));
}
}```
wrong ping sorry
can you add direction for damage?
yes, because i have this right now which works
@EventHandler
public void BreakBlock(BlockBreakEvent event){
Material type = event.getBlock().getType();
Player player = event.getPlayer();
if(type == Material.GRASS_BLOCK){
player.damage(1, player);
event.setCancelled(true);
}
}
is there a way to implement a sense of direction?
apply a velocity to the player
you want to push the player away from the block?
yes
i tried this, but it didn't work how i wanted it to
and what exactly didnt work?
Then, yes as mfnalex said, calculate teh Vector from teh Block to teh Player and apply as a Velocity to the Player
teh
blockVector.subtract(playerVector).normalize()
Ohhh, thank you!
You should see me on a bad day
and then apply that to the player
I think you misunderstood I mean item entity health not durability
twice though
Item Entity?
You mean a dropped Item? That has no health
a Dropped Item is there or its not
a dropped item has 2.5 hearts
no it hasn't. Only LivingEntities have health
bit unrelated to spigot, but in java is there a way for the class to know what line that bit of code is running
it seems unlikely but you never know
dropped item is not living
yes, you can create an Exception and then get the StackTraceElements
a dropped item doesn't have health in spigot but has health in minecraft
it does not have health
ah right ok
so it wouldn't be viable as a debug message
?
to show the class and line of code
LinkageError error = new LinkageError();
int currentLine = error.getStackTrace()[1].getLineNumber();
you don't have to throw the error
just create it and get the stacktraceelements
not sure if [1] is correct
it will be either [0] or [1] or [2]
an item has health
event.getBlock().getLocation().toVector();
this changes the blocks location into a vector?
a dropped item doesn't have health in spigot but has health in minecraft
nevermind lol
int lineNumber = Thread.currentThread().getStackTrace()[3].getLineNumber();
apparently it's 3
yes since essentially a location is a vector with extra info
that vector is a position vector, it does not have direction or anything
isn't that the line number of the code that called your current method?
well just print out the stack trace and see for yourself
ahh alright
yep
when you call toVector it gives you a vector object that has the x,y,z position
yes
ok thx a lot
Since it's not part of the api you will have to access it with NMS
___8drrd3148796d_Xaf
if you put it into a separate method, it's [2]
public static void main(String[] args) {
System.out.println("Current line number is " + getCurrentLineNumber());
}
public static int getCurrentLineNumber() {
return Thread.currentThread().getStackTrace()[2].getLineNumber();
}
if you "inline" it into your code, without a separate method, it's [1]
does someone have a sheet which RGB values vanilla potions use?
because apparently vanilla potion's PotionMeta's getColor returns null
Depends on your version
1.19
thanks
so yeah either [1] or [2] depending on how you do it
can't seem to get a players vector
player.getLocatino().toVector()
nice
the difference?
im creating a debug logger but i'm not sure if bukkit displays these
without modifying the log4j2
isnt it info and above or something
Hello guys.
My question : I want to deploy 1.17+ NMS dependencies on a private artifactory (artifactory is a dependency repository like maven central, nexus, jitpack, ...).
Context :
I'm a benevolent in an association where 9 developers works mainly on spigot plugins.
Some projects of our association uses NMS version dependent code. In such case, we usually have to get all required dependencies.It means EACH developer have to locally execute buildtools on EACH NMS version for spigot. Then the same must be done for paper.
I want my association's developers not to have to locally install each paper/spigot versions required. I want them to be able to download those automatically from our private artifactory.
Legally no
mhm
in a private repository, no problem
I do the same
just make it password protected lol
Still legally No. As its not private, it is shared between your devs.
is there a way to print [DEBUG] instead of [INFO] i the console
any help on how i can get a vanila potions color based on the fact that PotionMeta returns null for vanilla potions?
Really private is fine
who is gonna sue you if noone else can access it
When one of those devs falls out with you
well hosting providers are even distributing spigot to all their customers and noone was ever sued for that
If one of those devs has a hissy fit, he will be the one left in teh firing line for making it available.
Yeah, I'm not talking about what has happened. I'm talking about facts and what CAN happen.
everything is always spelt perfectly except "the"
Ok then, what should I do to make the installation process easier ?
Today is a good day 🙂
tell them to simply run
for version in 1.19 1.18.2 1.18.1 1.17.2; do java17 -jar BuildTools.jar --rev $version --remapped; done
once
Vector blockvector = event.getBlock().getLocation().toVector();
Vector playervector = player.getLocation().toVector();
blockvector.subtract(playervector).normalize();
player.setVelocity(blockvector);
this pulls in the player towards the block
if you want the opposite flip the vector
yes yes I know thank y
but my question is why do you subtract the players vector?
to get the difference
and normalizing it gets you the direction
from player to block
then switch blockvector and playervector
or multiply it with -1
If you subtract one from the other and get teh wrong direct, reverse it and subtract the other way around
its getting worse
yes thanks
oh yeah fuck mornings, I need coffee
I forgot to set my coffee machine to 11 am yesterday
now I have to get up and start it manually
hmm
ow, yea thanks
shes sleeping
isn't geometry / vector stuff taught in school where you are from?
no
damn
the only vector i know is from my computing class
I really liked the topic back in school
which is an image used from a mathemetical formula
yea i didnt rlly get tought either
where if u zoom in it stays good quality
very sadge
oh and in physics
well yes kind of i guess then
it's similar to an MC vector but not exactly
it's a quantity with a magnitude and direction
MC vectors aren't that hard tho
position / direction
a vector is a direction with a magnitude
yes
no
eg
they don't. but imagine you have two locations:
50 | 100 and 52 | 102
then you can get the difference in those locations
which is 52 - 50 | 102 - 100 so it's 2|2
so to get from 50 | 100 to 52 | 102 you need the vector 2|2
yeah it's actually totally easy unless you try to learn it from wikipedia lol
you add 2 speed and 2 "direction"
and then you get pulled in
am i understanding it right
I think you rather set his velocity to that specific direction
blockvector.subtract(playervector).normalize();
so in this line
normalize is to turn the vector to a length of 1
why would you do thise
normalize basically means "only the direction"
if i didn't normalize what would happen
then you would get faster the more distant the locatinos are
the vector would have another length
hi, is there a way to get the server's jar file? something like spigot-1.19.jar , ive found
new java.io.File(SomeClassInYourJar.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath())
online but it gets the plugin file
that doesn't change
let's assume the arrows were parellel. if that would be the case, then the lower vector would be basically "twice as fast"
but same direction
a normalized vector is a vector where the length of the arrow is one
so you can easily set a speed by multiplying the vector, without changing its direction
do it for Bukkit.class instead of SomeClassInYourJar.class
exactly
for example the direction from 0|0 to 2|2 is the same as the direction from 0|0 to 200|200. but the first vector has a small length and the second one has a huge length. normalizing both would return in the same vector, which would be roughly 0.7|0.7
a bit closer, but it seems that its getting the maven dependency, any idea?
because sqrt(0.7^2) = 1 (pythagoras)
oh yeah because it's split up into different .jars
for example if you are trying to move 5 units in the direction of the point
normalize the vector 1|1 (gives you about 0.5|0.5)
if you multiply 0.5|0.5 by 5 units
only thing you could try then is to get a file out of the bootstrap .jar then
you will move 5 units in the direction of the red point
try to use org.bukkit.craftbukkit.bootstrap.Main.class
DESMOS 🤩
we love desmos
is that nms
no, thats obc
nms starts with net.minecraft.server 😛
obc starts with org.bukkit.craftbukkit
hence why it is called nms
cant find it with spigot-api as dependency
you have to use spigot
no idea whats obs lol
kind of like nms then i guess
CraftPlayer, CraftEntity, CraftLivingEntity, ...
CraftBukkit provides the implementations for the BukkitAPI and wraps around NMS
CraftPlayer implements Player and wraps around NMS Player
it's basically the "middle thing" between vanilla MC and Bukkit API
so in a way bukkit is a fork of craftbukkit?
vanilla MC is the cocaine farmer in south america, craftbukkit is the dude who smuggles it to your country and Bukkit API is your local drug dealer
no. craftbukkit is the implementation of bukkit
you farm cocaine?
hmm i think i understood it better
only when neccessary
e.g. if my local drug dealer doesn't have it
no as in is farming of cocaine the correct verb of producing cocaine
for example to send totem animations, I have to farm the cocaine myself
i thought it was like cooked
but to send a message to a player, I can use my local drug dealer
like meth
honestly this flew over my head im just gonna remember the cocaine example lmao
Now i'll try use what you told me into making it so when a hoe is rightclicked i fly upwards
not upwards
in the direction i'm facing
alex make blog post on vector
yes you are a literal maths genius
how can i check the block a player is walking on?
if you check out bukkit, you'll see that everything is only interfaces. it doesn't do anything. CraftBukkit provides the actual code that does something.
Player in Bukkit defines what a player can do.
CraftPlayer in CraftBukkit defines HOW exactly a player does something, by saving the NMS player in some field and basically translating the Bukkit calls to vanilla MC code
get the player's location, subtract it by 1 on the y axis and get the block from that
^
is there no event for it?
what event
yeah
there is an event for when a player moves
unless you mean PlayerMoveEvent
ohhhhhhh, no wonder when i view Player all i get are interfaces
The code the error is facing to:
getData().set("Players." + player.getName() + ".Rank", "default");
The error:
java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.set(String, Object)" because the return value of "neonowlgery.**************.core.managers.SQLiteManager.getData()" is null
Question: I am the upmesser, or did the API got autism or something? I mean... it actually should be correct, because on other projects, it worked fine, but now, for some reason it just doesn't wants to work, while the codes are the same.
yep. to see the underlying code, look at CraftPlayer
maybe there is a playermove event where you can get the block he is moving on....
this was my question
yes, PlayerMoveEvent
on PlayerMoveEvent do this
then subtract one from the player's location's Y and get the block
Hey,
Does anyone know what ProfilePublicKey is for?
Found this in the consturctor of EntityPlayer
neonowlgery.**************.core.managers.SQLiteManager.getData() returns null
so make getData() return sth else than null
it returns cuudconfig in the code
Player p = event.getPlayer();
Location loc = p.getLocation();
Block below = loc.subtract(0,1,0).getBlock();
Like in every other one
then cuudconfig is also null
idk, I can't magically see your code
to detect right click with hoe we use playerinteractevent in the method?
or is there something else i can use
yes
then check if the action is RIGHT_CLICK_BLOCK or RIGHT_CLICK_AIR
and if the item in use is a hoe
and how can i get the block then?
yep, thanks
public static void setup() {
file = new File(Bukkit.getServer().getPluginManager().getPlugin("pluginname").getDataFolder(), "Data/CUUD.yml"); // this is where the file is saved, which is successful
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
cuudconfig = YamlConfiguration.loadConfiguration(file);
}
}
public static FileConfiguration getData() {
return cuudconfig;
}
public static void save() { // this saves the file, and after that, it needs a reload, which is competed by the static reload event
try {
cuudconfig.save(file);
} catch (IOException e) {
System.out.print("§cA plugin nem tudta menteni a CUUD fájlt.");
e.printStackTrace();
}
}
public static void reload() {
cuudconfig = YamlConfiguration.loadConfiguration(file);
}
@near crypt
i want an event bro
yes put that code inside PlayerMoveEvent
erm why do you call this SQLiteManager if it only handles YAML files?
have you called the setup() method at all?
no
the data inside it cannot be modifyed for some reason
you only set cuudconfig if the file didnt exist
when the file already exists, you never assign any value to cuudconfig
your code:
if (!file.exists()) {
...
cuudconfig = YamlConfiguration.loadConfiguration(file);
}
as I said
with the same code.-..
you only load the file if it didnt exist
this makes no sense
you should also load the config when the file existed
How i can reactivate a inactive entity? (entity-activation-range) with code?
cuudconfig = YamlConfiguration.loadConfiguration(file); should be OUTSIDE of the if(!file.exists()) body
it is outside of it
actually
but since my account is not activated here, i cant send images
bro
it's not
I have literally copy pasted your code
and replaced the try / catch with ...
this is exactrly your code
if (!file.exists)) {
...
}
cuudconfig = ...;
thats how it something looks like
no...
...
yes lol
like this, it'd be correct
next time i guess i should use the save and the reload event when creating that file...
Ctrl+Alt+L automatically fixes the intendation, then it'd be easier to see
in intelliJ
toosad i use eclipse
Since PLAY_ONE_MINUTE is returning ticks... Does TIME_SINCE_DEATH return ticks as well?
np
I don't think so, because the javadocs explicitly state this for PLAY_ONE_MINUTE but not for TIME_SINCE_DEATH
but just try it out
oh wait
it's TIME_SINCE_DEATH
yeah then it's probably ticks
I can't since there are a lot of changes I must do before I be able to build the plugin 😂
Lots of changes!!!
well you could just do a tiny plugin that prints the TIME_SINCE_DEATH every second in the chat
to find out
I assume it is ticks and after I finished I'll check it while debugging
whut?
nevermind
Just have to add a todo
I can just use material
i wanna set an itemframe with an item in it and some more nbt, how can i do this? ^^
if i have an arraylist in a local scale like this ```java
ArrayList<UUID> targets = new ArrayList<UUID>();
does anyone know why it lets me use elytras? it should prevent me from equipping elytra
public void noElytra(InventoryClickEvent event){
if (event.getClickedInventory() instanceof PlayerInventory){
if (event.getSlot() == 6){
Bukkit.getScheduler().runTaskLater(plugin, () ->
{
if (event.getWhoClicked().getInventory().getItem(6).getType() == Material.ELYTRA){
event.getWhoClicked().sendMessage(ChatColor.RED + "You can't use elytras!");
event.setCancelled(true);
}
},2L);
}
}```
cast the ENtity to ItemFrame and then you can set the contents
how can i find the direction the player is looking at?
if you want to check equipping armor, use my ArmorEquipEvent
example? dont understand it, sry
it doesn't exist
I sent you a link
declaration: package: org.bukkit.entity, interface: ItemFrame
guess no
Anyone knows why the first time I export my plugin after restarting my pc it's like it's not shading the gui library I'm using?
Caused by: java.lang.NoClassDefFoundError: me/minesuchtiiii/trollbossplus/gui/guis/Gui
Depends timinator
it'll get eventually GCed if it's just a local var
If it gets passed to an instance field or returned and cached it might not be gc’d
If I export a second time and restart the server it works
But if you just use it as a temp list it will surely get enqueued once unreachable
send your pom.xml
its in a bukkit runnable to not apply potion effects to the same entity more than once
during the execution
Mind showing me the code?
sure but its still nasty
well it doesnt really change and all i need it for is the getname ,ethod
why doesn't this work? it does nothing
event.setCancelled(true);
}```
Send the entire logger class
its too long so i dmd u the msg as file xD
well its slightly broken rn
one sec
just undoing the changes and sending a paste
?paste
nvm
anyone?
?paste
did you register the listener?
ups
ArmorEquipEvent.registerListener
yes
most of it's from maximvmdw's logger class i'm just adapting it
:/
oh
print out the new armor piece in the event and see what it says
No
oh
What’s a manager?
just accessible through a getter in the plugin instance
plugin.getCustomLogger().blahblah
That’s a weird definition of a manager
Then an int could also be a manager technically xD
But remove the static
?paste
How do I increase the speed of the velocity ?
Vector direction = player.getLocation().getDirection();
player.setVelocity(direction);
done, but how will i access it from nonstatic places now
?paste
nothing there should be static
paste is dead?
Depends on what places
Let me check the paste cmd rq limpeex
so now i can just plugin.getLogger.blahablh
rip
Yep
Is there a different way to register the event because it's not in the default spigot events?
@sacred mountain but anyway if you need to access it statically then
MainPlugin.getInstance().getLogger() or sth should be fine
ok
where getLogger is an instance method of your main class
yes
is it bad practise to have a static instance of your plugin defined on startup
To some extent yes
to only use in case of static needed stuff
i know how to dependency inject and avoid static abuse mostly now
so as long as i dont abuse that then i think it should be ok
Static should by convention only be used for constants, stateless and arguably pure functions
(Utility functions, helper functions, factory functions)
I mean - did you do ArmorEquipEvent.registerListener?
you have to do that, and then also register your own listener
@Override
public void onEnable() {
ArmorEquipEvent.registerListener(this); // Registers MY listener that CALLS the event
getServer().getPluginManager().registerEvents(yourOwnListener, yourPlugin); // Registers YOUR listener that LISTENS to the event
}
you need to do both @harsh totem
i wanna learn kotlin
Hello, I am trying to make a duel plugin. When a player enters a command, they will enter a duel with another player and fight. If one of them dies, the match will be over, and if both do not die within the specified time, it will be a draw. However, in a way that I don't understand, sometimes some processes do not work, for example, if I use the command once and then use it again, it appears that it is a draw even though someone dies. Here is the paste. https://paste.md-5.net/wixicewata.java
Epic
yep
i'm done with npe's
so my math classes and stuff can be static
lmao i just sout every possible variable and see what happens
true developing
Minion well you can avoid npes in java as well by using good practices
i barely get em
how do i create an itemframe object?
but sometimes it just happens
World#spawnEntity
should i do INSTANCE = null; in the onDisable or is it redundant
It is probably redundant
aight
Provided that the class that contains the static variable gets unloaded
Which it should if no other plugin keeps referencing that plugin instance
yeah mk
Like generally speaking, static doesn’t get garbage collected, but class loading makes it possible
something like this?
yee, but how to inicialise an itemframe object in java? ItemFrame itemFrame = ???
Yeah lombok sucks
@tender shard ok thank you
ItemFrame itemFrame = (ItemFrame) world.spawnEntity(...)
your instance shouldnt be uppercase anyway
because it's not static final
