#help-development
1 messages · Page 1703 of 1
yeah so actually i dont think post the issue here will help, especially after we flooded all the chat :madman
The inv in this method is the inventory which is a final type variable and is public
@Override
public Inventory getInventory() {
return inv;
}
``` I need to use p.openInventory(ResourecpackSelection.getInventory()) to open this in the event class but it gives error and says make the public Inventory to public static Inventory
i think im gonna post it on spigot too lol
Did you TRY it?
@carmine nacelle
Hey guys working on spigot ATM and need a opinion. If BlockDispenseArmorEvent's itemstack is changed would you guys want it to be called again with the new itemstack or would you rather that it only call the event again if the dispense behavior is different from that of the original item
:madman:
@quaint mantle try it, guarantee it works.
@carmine nacelle @carmine nacelle @carmine nacelle
@sharp kelp ya know stop being a little annoying will help you alot
Imma wait.. okay
dont use the meme age lol
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.
Ok so now you have 3 classes.
- Main class
- Inventory class
- event class
right...?
To avoid having multiple instances of the inventory class, you would want to reference it from where it's already being created the first time.
so you'd have the constructor in the event class, same as the inventory class, passing the main into it.
@sharp kelp
@quaint mantle try it yet?
in progress
ok
This has some haste as im making the last changes to it ATM
What do you mean if its itemstack is changed?
yeah nothing really work out, exept i just realized something
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "org.bukkit.configuration.file.FileConfiguration.getString(String)" is null
at com.risingcore.events.onDeathRespawn.onRespawn(onDeathRespawn.java:64) ~[?:?]
[?:?]```
What's on line 64?
if (locationsData.getCustomConfig().getString(locationName + ".world").equals(p.getWorld().getName())) {```
But im stuck on a design decision would it be better to call the event again if the dispense behavior is different (Think item vs armor) or to call the event every time the itemstack if different from the one that called the event
yeah because the locationName dont work
so it is null
and that's make me think the loop dont work with the locationName
Why doesn't it work?
i have no idea
I'm not sure, someone else might
Print the values it's getting
Spigot API changes
:>
already from the start
well you havent sent me them
so idk whats giving
oh
thats not what I mean
print them at the start of the for
for (String locationName : locationsData.getCustomConfig().getKeys(false)) {
// Print locationName here
if (locationsData.getCustomConfig().getString(locationName + ".world").equals(p.getWorld().getName())) {
sorteddistance.put(p.getLocation().distanceSquared(locationsData.getCustomConfig().getLocation(locationName)), locationName);
}
}
public static Inventory inv;
private setup main;
public static Boolean trigger;
public ResourcepackSelection(setup main) {
inv = Bukkit.createInventory(this, 9, "Downloading Resourcepack...");
load();
this.main = main;
}
@SuppressWarnings("unused")
private void load() {
ItemStack item;
List<String> lore = new ArrayList<>();
// lore.add("§7Example Lore");
new BukkitRunnable() {
int slot = 0;
@Override
public void run() {
if (slot<8){
ItemStack item = createItem("", Material.BLACK_STAINED_GLASS_PANE);
inv.setItem(slot, item);
slot++;
} else {
trigger = true;
this.cancel();
}
}
}.runTaskTimer(main,0,10);
}
private ItemStack createItem(String name, Material m) {
ItemStack item = new ItemStack(m, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
item.setItemMeta(meta);
return item;
}
@Override
public Inventory getInventory() {
return inv;
}
So I made multiple edits
First I changed private final Inventory inv; to public static Inventory inv;
Then Instead of how the tutorial did by making a small method with return value of inv I directly used the variable inv in the event
Will this work?
If i want to do something every tick to all players is it better to use Bukkit.getOnlinePlayers() or should i have a collection and just add player when they join
replace done
Just use getOnlinePlayers.
looks ok at a glance.
Send me what it gives
vivian is busy, like very busy lol
nothing even work at the start :madman:
[INFO] .... Firminus issued server command: /kill
[INFO] .... Firminus fell out of the world
[INFO] .... [Firminus: Killed Firminus]
[INFO] .... Firminus issued server command: /gamerule doImmediateRespawn false
[INFO] .... [Firminus: Gamerule doImmediateRespawn is now set to: false]
[INFO] .... Firminus issued server command: /kill
[INFO] .... Firminus fell out of the world
[INFO] .... [Firminus: Killed Firminus]
[INFO] .... Firminus issued server command: /gamerule doImmediateRespawn true
[INFO] .... [Firminus: Gamerule doImmediateRespawn is now set to: true]
[INFO] .... Firminus lost connection: Disconnected
[INFO] .... Firminus left the game```
it's not outputting anything to console?
man this is so sick LOL
nothing happens
yeah almost like that config structure doesn't work
than just some others events i already set
like ive been trying to say
man yaml file is suck, now im gonna change the structure to see
so... do this
holos:
Test:
location: world, -337.9180889181425, 72.0, -446.26819453769014
owner: e42b60b0-c35a-462f-a2b4-b1a9980f399e
lines:
- '&cTest 1'
- '&cTest 2'
- '&cTest 3'
- '&cTest 4'
this is how I have my config setup.
except it would be locations instead of "Test"
yea
so it would be
locations:
Location1:
blahblah
Location2:
blahblah
Location3:
blahblah
i have no idea why adding another line of "locations" means everything work LOL
but
let me test it
ok so
the "another line of "locations""
is a configurationsection
its a starting point for the loop to start at and loop through the things inside it.
just try it
if im wrong then u can make fun of me lol
but im not, so just try it if u want my help
im gonna suicide if adding another line work :v
should I get the hotline # for you then?
well you cant just change the config, you have to change the saving/loading code too.
already
im not bad
so is it working then?
:hehehe-face:
hahaha i lied to you
?
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player p) {
if (!sender.hasPermission("risingcore.spawnsystem")) {
return true;
}
if (args.length == 1) {
String locationName = args[0];
if (locationsData.getCustomConfig().contains("locations" + locationName)) {
}
locationsData.getCustomConfig().set("locations" + locationName, p.getLocation());
locationsData.saveCustomConfig();
return true;
}
return true;
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("messages.console-execute")));
return true;
}
nothing change __(:/)__/
let's export it again
yep
re-export and delete the config again
ah fuck
ok
you need..
if (locationsData.getCustomConfig().contains("locations" + "." + locationName)) {
need the dot between so it goes to a new line and stuff for formatting
same for the setter
ahh shiet here we go again
yup here we go again
basic stuff
yeah would work but i use locations., but nothing matters anyways let me test it
send ur config again
ik it didnt change or whatever but idc
send it
it might already be formatted that way, i dont remember cause u refuse to send it
ok you dont need the dot
its already formatted fine
but you should have
lied again, you do need the dot still
Firminus:
==: org.bukkit.Location
world: world
x: -4.9501626474914575
y: 71.0
z: -255.56610549926532
pitch: 46.04815
yaw: -80.76631
lol
now were getting somewhere.
ur reaction are very l0l
ok send the respawn thing
for (String locationName : locationsData.getCustomConfig().getConfigurationSection("locations.").getKeys(false)) {
System.out.println(locationName);
}```
its 7:30 am ive been up all night coding and dealing with children
that girl?
it is 6pm for me, asian time 😄
800-273-8255
👌
yeah spigot just suck
now add back the other code to teleport
i dont know why it have the getKeys but it cant use in getconfig, need to be after the configurationsection
for (String locationName : locationsData.getCustomConfig().getConfigurationSection("locations.").getKeys(false)) {
if (Objects.equals(locationsData.getCustomConfig().getString("locations." + locationName + ".world"), p.getWorld().getName())) {
sorteddistance.put(p.getLocation().distanceSquared(locationsData.getCustomConfig().getLocation("locations." + locationName)), locationName);
}
}
String locationName = sorteddistance.values().toArray()[0].toString();
e.setRespawnLocation(locationsData.getCustomConfig().getLocation("locations." + locationName));```
to ensure that it is what we are talking about, im gonna send it here
i might be wrong but in yml you can have...
setting1: test
setting2: test2
setting3: test3
setting4: test4
because they're all completely separate, whereas to have nested items such as locations, you need to have it in tree format.
get rid of your "object" crap
REEE
if (locationsData.getCustomConfig().getString(locationName + ".world").equals(p.getWorld().getName())) {
REEE it dont matters man maybe it is better lol i can see it more clearly
this is your line 2 of for loop
all the Objects is doing is converting it to a format that its not getting the error on
so?
discord just crashed that was a neat party trick.
but at least i dont think it would not work, and for me it looks cleaner to put them in that
back
why do you have that ==: thing?
LMAO
I always see people having something like that in the config
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
== means its a class
that is the default if you use location to save
ooh ok
for (String locationName : locationsData.getCustomConfig().getConfigurationSection("locations.").getKeys(false)) {
if (Objects.equals(locationsData.getCustomConfig().getString("locations." + locationName + ".world"), p.getWorld().getName())) {
sorteddistance.put(p.getLocation().distanceSquared(locationsData.getCustomConfig().getLocation("locations." + locationName)), locationName);
}
}
String locationName = sorteddistance.values().toArray()[0].toString();
e.setRespawnLocation(locationsData.getCustomConfig().getLocation("locations." + locationName));```
this is the code that supposed to work right?
delete the for loop except sorteddistance.put(p.getLocation().distanceSquared(locationsData.getCustomConfig().getLocation("locations." + locationName)), locationName);
you dont need the for loop
you can just do... config#getLocation
what do you mean by it .-.
Yassevzriona
only 1 what
not every location objects
ok so you could do
getHoloConfig().getLocation("locations" + "." + locationName);
this, except with your config name ofc.
yes man, which i mean locationName is what i need, that's why the for loop exist lol
i have just found a way to create a plugin, and now i have the plugin all setup with the plugin.yml and the main java but now i don't really know how to add stuff to it, can someone maybe show me any examples on how to add cool stuff to it? since i just started, i think it would be great if it was simple like maybe adding my own command that does something cool?
u can do that if u see that looks cleaner to u tho, but
"locations."
brain.exe not responding
I recomend you google. Its how i started.
okie
Oki vivian Imma wait but use the threads to reply to m
What is "sorteddistance" anyway?
nothing really special, that is normal with a man who needs to code and dealing with fake child girl through nights.
does it teleport you to the nearest spawn?
public Map<Double, String> sorteddistance = new TreeMap<>();
so is it to get the closest spawn to the player?
yea
ive never used treemap...idk how its different from hashmap, but
sort
It uses a comparator to store stuff
for (String locationName : locationsData.getCustomConfig().getConfigurationSection("locations").getKeys(false)) {
// Print locationName here
if (locationsData.getCustomConfig().getString(locationName + ".world").equals(p.getWorld().getName())) {
sorteddistance.put(p.getLocation().distanceSquared(locationsData.getCustomConfig().getLocation(locationName)), locationName);
}
}
this is your new for loop
as opposed to hashing
try it
Though if it’s a TreeMap you might as well just expose the type to be a SortedMap instead of just a Map
yes i actually want to find a way to sort it. after 3d i found out why dont i just use it directly instead of using another hashmap to store then use the constructor of that hashmap to put into the treemap
@ivory sleetthank god, pls help ive been helping like 4 ppl at once 😭
Guys we need feedback in #890917455805968444
u dont need to lol
i dont think, i have a test code and it work even with Map
Oh I will leave you then here, need to finish studying (:
haha
@carmine nacelle @carmine nacelle @carmine nacelle xP
im gonna need that number
@carmine nacelle @carmine nacelle @carmine nacelle xP
Yes RPGAccount but your TreeMap is not substitutable with a HashMap in this case
!java
Thus breaking the substitution principle ¯_(ツ)_/¯
?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.
@quaint mantle try with the new For loop I sent above ^
ok ^^
People really need to learn it anyway please i need feedback on what to do with spigot's garbage #890917455805968444
idc if it CAN throw a null, it WONT because you're gonna put null checks before it, right?
havent
btw you forgot this 😂
locationsData.getCustomConfig().getLocation("locations." + locationName) but anyways let me test it
f-
lol
teo teo teo teo teo
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at com.risingcore.events.onDeathRespawn.onRespawn(onDeathRespawn.java:68) ~[?:?]
the line 68 is just the get array, which if it dont work then uhhhhhhhhhhhhh
so what you're saying is
it's not properly getting through the code that i provided
which you werent happy with
and its now stuck on yours 😉
nope man
damn it feels good to be a gangster
im trying to find the code that i used to print the locationName
lol
gangstar
so its putting your distance from the location, then the location name into the map
did you try printing the values of the map?
at least now we have VALID things to put in the map.
wait wait wait let me test out the old print the name of the location thing
OMG I JUST GODBRIDGE WITH LIKE 8cps (6 block nothing much but i once got 9
i just had a fucking stroke
can you run that through https://translate.google.com/ for me and convert it to English?
Google's free service instantly translates words, phrases, and web pages between English and over 100 other languages.
Ayy dude stop swearing dude
its not against the rules
nope man its meme
and i think its warranted dealing u with guys lol
i think if this work then i can say that this issue is solved
for (String locationName : locationsData.getCustomConfig().getConfigurationSection("locations").getKeys(false)) {
if (Objects.equals(locationsData.getCustomConfig().getString("locations." + locationName + ".world"), p.getWorld().getName())) {
sorteddistance.put(p.getLocation().distanceSquared(locationsData.getCustomConfig().getLocation("locations." + locationName)), locationName);
}
}
System.out.println(sorteddistance.values().toArray()[0].toString());```
you're so stubborn omfg
😂
the mind of this man leaved him. poor guy who tried to deal with 4 kids
through nights. and coding at the same time
yes
😂 yes im so stubborn but my dad took the pc so now im gonna stop the issue, and thanks for your help :madman:
Todododo
how can I cancel OFF_HAND if HAND was used?
ProtocolLib?
no
boolean
package test;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
public class Ls implements Listener {
private static EquipmentSlot h;
private static ItemStack main;
private static ItemStack off;
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Player p = e.getPlayer();
main = p.getInventory().getItemInMainHand();
off = p.getInventory().getItemInOffHand();
h = e.getHand();
if (h == EquipmentSlot.HAND) {
if (main.getType() == Material.TNT) {
p.sendMessage("HAND");
main.setAmount(main.getAmount() - 1);
e.setCancelled(true);
}
}
if (onOff()) {
p.sendMessage("OFF_HAND");
off.setAmount(off.getAmount() - 1);
e.setCancelled(true);
}
}
}
public static boolean onOff() {
if (h == EquipmentSlot.HAND && main.getType() == Material.TNT)
return false;
return true;
}
not worked(
im confused, so you want it to make it only run 1 of the code blocks..?
that seems very..hacky
What exactly is the goal here
It gets called for each hand once thats why you get it called twice I think so
PlayerInteractEvent
There's a method to check if it was the main or offhand
my intellij is updating so I cant check, but look for it
when pressed in two hands, it writes OFF_HAND and HAND
Im aware.
most likely it will not work, since the event is called twice and therefore OFF_HAND was written twice in my chat
declaration: package: org.bukkit.event.player, class: PlayerInteractEvent
Use e.getHand()
and see which hand it is
and only run the code for one of them
no
ok suit yourself
I already use this, but if I take the object in 2 hands and click, it will write OFF_HAND and HAND, and I need it to write only HAND
Yes, you use code to see if it's ONLY one of those 2, and if its not, then do nothing.
that way it only runs once
how?
by using e.getHand() that I sent above.
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
Action a = e.getAction();
EquipmentSlot h = e.getHand();
ItemStack mainhand = p.getInventory().getItemInMainHand();
ItemStack offhand = p.getInventory().getItemInOffHand();
if (a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) {
if (h == EquipmentSlot.HAND) {
if (mainhand.getType() == Material.EXP_BOTTLE) {
p.sendMessage("HAND");
this.removeItemInMainHand(p);
e.setCancelled(true);
}
}
else if (h == EquipmentSlot.OFF_HAND) {
if (offhand.getType() == Material.EXP_BOTTLE) {
p.sendMessage("OFF_HAND");
this.removeItemInOffHand(p);
e.setCancelled(true);
} else {
return;
}
}
}
}
?
like this?
if you take the same items and click, it will write OFF_HAND and HAND. I need it to write only HAND once
but it still writes OFF_HAND and HAND
why do you need to run the code twice?
of course it's going to, it has code for both.
are they both doing the same thing?
if I check whether the HAND is used? that event will be called 2 times and only for the left hand
I still dont understand what you are trying to accomplish.
Why not just get rid of OFF_HAND
and keep HAND
it runs itself for the left and right hand PLAYERINTERACTEVENT
yes... im aware..
it runs twice.
cool.
else if (h == EquipmentSlot.OFF_HAND) {
if (offhand.getType() == Material.EXP_BOTTLE) {
p.sendMessage("OFF_HAND");
this.removeItemInOffHand(p);
e.setCancelled(true);
} else {
return;
}
}
delete this
no
this should be a plug-in for manual dynamite, and if the player takes a sword in his right hand and dynamite in his left?
ahh so there's finally what ive been asking for
how? can I have an example, please?
and if there are two at once?
If they hold it in both hands then they throw it with both hands
I don't need bottles, but Material. TNT
@young knoll, Equipment enum? how?
words
used 2 times
I use 2 hands, if I cancel the left hand when the right hand is already used, I use the left hand 2 times
yes
yes
I did tell you a couple of days ago this is not a simple task
if you only want one hand to action when both click you have to delay the first event a fraction so you can wait to see if the other hand is used too
how can this be done? can I have an example, please?
is it always with a specific item?
yes
and always player interact event?
yes
what does the item do when used?
Yes, thinking
Can anybody else help me there I dont know if he is going to help me...
guys do i need to use hex color codes to add color to my plugin? for example plugin name?
if(packet.getEntityUseActions().readSafely(0) != EnumWrappers.EntityUseAction.ATTACK) {
I'm using this with ProtocolLib to try making sure that my code will only run when right clicking the entity, but it still runs even when left clicking. Any idea..?
How to prevent closing of a custom gui inventory?
Also just for people who say use InventoryCloseEvent then I found that it does not have a e.setcancelled option while Protocol lib also does nothing
And I cant make it auto reopen my inventory because of some variables which make some items move in the gui
ahh nvm I think I found the way
you can’t prevent a player from closing an inventory
I think I found a solution to my problem - https://www.tabnine.com/code/java/classes/org.bukkit.event.entity.ProjectileLaunchEvent
throw, blockplaceevent
that won;t fix your both hands issue
why?
there is already a blockPlaceEvent here
throw
but most likely I will not be able to put dynamite in private, and I need it
I have no idea what you are on about
You were asking about when clicking with both hands you only want right click to operate
That has nothing to do with block place nor projectile launch
ok, this works.
?paste
you can place with either hand, but if you click both hands at the same time it will only take from the main hand.
Hey can anyone check out my thread and see if you have any idea? Thanks https://www.spigotmc.org/threads/protocollib-entityuseaction-issues.527084/
is it safe to send packets async or do i need to put it in a runTask(
they are safe async
hmm, why it doesn't prints anything?
if it prints nothing you haven't registered the listener
im sure i have
sysout can not fail to print
Hello! How could I set a world border for only one player ?
(google, i know) - but I didn't find anything useful for my case
my objective is that whenever someone joins the server, a worldborder is created for him, at a certain distance
You would need to work with packets
Already checked
but it crashed and I don't work with packets really often
WorldBorder wb = new WorldBorder();
WorldBorder border = new WorldBorder();
border.setCenter(player.getLocation().getX(), player.getLocation().getZ());
border.setSize(getConfig().getInt("radius"));
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(border, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
well, no, because they all must be in the same world...
Aight packets then
Guys how do I make a limited death rule?
what do you mean ?
you mean you can die three times before being eliminated ?
and so, do you know how I could fix this ?
Find what's null
Yessir.
hmm... what could be ?
Yeah but how do you code like code it?
is there a tutorial?
Can I do it with command blocks?
player
.
Hi. It seems PotionMeta#setBasePotionData(PotionData) does not exist in 1.8, can anyone help me with this? I need to set the level and duration of the potion.
Me sir?
yea
[OUTDATED] See the new version here!
https://www.youtube.com/watch?v=3jZyXbGX_Hc
Using command blocks, I've made a new gamemode you can play in survival, similar to hardcore mode. In survivalist mode, you have a set amount of lives, and can increase them by eating Notch apples. Don't lose your last life though!
One Command Installation [1.11.2...
This you think ?
might be helpful
Ok sure.
Ehm so I have a server and I want to have a death limit like when people die 3 times it will set the person to spectator.
I see
does someone know a plugin to drain water in 1.17.1 with out worldedit
well, if you're up to coding, you could use a hashmap.
When a player joins, he is put into it, as well as the max number of lives (3).
When he dies, you access the values and modify the number of lives
hmm... did you find anything when searching ?
nooo just worldedit
and it just works on bukit
bukkit
Oh ok thanks.
WorldEdit works on Spigot
do you need anything else ?
well... if that's the problem...
it does
spigot = bukkit in some way
but also
spigot != bukkit
anyway
i got it working but it i dident get the wand
//wand
well, creative mode?
How do I make a death instance?
permissions ?
Bukkit is an API. It is contained in Spigot
ermm... playerdeathevent ?
an event handler
join & death events
i am op
cant i be in creative mode
Check my events, it's kinda the same as you want but I use database
i was in creative mode and was yuping //wand
wait i need to install it agien
... do it then
or send me the list
are you sure you took the good mc version ?
bro are you jokeing, i dident test to go to the bukit side and download the world edit for 1.17.1 and add it to my server it works perfect now, thanks for the help, love you
Guys how do I create a death instance?
A what
btw
I know that you can do a circle with world edit with the command cyl, but can you do walls with is so there is walls up do down in a ciicle
hum...
well do //undo, then do it again by moving a few blocks down until you get it where you want
no not like that i want the circle to have walls all the why down to the bottom of the sea
oh
so like outer walls
does anyone know how to put colors in your plugin name/prefix?
nope
and now i want outer walls all the why down
impossible
//cyl ALONE
no problem 🙂
In 1.8 how do I set the duration of a potion?
I don't know, look for the docs online
I literally did
If in config yml someone puts a bad value example
chest rows: -1
How should I deal with that
Set HP to 0 maybe
"make a death instance"
I sure do love when people ask nonsense questions and then try to bump as if the reason nobody answered is because they didn't see it

My best guess is that they want to spawn an entity that is perpetually in it's death animation

No like how do I make the Death death = new Death() .
Thing?
what

What the fuck are you talking about lmao
new Death();
If you have a class called "Death", then you make an instance exactly like that.
Alright in other words, how do I make a variable that does something whenever someone dies?
That makes so much more sense 
An event listener
Yes.
You listen for PlayerDeathEvent
that's what I told you sooner...
@fresh templetHandler
public void onPlayerDeath(PlayerDeathEvent e) {}
If you don't know how to register a listener, go read docs :)
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class JavaEvents implements Listener {
@EventHandler
public static void onPlayerDeath(PlayerDeathEvent event)
}```
Like how do I make the onPlayerDeath?
well... sorry...
Go read docs
urm... look on internet for a tutorial
?jd
about Listeners
There are literally hundreds of examples
or yea docs
If not thousands
I did but there isn't something that matches my goal.
I guarantee there is
well, you don't need to copy exactly what you want
you can adapt
like a tutorial about join event, use the same technique for playerdeathevent
pls
How do I get the player from EntityPickupItemEvent
Check and cast
Do I have to cancel the task of BukkitScheduler#runTaskAsynchronously or does it "cancel" itself when "run()" was executed?
It runs once and cancels
Yea, so I dont have to do it manually?
no
event.getPlayer() typically
Yeah but this is PlayerDeathEvent.
So I can't do that.
And I need something like the getPlayer function.
event.getEntity
Ok thanks.
event.getEntity().getPlayer();
wait a queue is LIFO right?
in player dead event shouldnt there be 2 types of entities
one is the dead player and other is the killer entity or player
well kay nvm
Generally they are FIFO
ah forgot it
Or LivingEntity#getKiller()
Only works if it's a player
ow yea its the stack which is LIFO
Well PlayerDeathEvent#getEntity() returns a Player so
And can I run a sync TaskTimer containing API stuff, called by an async Task?
Yes
Cool, thanks
next time https://tryitands.ee/
im begging you
embed
there
EMBED
im gonna cry
You need to be linked for embeds I think
dang
lol, It doesnt cost anything to ask, does it?
does someone know a auto build plugin so it auto builds like a farm
It doesn't, but you're constantly going to be asking for things you could test in a shorter amount of time
For everyone, really
No, I got an answer in like for real 2 seconds
Well, you did this time. Might not be the case next time.
probably a question for #help-server sorry! I can check for you tho
sometimes replies take like 15 minutes
yea, thanks for the hint
npnp
Hi someone can help me I was developing and so I use github and git to commit which I would like to remove so I don't know how to use it well with a command to try to synchronize my changes with those in the repository now he has sent me the files back to a quite a lot and it took me 2 months of work someone knows how to do it
what is your goal?
Getting the files that made me go back to basically everything I had before doing these commands
and as soon as I have everything I want to remove the use of git and totally remove github etc. I prefer not to use it and publish my plugin on spigot and get feedback from them
So I am currently facing a issue where I am making a mob target the player through a custom goal
But when the player crouches past the edge of a block, it targets the air block they "stand" on instead
And thus the mob targets the air, and never actually attempts to target the player because midair is unreachable
if i use player.setDisplayname(some string) it doesnt changes the name for some reason
Is there a way to detect when a player is crouching off of a block to float, and get that origin block instead?
Help me?
kind of
you can detect sneaking and air under teh player
you need to take the AIR block location under the player and work out which BlockFace is closest to the player. You can then getRelative to get the block the player is hanging off
How can I detect a block being destroyed by an explosion and cancel it?
EntityExplodeEvent or BlockExplodeEvent
thanks
will that work if their at diagonal corner of the block?
You would then get the relative block twice
You can probably just detect if the player is on top of a air block, and then determine which of the 8 adjencent blocks their hitbox is closest to
As the hitbox has to remain on the solid block
nvm mb just realised theres block face for north_east and stuff
I was able to revive the files via git reset --hard but first I had to find the last commit via git reflog before committing the trouble I had done just now I don't know how to remove the repository I have and detach it from my project too
does anyone know what the enderchest gui class is called i cant find it anywhere
its just a normal chest inv ?
yea but i want to open the players ender chest
Player.openenderchest
cool thanks for the help
is there a way to make a constructor with no args that lets everything uninitialized?
Why tho
Yeah
if you mark it as final afaik you cant
triumph gui, inventory framework, interfaces, canvas and my own
you are forced to assign them null
I try avoiding frameworks yes I’m that nincompoopy
i'm using on of the class' methods but i dont want to initialize those fields if i never use them
I'm iterating over a large number of blocks and trying to get their BlockState with getState. Since this takes a while, I want to do this async. Obviously it does API accesses for some blocks:
java.lang.IllegalStateException: Tile is null, asynchronous access?
```What can I do, or can I somehow find out which blocks are having this issue so I can run it sync?
Just pass null then fourteen brush?
As you did
ah yea but then it does this things
item = new ItemStack(material == null ? Material.BARRIER : material);
itemMeta = item.getItemMeta();
lore = new ArrayList<>();
Looks like some code of yours runs async
My entire iteration runs async
Idk if null can be passed there
Problem ofc
Bukkit isn’t thread safe, not in the terms of BlockState access it seems like
anyone available (lol) to help me ?
What does not work, be more specific
Ye but I cant iterate over a few million blocks in a sync way
and updating it
Not in a single task
wezll
What you instead want to do is to distribute the iteration over several ticks
right now, I just want to create a world border with a radius of 20 when a player enters the server
and it doesn't work
but if I send a message to the player just after it
it sends it
You can do this by equally dividing the amount of blocks into x amount of groups and then iterate one group per tick.
so
well, before that I want to successfully create a border
That wasn’t to you
Let me read what you just wrote 😄
ah maybe like this
What no
😳
If it’s a builder
Don’t use final there
The entire point of builders is that they should be mutable
How do I set the fuse of TNT? This code doesn't work.
Entity tnt = e.getBlock().getWorld().spawnEntity(e.getBlock().getLocation(), EntityType.PRIMED_TNT);
TNTPrimed tntPrimed = ((TNTPrimed) tnt);
tntPrimed.setFuseTicks(52);
tnt.setVelocity(new Vector(0, 0, 0));
Hm, thats an idea. Could it also be possible running the getState part sync for the blocks where it happens or is that too inconsistent?
Such that you can chain mutations to then finally create the actual object
yea but the lore or something should not change when the object has been created
it has a setLore method
etc
No no no
always return the builder
^
there should always be a return this
This is a design pattern fourteen brush
Also
https://dzone.com/articles/design-patterns-the-builder-pattern go to pattern example
Use
this.lore = lore; rather than
this.lore.addAll(lore)
Or well if you don’t want to have a dirty list implementation passed, use something like
this.lore = ImmutableList.copyOf(lore)
Someone knows the best way to communicate my plugin with my website?
Im doing a minecraft store software.
Hey soo.. if I want to use this: https://i.gyazo.com/d40235fc4c9004344d7860da15919200.png
but I just want like a "virtual" editor, where it just gets the data entered but doesnt apply it to a sign, whats the best way to do it?
@ivory sleet
I could just like..make a random sign in the world then use the location of it but thats jank
for the love of god dont use signs for users input
why not?
That would involve hell of a lot of callbacks which is just going to slow you down since it can’t be done in one tick either
thats inconvenient as fuck for users and hard to maintain for developer
What's the "coolest" way then
good ol chat
yawn
well also a sign limits you to like what? 18 charachters?
Someone knows?
you could append the other lines but
Hm okay. Do you know a good sync iteration rate so that the server does not lag?
ive seen people use anvils too
you mean what a backend is made for?
anvils are inconvenient too
yeah
sadge
yeah. i mean, i thought that anvil input will be super cool too
Depends on what ram the server has and all that
"manage" how?
Test your way to the more optimal settings
i asked some players on my server and they said that they got annoyed by anvils all the time
especially on nick input
fine fine..
okay, thankyou! 👍
May I ask why use packets?
How do I set the fuse of TNT? This code doesn't work.
Entity tnt = e.getBlock().getWorld().spawnEntity(e.getBlock().getLocation(), EntityType.PRIMED_TNT);
TNTPrimed tntPrimed = ((TNTPrimed) tnt);
tntPrimed.setFuseTicks(52);
tnt.setVelocity(new Vector(0, 0, 0));
Define "doesnt work"
This sets the fuse to aprox 2.6 seconds
The fuse is still the default, 80 ticks.
also, why set the velocity vector to zero?
wouldnt seeting the ai to false achieve the same even with gravity?
Try setting it pre-spawn:
public TNTPrimed spawnTNT(final Location location, final int primeTicks) {
return location.getWorld().spawn(location, TNTPrimed.class, tnt -> tnt.setFuseTicks(primeTicks));
}
Okay.
So, I need a way of keeping track of if someone's editing a hologram in my system. I could make an ArrayList of uuids of people currently editing, I could make a hashmap, with UUID as the key and boolean as the value, I could make a UUID and store it in my Hologram object..what's best?
for efficiency/cleanliness
make a event system then use it to log?
I am.
Thats what im trying to figure out is how I should keep track of it.
maybe hashmap with UUID key, hologram value.
Map<Something, Boolean> makes no sense.
List scales bad if you want to call contains often.
So then that leaves me with hashmap<UUID, Hologram>, or just setting a boolean of if it's being edited in the object (only owner can edit, already keeping track of the owner's uuid)
HashMap is prob the best.
According to IntelliJ tnt.setFuseTicks(primeTicks) doesn't exist in this case
If only the owner can edit the hologram and you already track the owner from withing the hologram than you can also just use a simple
boolean currentlyEdited inside your hologram as this is unambiguous.
Im guessing that the spawn method doesnt exist because you are using an old Spigot version?
What version are you on=
The spawn method DOES exist
1.8
1.8 support was dropped almost half a decade ago. Move on.
I am making a multi-version server
Right, then to get the holo that they're editing, I'd have to find the one that has them as owner, and is currently being edited
It really depends on your use case. If you want to check which hologram is currently edited then you def need a Map for performance sake
Well, psuedo scenerio.
Right click the hologram, opens a gui with options to add lines, set name, etc
Then upon updating a setting inside the gui, I'd have to get the hologram that was being edited. So I could either put their currently editing Holo into a map with them and get it that way, or I'd have to loop through all holograms, then find the one that has their UUID AND the editing boolean to true
So you aren't going to help me?
I know multiple ways to do it I'm just trying to figure out the BEST yk
solution: delete minecraft
same for paper,they dont allow 1.8 discussion anymore
1.8 is dead meme
Using 1.8 is like using Microsoft Word 2013 and expecting Microsoft to fix all your issues with it
The only somewhat good reason to use 1.8 anymore is Factions
cause tnt behavior, combat..whatever
Thanks, thats very useful 👍
Too old! (Click the link to get the exact time)
LOL
solution: 1.16.5, and get an old combat mechanics plugin
why 1.16.5 
why not
because 1.17.1 exists 
I still don't fully trust 1.17 tbh idk why
works perfect for me
Just wait for 1.18 performance :>
with each server you need more and more resources tru..
especially with PurPur configs
checks discord server name
cant wait to have 4gb ram minimum to even start 1.18
people are 100% willing to help with 1.16.5, but maybe not 1.17 because of changes etc
Is 1.18 gonna have good performance or make us wanna cry performance
800-273-8255
that answer it?
Well, they are two snapshot in and have released a snapshot purly trying to improve performance
How would a timer for 15 seconds then after that times is up do something?
?scheduling
TIL scheduling command
Since we're on the topic..what would be the best way to keep track of something like..
if a player is offline for x amount of days, do y
I made a copy of a players inventory (playerInvCopy) and then cleared their inventory
how would i put their inventory back in
without putting in every single item
get the copied inventory's contents and set their inventory contents to the same
( i think)
getContents, clear inventory, addAll
no, but player.getInventory()#setArmorContents, setContents, setExtraContents, and setStorageContents are.
Not sure what extra and storage are, but armor is armor and setContents is their normal inventory
I have this code: https://pastebin.com/kr4NJhzT: though at the end of it the error i am getting is when i type 'this' and i think its because im not in my plugins main class and the parameter type is supposed to be Plugin, how can i fix this? I tried calling my main class but that didnt work either.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
i fixed that issue
but
is this possible: https://pastebin.com/PmGnSccw
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.
other than the bracket i missed is it possible?
Kind of. What are you trying to do?
because i have lots of items to edit
i dont want to do ItemMeta meta = item.getItemMeta
for every single one of them
I get an error in console saying that the meta is null
Write a builder class.
public static final ItemStack HELMET = new ItemBuilder(Material.NETHERITE_HELMET)
.name("§eCool Helmet")
.lore("")
.lore("§7This is a cool helmet")
.enchant(Enchantment.PROTECTION_ENVIRONMENTAL, 5)
.enchant(Enchantment.DURABILITY, 3)
.build();
so would @NotNull. fix it?
No
ItemBuilder doesnt appear for me
You need to write one yourself
Another way would be using an enum like this:
@AllArgsConstructor
public enum CustomItem {
HELMET(Material.NETHERITE_HELMET, "§eCool Helmet", Arrays.asList("", "§7This is a cool helmet.")),
CHEST_PLATE(Material.NETHERITE_CHESTPLATE, "§eCool Chestplate", Arrays.asList("", "§7This is a cool chest plate."));
private final Material material;
private final String name;
private final List<String> lore;
public ItemStack create() {
final ItemStack itemStack = new ItemStack(this.material);
final ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName(this.name);
meta.setLore(this.lore);
itemStack.setItemMeta(meta);
return itemStack;
}
}
Then use it like this:
ItemStack helmet = CustomItem.HELMET.create();
there is a factory for meta https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/ItemFactory.html
Or use Kotlin 🙊
Elaborate
val custom_item = ItemStack(Material.NETHERITE_HELMET).also {
val itemMeta = it.itemMeta!!
itemMeta.setDisplayName("§cCool Helmet")
itemMeta.lore = arrayListOf(
"",
"§cThis is a cool helmet"
)
it.itemMeta = itemMeta
}
could you do that if you have time pls?
Oh yeah. Almost forgot. Im pretty far but there is still one pesky problem
okay thank you just take your time
Okay that really cool already
But is it only 2D cause if id would be 3D it could just go over the stone right?
which algorithm you are currently using?
I added predicates to determine the behavior
Bootleg A*
Kind of eyeballed it
Ah interesting
if I were to do java entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier()); what would go inside addModifier()? I cant figure it out
Hi
It looks so cool already thats amazing thank you
A new instance of AttributeModifier. Your IDE should tell you that.
My shadow plugin does not bundle Aikars ACF dependency with my fat jar. This is my build.gradle
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
group = 'de.cstmth'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://oss.sonatype.org/content/groups/public/' }
maven { url = 'https://repo.aikar.co/content/groups/aikar/' }
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'co.aikar:acf-paper:0.5.0-SNAPSHOT'
}
shadowJar {
relocate 'co.aikar.commands', 'de.cstmth.moderationvisor.acf'
relocate 'co.aikar.locales', 'de.cstmth.moderationvisor.locales'
}
Can someone tell me why this happens? The build.gradle seems to be fine
it does, I was just too stupid to figure that out lol, anyways, thanks!
"compileOnly" <-
I wonder why
Use implementation also not compileOnly
with worldedit can i do like //replacenear 25 grass_block 25%moss_block
implementation will add the dependency as a compile time and runtime dependency as opposed to compileOnly which only adds the dependency as a compile time dependency
hello. im canceling the InventoryClickEvent but when i do this, the player makes the left click as shown here:
basically im using my inventory api (https://github.com/WizardlyBump17/WLib/tree/main/core/src/main/java/com/wizardlybump17/wlib/inventory, canceling event: https://github.com/WizardlyBump17/WLib/blob/main/core/src/main/java/com/wizardlybump17/wlib/listener/EntityListener.java#L26)
Video is zero length
maybe you just did not downloaded it
yeah, not downloading a video
when I do someArray.length does it start at 0 or 1?
0
help me
you are in the wrong channel for getting help using a plugin
okay thank you
#help-server <- Ask here
i did
you know the ansawer
help me
XD
Use the appropriate channel, end of discussion
You are the kind of person that goes into a computer shop and asks for help with your spanish homework because its about calculators.
[16:01:40] [Server thread/ERROR]: Ambiguous plugin name `plugin' for files `plugins\plugin.jar' and `plugins\lifesteal.jar' in `plugins' I got an error with my plugin, I have two that I made. This plugin was quick and sloppy so I expect it to be a stupid error
plugin.jar and lifesteal.jar have the same plugin name in their plugin.yml
you cant have duplicate plugin names
Check your plugin.yml and dont name your plugins the same
I copied that from my other plugin and changed it lol, guess I missed that part
Is there a way to replace my current plugin.jar with the new plugin.jar while in development cycle? Stopping and restarting the server all the time takes a lot of time and I think there is a way to do it with reload. I know it is not recommended and would not do it on production.
When I try to overwrite the file using IntelliJ drag-n-drop though it gives me an IOError
yes, because a class it might need on shutdown is not on the disk (it has been overwritten)
If you absolutely have to, unload, then replace, then load
or make sure no new classes are loaded on shutdown
I remember just letting shadowJar override it but that seems to not work anymore
What do you mean by that? I just want to replace the running jar of my plugin with a new one with updates on my test server. It does not matter if errors occur as long as reload fixes them.
I know this is possible, I just don't remember how
Well, the exception is likely a zip file closed exception right
No, java.io.IOException: Cannot delete "filepath"
oh thats different then
I'm just using IntelliJ Drag and Drop
I'm assuming it's the regular "file in use" block.
Which makes sense technically
mhm no, probably this is an error you can just fix though
Does it also happen on a normal shutdown?
No. As long as the server is offline (I used stop), I can drag it into the plugins folder as regular.
When the server is actively running the plugin though it does not allow me to do so
This ioexception, is it thrown in intellij with the shadowJar gradle task? Or does it happen on the server
not sure how you copy after your build to the server
I think we have a misunderstanding.
Yeah ig, not really getting the full picture
why does it go up there tho and not down
I have no idea. currently investigating
thank you so much
I am regularly running the shadowJar task, no issues here. Then I want to move that fat jar to my test servers plugins folder to test the changes I have done etc.
Some while ago I had some way to make Gradle/shadowJar replace it directly but I don't know how to do that now. So my plan was to just drag and drop the newly created fat jar from /build/libs/ to /server/plugins/ but that is not allowed. Then, the error occurs.
Note that the server is running while I try to move the jar file. When the server is stopped, I can move it without issues.
right, so you drag and drop directly, and the error is displayed in the server’s console?
cstmth are you’re trying to hotswap? btw tldr
Yes technically. I got it working now
No, in IntelliJ. I got it working now with this shadowJar config
shadowJar {
destinationDir(new File("D:\\Shared Drive\\Entwicklung\\Projekte\\ModerationVisor\\server\\plugins"))
}
Is that the recommended way of doing it though?
So do you run your server instance by a gradle task? If so do you run it using debug mode?
This is what I get: https://prnt.sc/1thz0d0
No, I just run it like a regular server using java -jar spigot-1.17.1.jar and so on
So how I would run a regular server as well. Is there a debug mode especially for development?
if (args[0].equals("decision")) {
if(args[1] != null){
String target = args[1];
DorokeiCommandResult.randomDecision(target);
}else{
DorokeiCommandResult.decision();
}
}```
When I execute the added command, I get the error "an internal error occurred while attempting to perform this command".
① /dorokei decision <MCID>
There is no problem when I hit
② /dorokei decision
If it is only, an error will occur
I want to execute different processes for ① and ②
Check args.length, not args[1] != null
This, otherwise epic IndexOutOfBoundsException
.
thanks
Is there a way to get the block the player is currently colliding with
Not via position, but via collision
any one can help
with this
how would I block that package
so it wont reach viaversion
That is a lot of extra
talking to me ?
mhm
