#help-development
1 messages · Page 1646 of 1
Doesn't always match but it's a good starting point
Please fix JAVA_HOME environment variable.```
JAVA_HOME is a system environment variable.
ignore it then. I'm sure it will be fine and everything will work correctly.
o ok
That was sarcasm btw
:/
errors and warnings as there for a reason. Fix them.
you dont want to mess with her
I don't understand why my projects are not finding the spigot artifact anymore, is the repo down?
@quaint mantle what
if you dont understand your own meme than this is sad
Hey, i'm currently working on my first spigot plugin, not new to java however but had a quick question, i have a chatListener class which i want to take player's chat messages and store them into a hashmap of the player's username and message so that when a command is executed i can check their last message and if it is "confirm" it executes the command, Is there a simpler way of doing this? Atm i'm struggling to pass the hashmap over from the chatListener class to the command class since i'm unsure as to how it's instantiated with bukkit over standard java
I think i'm getting myself confused but i'mnot finding anything helpful online
First of use UUID instead of username
I was planning on this but i wasn't sure how to get the player's UUID from the event
so i settled for their listname
You use getUniqueID on the player object
The problem with usernames is that there are rare cases of duplicate usernames, and you don't want that to break your plugin
That's what i was thinking yeah, just couldn't find the method in the API, that's changed thanks
Anyway there isn't a difference between how spigot and java instantiates things
Would i be able to skip the chatListener entirely and treat the command executing class allowing it to implement both Listener and commandExector instead?
The listener will be called in the instance you registered it with
Can i set a persistent data type to a boolean?
(byte) 0/1
did you cast it to byte?
is there an easy way to summon an entity without calling EntitySpawnEvent? or maybe to register the entity as something the event doesnt care about?
Explain
So I'm trying to use the Player Position packet with protocollib, I think (I could be wrong) it should be PacketType.Play.Server.POSITION
I tried this;
ProtocolManager protocolManager = mainPlugin.getProtocol();
protocolManager.addPacketListener(new PacketAdapter(mainPlugin,
ListenerPriority.NORMAL,
PacketType.Play.Server.POSITION) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
Bukkit.broadcastMessage(String.valueOf(packet.getDoubles().readSafely(0) + "," + String.valueOf(packet.getDoubles().readSafely(1) + "," + packet.getDoubles().readSafely(2))));
}
});
Just to see if it works. It does not broadcast anything and also does not give an error.
Any clue if I should have a different packettype or smth? Am kinda new to packets/protocollib
I would love to have a chance to spawn a horde of Zombies around one if its hit by a player, but currently it crashes the testserver every time it happens
Spigot has an API event for player movement
send code
?paste
true but am messing around with packets to understand it better
how do I pack code into discord?
ok
ok
?paste
currently Ive fixed it by making the horde entites into Husks instead of Zombies since doing it with zombies has a chance to put it into a loop
what was the error
Every time you spawn a zombie, it triggers a new hord to spawn, infinate loop
oh I thought only on damage
true, but that only happens when you have the spawn chance at 100%
you are doing this on spawn ?
didn;t you say you wanted a horde to spawn when a player hit a zombie?
yeah I didnt remember it correctly sorry
easiest solution is to use the World#spawn method that takes in a Consumer<T> and add a PDC entry to the spawned zombie
then check for that PDC entry on entity spawn
the passed consumer is executed before the entity is added to the world (and the respective event is called)
at the beginning of your horde spawner code, set a boolean field to indicate you are spawning a horde. Then in your spawn event ignore any spawns when the horde is spawning. Reset the boolean when you finished the spawning
or that
I think Ill do that, sounds way easier, thanks for the help 😄
it is xD damn minecraft single thread
sometimes it does help
player#OnGround is deprecated, should I use something else to check if a player is on the ground?
check wether the block under the player is air?
would not account for a player on the edge
It's deprecated because the client decides if it's on the ground or not
only deprecated because the client can modify that field as it likes
deprecated as it can be faked. There is no replacement. Use it but know it could be tricked
use maven
Or javac if you want to try hard
javac poop
There is only one IDE for Java

Ill program on my calculator if I want to ok?
MS Word or quit
Samsung smart fridge gonna come in clutch
google docs better
inventoryclickevent
you use InventoryPickupItemEvent
No.
oh nvm
Maven works on Windows
sounded like the exact thing he needed
no
I have it right now
same
No
not even sure why you download it
no
I never downloaded it. came with the minecraft plugin for intelliJ
are you a developer Ryan?
You can install it on any platform. But its a bit complicated because you need to edit the system environment variables.
download the file, it’s that simple.
@vivid palm
maven is just jar files 😭 it isn't OS dependend
or you know the official installation instructions work too
I hope Ryan is not a dev
They are poop
🤨
True
but they are good enough
As player#onGround can be used by the client, what would be an alternative?
Just checking the block under the player will return the wrong block when standing on the edge. Not to mention all the "weird" blocks like beds, skulls ect
There is none. You could get block under, unless crouching with no block under, then get the closest block.
How do you change which map an ItemStack is showing in 1.17? Like the data value
You use MapMeta
declaration: package: org.bukkit.inventory.meta, interface: MapMeta
thanks
hey im wondering if its possible to log certain things to RCon aswell w/ Console
like
can i just
idk
I do not think that that integration exists
well there's a "RemoteConsoleCommandSender"
im wondering if i can get that in any way :o
You can pipe stdout anywhere. You can even mirror it into dev/null/ if you feel like it.
are you talking to me
yes
Yes. Im not sure what RCon is but you can pipe the logs wherever you want
ah
i wonder how, i'll google
GG
i forgot Spigot is an actual irl item
big brain?
spigot + pipe == faucet
faucet logs
new spigot fork - faucet
I represent my new spigot fork: nozzle
I represent mine too: nuzzle-wuzzle
Dont search for spigot stuff. You need to re-route System.out
Pretty sure all of these were already used lol
Or return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource
Even nuzzle-wuzzle?
thats a thing?
yes
May be an exception
bruh
Phew, good.
yikes
that being said, idk if they allow writing to RCON
Hey is their an event for die?
or is it EntityDamageByEntityEvent?
yo
i think they do allow writing to RCon @quiet ice
because you can send command feedback
you can .sendMessage()
And does it work?
so how can i kick a player, i try things like p.KickPlayer(name) but this kicks the player who uses it, ( bc of the p. ) what else can i try?
I don't care whether something compiles if it straight up does not work
well i can do /who in rcon and get the feedback
therefore it must be possible
ignore the capslock toggle
?jd this is a javadoc issue
what would it be under>
kickPlayer
void kickPlayer(@Nullable
String message)
Kicks player with custom kick message.
Parameters:
message - kick message
Yes, that is because you are not using some super strange firefox config
So do Bukkit.getPlayer(name).kickPlayer(reason);
am i need to wait?
?jd
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDeathEvent.html use javadoc ffs
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
PlayerDeathEvent for example
like seriously, we should start kicking people asking such easy questions
LOL
ty so much ^_^
the snoofpeed

e
How do you render an image to a certain map id
Ask them
weird and confusing Component stuff i cbb to learn about
That error is related to something in Paper
i want to get the location of 100 blocks higher than a player
Player p = e.getPlayer();
Location sky = loc.getY()+double (100);
Then use the add method on the player location and get the block from that
how do i fix the double(100) part
100D
Double isn't a location
the letter at the end of a number is used for typecasting
whats the add method
add(x, y, z)
oh i didn't look at the rest
^
How can I get if a BukkitTask is running?
This is not how java works
Do you have a reference or id of this task
ive only used java a few times so im still new
probably isCancelled
If you're inside it
?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.
i recommand you read one of those
Cannot invoke add(int, int, int) on the primitive type double
uuuuh
._.
what did you do
thanks for the links im gonna take a read of them
Yeah sounds like a good idea
ye
Player p = e.getPlayer();
Location loc = p.getLocation();
Location sky = loc.getY().add(0, 100, 0);
taskSpawnParticleZ = Bukkit.getScheduler().runTaskTimer(Main.getPlugin(), new Runnable() {
@Override
public void run() {
if (taskTimerZ == 50) {
taskSpawnParticleZ.canel();
}
taskTimerZ++;
player.getWorld().spawnParticle(shieldParticle, loc, 1);
}
}, 0L, 1L);
I wanna know if this task is running or not
oops forgot to delete the getY
Aight just use isCancelled on taskSpawnParticleZ
not an actual location
oh didnt saw that somehow thank you
i think, read the docs
package index
you have everything right there
Hey, please help with fixing a bug, I described it on project repo, https://github.com/Aregcraft/HittingAnimations in readme.md file at bug section. Please help
you have a typo, taskSpawnParticleZ.canel(); should be taskSpawnParticleZ.cancel();
?
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import floorToAir.Main;
these are my imports
ah yeah thank you
You don't need anything more to be imported
Because Player implements Entity, every method of Entity can be used in Player
(actually Player implements HumanEntity but close enough)
Take a look at those java tutorials
Hi hi, i made a Plugin and i have a problem. I like to check if an integer is between two numbers. My Code:
if((LevelingAPI.getPoints(p) >= 1) && (LevelingAPI.getPoints(p) < 200)) { System.out.println("deb2"); lore.add("§7- - - - -"); }
And the error is:
Caused by: java.lang.NullPointerException at me.pierre_rene.MainLevelingSystem.Bukkit.util.GUI.SetItemMeta(GUI.java:57) ~[?:?] at me.pierre_rene.MainLevelingSystem.Bukkit.util.GUI.openGUI(GUI.java:44) ~[?:?] at me.pierre_rene.MainLevelingSystem.Bukkit.util.GUI.onCommand(GUI.java:29) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-dcd1643-e60fc34] ... 15 more
Code goes here
ye
so if i imported org.bukkit would i need to import anything else
Line 57 is the line where the method are colled and in the method is my code
You don't want to import org.bukkit
hypothettically
Show GUI line 57
okay thanks for the help
np
:
Line 57 is the line where the method are colled and in the method is my code
in the method is my code
No code -> No help
what
he's talking about that
wait i upload it
then LevelingAPI.getPoints(p) returns null
?paste
use this next time
yep
(((LevelingAPI.getPoints(p) >= 1) && (LevelingAPI.getPoints(p) < 200)) != false) also what the fuck is that
if (!taskSpawnParticleTop.isCancelled()) {
player.sendMessage("1");
taskSpawnParticleTop.cancel();
}
player.sendMessage("2");
I did it like this now I dont even get to the "1" or the "2" and get an error in the console....
Hi I'm relatively new to spigot development and I was able to override the generateChunkData method previously but as I understand it, that's deprecated and it says it's split up? I'm just trying to understand what it means by split up and what should instead be overridden? thanks!
The docs should contain all you need
just use ((LevelingAPI.getPoints(p) >= 1) && (LevelingAPI.getPoints(p) < 200))
it's the exact same
I think chunks now also have a y coordinate so the generation is split into several chunk sections.
package floorToAir;
import org.bukkit.plugin.java.JavaPlugin;
import floorToAir.listeners.floorToAirListener;
public class Main {
@Override
public void onEnable() {
new floorToAirListener(this);
}
}
why does onEnable() get the error "the method onEnable() of type Main must override or implement a supertype method"
ive done the exact same layout on my other plugins and it worked
Go through the basics pls:
https://www.spigotmc.org/wiki/spigot-plugin-development/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ohh ok thanks I'll look
yet i must say if LevelingAPI.getPoints(p) == null then i set it to 0 or?
extend
Why you don't extend javaplugin?
i don't know what's in your getPoints method, but it returns null.
oops forgot to add that
You need to take care of it
Also don't name your main class Main
Depends. If the backing data structure is a map then computeIfAbsent is a viable approach.
Otherwise you should make sure every player in the map actually has data associated with him.
ohh ok I guess the ChunkData is now a public member of the ChunkGenerator? huh
how come
unless I'm misunderstanding
it gives you a Integer out of a MySql Database
if (!taskSpawnParticleTop.isCancelled()) {
player.sendMessage("1");
taskSpawnParticleTop.cancel();
}
player.sendMessage("2");
```I did it like this now I dont even get to the "1" or the "2" and get an error in the console....
I wanna know if the BukkitTask is running pls help
Name it the same as your plugin
Another tip : in your code the method get called twice
You'd rather assign it once to a variable and then use that variable
Show some more code and the stack trace pls.
Because here you're doing 2 MySQL Queries
yeah ok thx i fix it XD
theres the error:
https://gist.github.com/ItzJustNico/5e4c32030d891f14a1865c4f77d971e7
Use SQL like that:
When a player joins -> load all data from sql to data structures
When player leaves -> save all data back to sql
You really want to avoid sql queries on the main thread at all costs.
yep
Whats FireAbilityManager.java line 56?
and thats the whole code:
https://gist.github.com/ItzJustNico/9f5637a0612b9493d5ad82b32ad26e3e
but it running on many servers on same tame and anny plyer con see it. I think so it is good
package floorToAir.listeners;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import floorToAir.floorToAir;
public class floorToAirListener implements Listener{
private floorToAir plugin;
public floorToAirListener(floorToAir plugin) {
this.plugin=plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void moveEvent(PlayerMoveEvent e) {
Player p = e.getPlayer();
Location loc = p.getLocation();
Location sky = loc.add(0, 100, 0);
Block b = loc.getBlock().getRelative(BlockFace.DOWN);
if(b.getType()==Material.AIR) {
}
else if(b.getType()==Material.CAVE_AIR) {
}
else if(b.getType()==Material.WATER) {
}
else if(b.getType()==Material.LAVA) {
}
else if (b.getType()==Material.OBSIDIAN) {
}
else if (b.getType()==Material.NETHER_PORTAL) {
}
else if (b.getType()==Material.END_PORTAL) {
}
else {
p.teleport(sky);
}
}
}
where it says private floorToAir plugin; the plugin gets a warning saying "The value of the field floorToAirListener.plugin is not used"
?paste
but apparently im still meant to include it
use this please
Stop posting your code like that pls
and also use switch instead of multiple ifs
if (!taskSpawnParticleTop.isCancelled()) {
then taskSpawnParticleTop is null
what’s this meant to mean 
don't worry i code in python too
and its null because its didnt run already right?
if the error is throwing that means that the task is running
its a good idea but it running on many servers on same tame and anny plyer con see it. I think so it is good
You should make one runnable that ticks every second and is always running. Then add/remove tasks from it. Starting/Stopping tasks and keeping track of them is a logistical nightmare.
?
where it says private floorToAir plugin; the plugin gets a warning saying "The value of the field floorToAirListener.plugin is not used"
I don't understand this sentence
Your IDE you mean ?
yh
If it's only a warning should work
it needs a multiple and realtime acces
Then you need another solution. Querying sql on the main thread like that will produce lag and can even straight up crash your server.
i sometimes get that warning and sometimes i dont
Store it in a variable
And the data'll be synchronised
on multiple servers?
doesnt it lead to causing lags if it runs unnecessary ?
Oh this
uuuuuuuuh
yeah
no
it'll just be laggy
or get it off main thread
Over long it will always produce lags. Any IO on the main thread is a horrible horrible idea.
yeah in cause of that i use MySql
How do you render an image to a certain map id?
You need a proper in memory data grid like hazelcast or redis.
what would be the best way to store what kits players have unlocked using mysql?
would it be
UUID, KITNAME, KITNAME, KITNAME, KITNAME etc. and all the KITNAMEs would have true/false
or would it be
UUID, UNLOCKEDKITS and have a long list (separated by comma) of all the kits unlocked?
You need to overwrite the render method and check the maps id
Example:
i don't think there's a better way, in terms of speed the second query would be faster
And always program async with delegation when using databases.
Consumer<T>, Function<T, E> etc.
yeaaaah it sounds good but its not possible cause my software from the server doesnt acces a redis
And the second is more flexible since you don't have to modify the table if you wanna add a kit
oh i see
Then prepare for random server crashes and quite a bit of lag if your server sees more visitors.
Plz help with fixing a bug, I described it on project repo, https://github.com/Aregcraft/HittingAnimations in readme.md file at bug section. Please help
yeaaaaah its ok
Do some debug
Like
it's not hard
check if the method is called
thank you
So puting more run methods in one Runnable? And how could I add/remove something from it then?
You can define your own Interface that will cancel itself. Let me write you an example.
yes that will help thank you a lot
Already done. Method is called. But still don't work.
Either .toString() it or just check if it works without
Why does it throw out an error
Sry for the chat clutter but its not much happening here, so:
public interface LimitedTask {
void execute();
boolean isDone();
default boolean executeThenCheckIfDone() {
this.execute();
return this.isDone();
}
}
public class LimitedTaskRunnable implements Runnable {
private final LinkedList<LimitedTask> taskQueue = new LinkedList<>();
public void addTask(final LimitedTask task) {
this.taskQueue.add(task);
}
@Override
public void run() {
final Iterator<LimitedTask> taskIterator = this.taskQueue.iterator();
while (taskIterator.hasNext()) {
final LimitedTask task = taskIterator.next();
task.execute();
if (task.isDone()) {
taskIterator.remove();
}
}
}
}
Your MainMenu is probably not extending/implementing the right class/interface
This one is even shorter but does the same:
public class LimitedTaskRunnable implements Runnable {
private final LinkedList<LimitedTask> taskQueue = new LinkedList<>();
public void addTask(final LimitedTask task) {
this.taskQueue.add(task);
}
@Override
public void run() {
this.taskQueue.removeIf(LimitedTask::executeThenCheckIfDone);
}
}
and where do I put the code I want to run through?
Implement LimitedTask and add it to the LimitedTaskRunnable
Is it not because it's already being used by a commandexecutor?
Try showing us the error lol
okay I will try that give me a second
Hover over the error and show us what it tells you
There you go. It expects a CreateMenu but you pass a MainMenu
I want to pass both
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.
interfaces
Then make them both extend a class/interface and qualify this class as argument
oh thanks
😉
oWo
i've asked before and tried some stuff, none works... how can i write to RCon, as a RemoteConsoleCommandSender
I dont get it haha
can you pls make me an example where I can see how to add it? Only if you have time tho
Is there a way to prevent flaming arrows? (Wether that be from the flame enchantment or them passing through lava, etc)
i've tried casting, System.out, and even making an arraylist of RemoteConsoleCommandSender and sending things from there
Do you want to stop them from igniting or stop them from setting entities on fire?
doesn't matter as long as the outcome is the same, but would prefer if it visually looked like they are "difused" as wlel
Can probs check entityigniteevent and check if its a projectile then check if its an arrow
if igniteevent doesnt work try https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityCombustEvent.html
declaration: package: org.bukkit.event.entity, class: EntityCombustEvent
In this example the runnable deals damage to the player until it ticked 10 times or the player disconnects
Omg thank you so much it helps alot! Are you german btw?
Yes
Me too haha
my condolences
lol
Hahaha
Generating a new world always lags the server out for some reason. Maybe try delaying the teleport for a few ticks and dont teleport him to a random location like 0 75 0 but the actual spawn location of that world because the spawn chunks are generated first.
Because the spawn loc is rarely at 0 0
The generation is in onEnable the teleport is oncommand
Oh god. Ive seen a name that triggers ptsd in me
if (e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (e.getPlayer().getItemInHand().getType() != Material.EXP_BOTTLE)
return;
how can I use 2 hands at once?
There we go...
The interact event is fired twice. Once for the main hand and once for the off hand. You need to listen for the event
and distinguish by PlayerInteractEvent#getHand()
Try adding a plugin chunk ticket at the location and teleport 5 ticks later.
I did the spawnlocation instead of 0,0 and that fixed it. (on the first test atleast)
public void teleportWithTicket(final JavaPlugin plugin, final Player player, final Location location) {
final World world = location.getWorld();
final int chunkX = location.getBlockX() >> 4;
final int chunkZ = location.getBlockZ() >> 4;
world.addPluginChunkTicket(chunkX, chunkZ, plugin);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
player.teleport(location);
world.removePluginChunkTicket(chunkX, chunkX, plugin);
}, 5);
}
God been trying to get this shit to work for the past 3 days and all it was, was the location wasn't loaded
Rephrase: the chunks were loading lol
xD
I'm trying to make an irremovable leather cap
curse of binding
^
im stupid
then just don’t remove it on death
how would you do that?
just in the death event remove it from the dropped items list?
also, you can take it away through code, right?
yeah
in the death event or respawn event?
i’m not sure - you may need to put it back after they re spawn
do you know if you can set their inv on death @lost matrix
You need to keep track of the items that should be kept on death and add them back at the PlayerRespawnEvent
yeah ok
so if there is just one type of item just keep track of the players that need it and on respawn just set their helmet to that
if not you need to keep track of the players and which they need
I already have array's of teams and stuff
should be pretty simple to add i think
This is the general idea:
https://gist.github.com/Flo0/cf590613ce8c9bc167e2d229e3d01d7e
But you probably need to define a wrapper class containing the ItemStack and the slot it was in if you want to put the items back on the same slot.
Perfect case for a record btw
There is just one problem when the player dies and disconnects without respawning.
obviously you couldn’t just Inventory#addItem
if it’s a helmet
cause it wouldn’t be equipped
Yea figured it out
It crashed after awhile. After I teleported. Never moved.
F i guess.
But if you generate the world in your onEnable then the server should not have any problems when teleporting you to that world later on.
how to get a player head
Search in spigot forums, there will be plenty of answers there
A quick Google search will do
ItemStack -> skull meta -> setOwner -> set meta
like this?
ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwner(p.getName());
skull.setItemMeta(meta);
p.getInventory().setItem(103,skull);
sorta
you can just get the meta of the itemstack and cast that
and
you don’t need the short in the itemstack constructor
as in
remove all that ordinal shit
and, you could use getDisplayName i guess
but that looks good
kk ty
Is there any API to set item lore via Components?
I don't see any, but thought I'd ask in case it's on a spigot() somewhere that I'm missing, or.. something.
Not in spigot but paper has kyori
Huh? What do you mean by "head index"?
oh
Aah
RIP thanks though
yeay ty
player.getEquipment().setHelmet(ItemStack);
^
ty guys
How would i keep track of, control the growth of plants?
Since their not tile entitys i cant add NBT to them
wdym
Since 1.16.4 you can save NBT on just normal blocks
Thats news to me. Mind explaining?
Spigot implemented, i'm not sure for the name, PDC for Chunks, which allows you to add NBT to blocks too
does it
Well you kinda can, just use x, y, z as a key in that chunk and you can save blocks to it
I know about the chunk PDC but not about PDCs for any arbitrary block
It's not a specific implementation but it works perfectly fine
you can still do it
would you mind explaining a bit more?
you can do chunk.getPersistentDataContainer as far as I know
I'm not sure what the methods are called
but you can add stuff to it similar to how a HashMap would work
you don't need y if you are saving a chunk
and you could just key it using a String
and then could do something like block.getX() + "_" + block.getY() + "_" + block.getZ() + "_" as the key
@reef wind
ok stop fr
I didn't understand
Anyone know the nms call to update a chunk's lighting in 1.17?
I've been looking for quite a while now and found nothing
In every prior version it's just nms.chunk#initLighting()
@waxen plinth
try nmsChunk.i.getChunkProvider().getLightEngine().a(new ChunkCoordIntPair(chunkX, chunkZ));
If not, try that class's methods
Hello, I am trying to prevent my endercrystal to get blew up by my explosion made with createExplosion()
I cancelled EntityDamageEvent and EntityExplodeEvent but the entity is still killed
a TNT doesn't kill the endercrystal with the events cancelled but createExplosion() does
Spawn TNT and set its fuse to 0 instead of using createExplosion
createExplosion() allows me to chose the strength of the explosion
I get that this function doesn't trigger EntityExplodeEvent, why not
oh thank you I'll try that
I googled "radius", block lists stuff like that but never found "yield"
Then createExplosion really is useless
but I don't want to cancel everything just not affect the entity
Doesn't cancelling EntityExplodeEvent cancel the block damage too
EntityDamageEvent & EntityExplodeEvent with endercrystal being the entity
but maybe endercrystals don't actually explode I was just trying anything
I used that it's perfect thanks everyone : )
love it when most questions in this channel are about java than spigot
yo I need help
for 2 things
why ping

Ask
I've got a problem with my start.bat

lol
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/alexandre/cloudboards/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0
any1 would know how to fix this ?
read it
done
be any1 be of some help pweaze
I've looked online and couldn't find a lot
Stop trolling
are you okay mate
Yes
doesn't seem like it
public class CustomChicken extends EntityChicken {
public CustomChicken(World world) {
super(world);
}
}
im getting an error at "world" at super
what's your error?
I don't like you windows
stop trolling math
'EntityChicken(net.minecraft.world.entity.EntityTypes<? extends net.minecraft.world.entity.animal.EntityChicken>, net.minecraft.world.level.World)' in 'net.minecraft.world.entity.animal.EntityChicken' cannot be applied to '(net.minecraft.world.level.World)'
Okay sorry Alexandre
didnt ask math kid
Update the Java that's running the plugin or build the plugin on a lower Java version
You should have allowed my GPU to work
MathWellan lil french boi
What are you talking about 🙄
how may I build the plugin on a lower version? I've tried downloading lower versions of java on my pc (java 8)
Yea I figured
Are you using IntelliJ
I'm using eclipse?
I do got intelliJ
but
yeah I made this plugin on eclipse for some reason
but isn't there a way of doing it on eclipse as well?
Intellij better
u using maven or gradle
ikik lmao
oh forgot screenshots were ass on here
well as you can see on the screenshot
it's a "Java Project"
u using maven or gradle
haven't spicified it
pick one, i reccommend maven
No
oh
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ermmm
Can someone explain this for me?
for (int x = loc.getBlockX() - 1; x <= loc.getBlockX() + 1; x++) {
for (int y = loc.getBlockY() - 1; y <= loc.getBlockY() + 1; y++) {
for (int z = loc.getBlockZ() - 1; z <= loc.getBlockZ() + 1; z++) {
Block b = loc.getWorld().getBlockAt(x, y, z);
}
int x = loc.getBlockX() - 1; x <= loc.getBlockX() + 1; x++ like whats going on here
You want to generate blocks in a cuboid?
its searching a 3x3 area
Yea, im trying to get a 3x3 area around the feet of the player
that is code that breaks blocks in a 3x3 area
So im trying to understand it
So what don;t you understand?
So i can edit it
each x,y,z +1 and -1
i dont get whats going on here int x = loc.getBlockX() - 1; x <= loc.getBlockX() + 1; x++ or why its in a for loop
so count from x -1 to x + 1
teh loop ends when that test is not valid. so when x goes above loc + 1
Test the code and see what happens...
ohhhhh
The logic is simple
Java don't have range like 0..10 in kotlin?
Nope
scan 3x3 using kotlin range is simple
if u know for loops u can 100% understand it
ok so:
A for loop is comprised of 3 parts:
The first is executed once when the for loop starts.
The second is a condition, the loop continues if the condition returns true.
The third is executed once per loop.
so this means
"assign x to block x - 1"
"if x is less than or equal to block x + 1, continue"
"when you loop, add 1 to (AKA increment) x"
The for loops inside it do the same thing, just with block y and block z.
Then, it gets the block at the x, y, and z.
You mean in Kotlin...?
in java
That's just false :p
for-each loops technically compile to while loops, so for-each loops don't exist :p
And the terminology is "enhanced for loop" but that's semantics
Technically, for loops are also while loops
And that's both functionally and internally.
the for-each loop isnt a while loop. maybe it has most likely the same impl. but it does not use a while loop internally
Do you know how the JVM does loops...?
Also, in no situation is a for loop the same as a for-each loop.
The fucking Wikipedia description makes a clear separation.
Foreach loop (or for each loop) is a control flow statement for traversing items in a collection. Foreach is usually used in place of a standard for loop statement.
read the java language specification.
And it is, it's literally a shortcut for iterator access.
the for loop IS the for-each loop. and for-each loop isnt the same as a foreach loop.
Javac desugaring ✨
WH-
WHY WOULD YOU
WHO THE FUCK
WHO SEPARATES TWO DIFFERENT CONCEPTS VIA DIFFERENCE OF A HYPHEN?
Do me a favor. Never use "for-each loop" in the context of a for loop.
You will confuse multiple people and make yourself look like a retard.
a for statement, a for-each loop or an enhanced for loop. but not just a for loop
welcome to java
xD
When I uncomment the second line, tasks inside of the MenuHandler class, register twice
Like that
Because you register the class twice.
you are not instance checking the inventory in your events
Then how do I register ConfirmMenu as well
Do what Elgarl suggested
You need to compare the inventory you create for each GUI is the actual Inventory thats being interacted with in your event.
am i not already?
You are creating two GUI classes so each should only handle the events for its own Inventory
So you suggest me to just not have a MenuHandler class and do their events inside their own classes?
Yes, you are registering each as an EventHandler, so each should handle their own events.
uhh gime a second
Usually you would only register one single menu handler that handles all menus.
With something like a Map<Inventory, GUIHandler> inside.
Your ConfirmMenu shoudl only handle its Inventory as shoudl CreateMenu
Because registering one handler for every GUI scales bad. Its just stacking a ton of equals() calls.
Also imagining rebaking the entire listener map every time
You have one event that matches the Inventory from teh map, then executes code in its associated handler
Inventory instances are persistent while used by the server
Map<Inventory, GUIHandler> <- Then call get on that and check if the return value is null. If not then pass the event to the handler.
Any class
Just something that encapsulates your logic
For a specific gui being clicked
ah ok
and accepts the event when passed on
Idk. Could be as simple as
public interface GUIHandler {
void handleClick(InventoryClickEvent event);
}
Scalability, robustness performance. And its way more dynamic,
even a boolean so yoru main event handler can set the canceled state of its return
can u show an example if u can
Deep down it should just be java Consumer<InventoryClickEvent>
im pretty sure the guy who asked the question didnt get anything and neither did I lol
lol
But you can also combine handler for opening, closing and dragging inside if you want to.
In a composition pattern that would just be a class with a bunch of consumers for those events.
We basically ended up with, rewrite all the code 🙂
Or you just use a sweet interface framework
And enjoy that a bunch of half decent developers used their brains
For cute API
wait
was he doing that
you can just check for the inventories in one event tho, right?
e
The event inside of the CreateMenu class doesn't work as its supposed to open an Inventory from the ConfirmMenu
Yeah each GUI class has their own event inside of them
And I'm registering them inside of my main class
this is my main class if thats what u mean
oh wait, i made a mistake specifying the inventory title
a typo
lemme see if thats causing it
why a listener for each gui?
then i have to make an instance of each class inside of the other one
would a .equals actually matter here?
in order for them to specify the invetory name
if you do an identity comparison (==), what changes?
you shoudl already have the Inventory instance in yrou class
idk
I am making explosives pick axe whick brakes in radious
What will bes way of braking blocks in radious calling blockbrake even by my self for e ery block in or should i just set them to air
I am thinking if i call event for every block that will make heck can that block be broken or not that could save me time
Os some body have some siggestions?
you compare object with equals
not exactly
sometimes it doesn't work if you compare object with ==
@eternal oxide what do u think abou it?
there's a major difference between == and equals
== compares by the instance (aka "by identity")
equals (overridden by a class) compares by value
@summer scroll if u use equal it can break cose if object is null
is this gonna work?
well actually lemme try
Objects.equals can be used then
simply just null check it
why null check when you can combine the null check with the comparison? :)
you might want to re-think the design again i think, because ideally you would have only 1 listener for all of the guis
@lavish hemlock like your way of thinking 👍
I optimize things :p
and thats my question. i made a menuhandler to handle every single GUIs' events
so null checking will make the code less optimized?
and that caused multiple registrations
ofc not
it's less optimized by a readability standpoint
not a performance standpoint
and btw, this error pops up whenever i click an empty slot (air) of the GUI
do i just make it
case AIR:
break;
?
null checks would actually be slightly faster than calling a method since method lookup and shit takes longer than a comparison
just check if clicked item is null
to be more specific here: == compares the adresses of the objects instance in the heap. if its the same its simply the same object and true
@eternal oxide thanks
or you turn that messy spaghetti code into clean readable fabulous ✨ code ✨
bruh it doesnt work
how do you exactly check if its null
case AIR didnt work
neither .isAir
this doesnt work either
@tepid monolith did u return
You're checking if the Material is null, check the ItemStack instead.
Check of item is null
U need to do tha first then
Check type
Step by step my friend
Skiping steps is not good
You will hurt your knees
🤣
could you give me example code?
im just checking the type
getType.equals does the same
Remove get type
doesnt it?
You can't check the type if the ItemStack is null.
oh
So you need to check if the ItemStack is null first.
So dupe your if up and just remove vettype from it
And that is done
Tben check if type if null
If you want
But no need for it
If item stack is not null
alr so a type cant be null
Just check does it correspand
so i just gotta check if the getcurrentitem exists or not
Bwtf
wtf
wtf
lol what
if(event.getCurrentItem() == null) return;
LOL return
what
do you know basic java
learning java at the same time...
I know it's really annoying when people tell you to learn java
but like
yeah good luck either way
you'll learn it just with using spigot
thank you
Here is the example you asked for:
https://github.com/Flo0/SpigotSandbox/tree/basicGUIExample
Its really basic. Normally you would enhance this with delegating the event to a wrapper class containing the ItemStack and a Consumer<SomeEvent> but this
example is more clear.
invisible items??
can i make a new class where i make item stacks and recipes?
if so what would go here?/
?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.
nvm i think i got it
oh ok
Could not load 'plugins/main-1.0-SNAPSHOT.jar' in folder 'plugins': uses the space-character (0x20) in its name
hm
?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.
absolute confusion
think thats beter https://www.baeldung.com/java-class-file-naming
You meant https://www.oracle.com/technetwork/java/codeconventions-150003.pdf right?
Hey, I would like to clear an empty glass bottle if dropped in the PlayerDropItemEvent
But so far the only way I got this working is by caching the entityId of the itemDrop and to cancel it's spawn in the EntitySpawnEvent but i'm pretty sure I could avoid using the EntitySpawnEvent, any ideas ? 😒
;-; why entitycombustbyblockevent doesnt apply for items in lava
is there a way to detect when obsidian is formed?
ive tried:
-blockformevent
-blockgrowevent
-blocktofromevent
none of the work
the first 2 dont even fire
and yes i have them registered
already tried that
.
Then you're doing something wrong, because it's the BlockFromToEvent
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockFromTo(BlockFromToEvent e) {
if (e.getBlock().getType() == Material.WATER && e.getToBlock().getType() == Material.STATIONARY_LAVA) {
e.setCancelled(true);
}
}
doesnt work
Does your version not have event.getItemDrop()?
Debug and print out the values, could it be flowing water?
It does, i have tried ```java
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
if(e.getItemDrop().getItemStack().getType() == Material.GLASS_BOTTLE) {
e.setCancelled(true);
e.getPlayer().getInventory().remove(e.getItemDrop().getItemStack());
}
}
why would you cancel it?
Instead of cancelling, try e.getToBlock().setType(Material.DIRT); if that works then it can't be cancelled, if it doesn't then either your if statement failed or the event isn't registered
delete it all and set the itemdrop to air
from is always stationary and to seems to be air or flowing water
not sure what to make of that
yes but wouldnt changing that result in it triggering when water flows anywhere?
well you just said e.getToBlock().getType() is air or water
but in your statement you use e.getToBlock().getType() == Material.STATIONARY_LAVA
yes but changing that would make it fire when water is flowing anywhere
if i change this the statement will be true no matter if there is lava anywhere or not
and even then a fromToEvent wont cover it
since you can make obsidian by placing lava like so and that wont trigger fromTo
Setting the getItemDrop type to air throws stone
What are you trying to do?
Look at BlockFormEvent if you want to control formation of cobble/obsidian
i already said i tried that
it doesnt fire
.
In that case you just cancel the BlockPlaceEvent
true that would be an option
BlockFormEvent works
The javadoc does say it handles "Obsidian / Cobblestone forming due to contact with water. " but all I can find online is people complaining it doesn't work for some reason.
it's not working for me :/
i have it registered and annotated
What spigot version are you on?
1.8.8-R0.1
Support was dropped almost half a decade ago.
Use ancient software -> live with the bugs that will never get fixed
or fix them by yourself
If you value your time this low then sure
Everyone, do we prefer javax.annotation.Nonnull or org.jetbrains.annotations.NotNull?
or lombok.NonNull 😉
spigot themselves use jetbrains'
def jetbrains for me. If you use intellij then you get nice support for them.
@lost matrix
Thanks for the input all

I kind of figured out how to do it
🤣
ok so if i do somethin like
int warn = 0;
does that warn ver - if i modify it woud it be diffrent for each player?
no
it would be the same for each player
or everytime a new one if its a local var
oh so how could i make it so its diffrent for each player?
Create one instance per player and save it in a Map<UUID, YourDataClass>
👀👀
Think again
good point
Not really. In fact not even close. Try to create a sandbox project and play around with maps so you understand how to use them.
yea, im trying to add a warn system to my plugin , i thaught it would be easyer lmao
The thing is not on the warm plugin
?
😐