#help-development
1 messages ¡ Page 1731 of 1
yeash thats not going to work
First of all the trailing dot must be removed
The arenas. should be arenas
Also i recommend loading the arenas into a list and rhen having a reload command to reload it
When needed
Instead of accessing the config the whole time
For performance and code cleanness
it worked when i removed the return in all the if statements but now it is applying to player inventories, when i re-add the return it doesn't work anymore
Map<String, Arena> arenas = new HashMap<>();
public void reload () {
arenas = ...; // Convert config section to hash map
}
public Arena getArena(String n) {
return arenas.get(n);
}
Something like that
Nice
accessing the config isn't bad, as its already loaded in memory as a Map, but it is slightly slower then using your own list/map
True
so one of your conditions is broken, remove them one only at a time to see which one causes the issue and then troubleshoot
But its cleaner
yes
oh no
what have those people let themselves in for.
will it blow up their microwave?
how can i stop runnable? if someone moves
in the move event runnable.cancel()
Have it rely on a boolean
depending on what type of runnable
Yeah
Sadly not possible
Except if u maybe make the leave button invisible using a forced resource pack
Its will be condusing
Confusing
Not impossible tho
No yiu could have something working
At least make a backup
Its seems like youre already pretty far
Just some bugs?
Really?
Nice
What joining part
Joining a queue or somethinf?
Like a minigame queue?
We can help tou
Your project is just so big already that we need a lot of code
To figure out whats going on
Not saying that starting over is a bad idea
But juwt make a back up
Because youre already rhis far
unless you think you can design it better now
True
less static would be good đ
If the core of the system (rhe framework) is bad, yoy should probably start over
But it seems like it almost works
Just some bugs
How does rhe arena storage work
Send a part of rhe arena manager
I've not see you load any arenas. Only count them
hate to break it to ya but nobodys gonna steal this persons code lol
Good thing
Its not that bad qctually
Could be improved
um for (int i = 0; i <- (Config.getArenaAmount()-1); i++)
Defenitely
also your GameState enum has a typo
Thats a compilation error what
fyi
p u m p
oki
Ok so getArena(int) returned null
This code is wrong. for (int i = 0; i <- (Config.getArenaAmount()-1); i++)
= not -
Thats should be a compiler error
it shoudl but it seems its not throwing one
it will prevent him creating his arenas though
it was a copy/paste so unlikely
Because thats not a statement rhe jvm can run
@quaint mantle Show us your manager class again
@quaint mantle bro
Ur forgetting to return shit
In your getArena method
Put return arena; in the if statement
In getArena(id)
Send code to confirm u did it right
Of getarena
No
Wait
Bruh
package com.hitman.minigame;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class Manager {
private static ArrayList<Arena> arenas = new ArrayList<>();
public Manager() {
for (int i = 0; i <- (Config.getArenaAmount()-1); i++) {
arenas.add(new Arena(i));
}
}
public static List<Arena> getArenas() { return arenas; }
public static boolean isPlaying(Player player) {
for (Arena arena : arenas) {
if (arena.getPlayers().contains(player.getUniqueId())) {
return true;
}
}
return false;
}
public static Arena getArena(Player player) {
for (Arena arena : arenas) {
if (arena.getPlayers().contains(player.getUniqueId())) {
return arena;
}
}
return null;
}
public static Arena getArena(int id) {
for (Arena arena : arenas) {
if (arena.getId() == id) {
return arena;
}
}
return null;
}
public static boolean isRecruting(int id) { return getArena(id).getState() == GameState.RECRUTTING; }
}
Paste that
Try it
You see the return arena; in the if statement in getArena(int id)?
You forgot that
It was always returning null
I always have that
Not necessariky while eating
But those stupid mistakes
Everyeone makes them
Really
Oh nice
Nice
Ur doing pretty well
Just work on basic skilks like debugging and reader errors
And basic java unspoken rules like proper use of static and stuff
Good idea
Its not that difficult to learn
It has a few parts to it
Check if it compiled
Otherwise fix the error
Actually it might be what elgar said
You have a syntax error in your for loop
Sorry what
Is it a runtime error
In the server
When you run it
Full error?
The world ur getting from ur config is null
Actually
Try to read and understand the error
No ur understanding it wrong
The world that it returns isnt null
The name you are giving it is null
It doesnt mean that the server cant find the world
It means you cant find the world name
Or well your plugin
Typo
U misspelled arenas
Try to not rush it
Cuz ur gonna make typos
Lmao
Yes
Coding is fun
When you get the hang of somethinf you can do whatever you want
Its so powerful
Can be frustrating though
Ok
Cya
Does it work though
Lmao
Nice
dang there's already a java 17
i'm gonna go ahead and assume that spigot still uses 16
is that correct?
p u m p
Yes
Spigot probably won't update until mojang does
feels like 16 came out yesterday
Whats going on
Didnt u fix it?
Is the event being called?
Ping when u need me
It's called, but now it's not working, the if statement don't work
Send the code
Ok
Use that for big chunks
Okay
not sure
Yes open
Would make sense
i was just trying to make a spring jar and it said 17 not 16 lol
And itâs stable enough
oracle's on fire
Open source projects are so good
Yeah
Cant wait for jdk 18 honestly lol
why
But contributors also help a lot i think
What do you mean âwhyâ?
@proud fiber
Vector API third incubator
Java 17 came out a while ago
Actually
New version of java is always exciting
And also
And utf will be defaulted
Sealed types
Which is very nice
Sorry discord crashed on my pc
Sexy instanceof checks
I am reopening it
Dw
bruh i'm gonna die
Since specifying StandardCharsets.UTF_8 is annoying
so many messages
yes I need pls :-)
Did u try to debug it using println
yep
it worked before if statements
but when i try in if statements it doesn't work
i removed the return and it worked, however it worked in every gui possible
maven related question, but how do i output my plugin directly into my plugins folder in my server dir?
google didn't help
What if statements?
The ones at the start of the method?
Like the ones checking for null?
all the ones in the event
Try using print
ok
Put like "if statement # passed"
No because it doesnt always return
As long as it doesnt give a compiler error ur fine
Put it after the if statements
Not in them
Like the next line
Not after the return
ok nvm it doesnt give unreachable code
Did yoy place it qfter or before rhe first one
The event.getinventory doesnt return rhe clicked inventory i think
You will have to check the inventory views name
wdym?
if (event.getView().getTitle().equals(inventory.getTitle())
hm let me try
Or you can use
if (event.getView().getTopInventory() == inventory)
(I think, havent tested it)
I recommend this qctually
For when you change the title
the last inventory should be inv right?
Did u put in the return statement?
mhm
ok
np thanks for helping me
I'll just recode the whole thing ig
pretty sure i fucked up a line or 2
not sure but paper already supports java 17
worth a shot since updates are happening so fast now lol
Hello so i am making chat messages for my plugin and idk how to add prefixes
public class ChatMessages implements Listener {
public ChatMessages(AquaEssentials plugin){
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onChat(AsyncPlayerChatEvent event){
Player p = event.getPlayer();
event.setFormat("PREFIX " +ChatColor.of(new Color(255, 178, 0))+ "%s " + ChatColor.of(new Color(255, 255, 255))+ "%s ");
}
}
Eclipse đ¤Ž
Why are you using Colour and not being a normal person and just using CC
Pretty sure thats the issue
I find out :)
Is there an alternative to the getNearbyEntites but can run async and not only sync
or looping through all the entites in a world async
How can I make my code run on Buckminsterfullurene atomic usage for my plugin?
The worst thing you can do is loop through entities in a world async im pretty sure, as the worlds is one of the main reasons why you can't use async on most of the api
So is there any way to get an entity async, or is it just a lost cause?
doesn't matter if it has to be done with some sketchy methods
well whats the problem using the above method?
what?
what is the problem with using getNearbyEntites
it runs every time a movement packet is sent with the plugin im making
doesn't sound like the best way to go about what ever you are doing
doesnt sound very performant
thus this
or somehow an alternative way
async will always be wrong, you making some sort of anit cheat?
movements are called thousands of times per second
no they aren't
they are
try it
I have
flying?
Isn't it the entityteleport packet for moving
Doesn't really matter what packet you listen to, still the same result, as in needing to use another method to check movement
is it a speed check or a wall check or a fly check or a fall check
how could i get text between percentage signs
private final Pattern placeholderPattern = Pattern.compile("%(.+)%");
thanks
I might be being dumb, but why do you need nearby entities for a jesus check
does your Y value change whilst running over a boat?
no
no and yes
it fluctuates sometimes
For example, sometimes a player would be in that "glitch" spot if you stand on a boat, it makes you hard to move on it, and the y axis bounces
otherwise the Y axis is the same
the checks are all made, the AC is done, just trying to optimize it in a way where it doesn't kill the server
and the only thing left is that getNearbyEntities problem
Unfortunately, I don't know much but my best guess would be there is way around not having to check for boats
yeah thats what i was thinking too, but couldn't think of a way
well thanks though
?paste
So I was trying to make a hologram called "001" when I placed a block I know its messy but does anyone know why its not working when I place a block https://paste.md-5.net/otekiqapop.java
are there any api library things for spigot in php?
https://prnt.sc/1w27end
for some reason my command is not recognizing the perms... whats the problem?
if(!(sender.hasPermission("etp.use"))){
player.sendMessage("§l§e(!)§r§c You are missing the required permission: §retp.use§r§c to use this command!");
return true;
}
``` this is what i wrote to check for the perms
Whatâs the issue? Perms or the command
its giving me true for if(!(sender.hasPermission("etp.use")))
which should be false because i have the permission "etp.use"
What permission system is that
i just typed it out in permissions.yml
i dont have any plugins managing permissions
Ah, Iâve never used that so ÂŻ_(ă)_/ÂŻ
Is that Pex?
You should use LuckPerms instead because Pex is outdated
But did you list the permission in your plugin.yml or somewhere at least too?
no i dont use any plugins
i just typed out my name and the permission under my name
thats it
it should recognize that i have the permission right?
the permission is in permissions.yml
Ah I see
...so it should work right?
hmm... so its not possible managing permissions without luckperms?
permissions.yml is really not meant to be a proper permissions management system
It was a poor mans attempt at it in early Bukkit inspired by WEPIF. You're most definitely better off using LuckPerms to handle permissions in almost every situation
Will
event.getDrops().clear();
Work for remove drops of the entity that died in entity death event?
oh i see ty
If i were to access a hashmap (or any other collection) inside an asynctask, should i use the synchronized keyword?
or is a nono for spigot
I am creating the collection inside the async task, so i presume it would be fine as other events wouldn't be able to access / modify it?
If multiple threads are using the HashMap, use a concurrenthashmap
Otherwise, if itâs just the same thread, itâs fine
I want to make a plugin that listens to when you move items around an inventory so that it can make the same changes to other invenotr
inventory
what is the best even to use for this
Example if you click on slot 20 to drag the stack around, the item in slot 20 on the other will disappear to and be placed where it was placed on inventory 1
don't use the color symbol
use ChatColor.translateAlternateColorCode()
huh, why?
its a bad practice in general and for future compatibility
oh ok
use a int
then each time the event occur just increase by one
@eventhandler
public void onsomething(somethingcool e) {
i++
}```
ok I have ideas what to do. thanks
if you want the i still have the last number when stop the server
just save it to the config
and change int i; to int i = plugin.getConfig.getInt(paht);
when the config start (or create) for the first time
just add the path is 0
heya
i need some help please
I need help for a project, please can someone help me build some things for my map? ... so I don't know much of English actually and if anyone can help me I would thank you very much
not here.
go #general
thanksđ
hey! has anyone tried developing plugins with kotlin? is it a viable idea, and how hard is it to set up a spigot kotlin project?
Hey, so I have coded a bot which sends discord message to minecraft which is perfectly fine just that it is sending it 3 times even if someone types a message once
Code
@Override
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
super.onGuildMessageReceived(event);
if (botEnabled) {
if (event.getChannel().getId().equals(plugin.getConfig().getString("chatIntegrationChannelID"))) {
if (!Objects.requireNonNull(event.getMember()).getUser().isBot()) {
String format = plugin.getConfig().getString("DiscordToMinecraftFormat");
assert format != null;
format = format.replace("{user}", Objects.requireNonNull(event.getMember()).getUser().getName());
format = format.replace("{message}", event.getMessage().getContentRaw());
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', format));
}
}
}
}
I asked this question before too at that time I was asked to check if my bot was running 3 times but it is not the case, the bot is only running by the plugin
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
maybe because you are calling super.onGuildMessageReceived idk
or your bot is running three times
No it is not running three times, I have checked it
then try removing super.onGuildMessageReceived
how did u check it
im assuming ur using JDA
ive used it to make a bot once
I mean it is in my plugin so ofc it will be in JDA
ik but JDA is the most used once
It is easy,
1st I checked if the bot is running by some other plugin or anything, I stopped my server to check if bot is still online if not then it is not being used by some other stuff
2nd It is my bot so ik I haven't used it elsewhere
3rd I also have a system where it sends in game message to discord and if bot was running 3 times then it should've sent the same message three times on discord too
ok
try removing the super.onGuildMessageReceived
do you have multiple listeners registered
or multiple instances of the same one
which could explain it
I do have multiple listeners registered but not of the same one
do any other listeners listen to this event
I don't think so but let me recheck because I was doing some stuff with that class
And also this thing was working fine before
what
Then I did something idk what and it started sending 3 messages
hmm let me check
wait
could it be because I am trying to register 3 different listeners in 1 try catch statement?
can you send the code where you register it
oh wait let me try something
Nvm it didn't work and this is not the case
why are your variable names camel case
why do they start with capital letter
change them first of all could mess with types
as cthey are also camel case
yes ik ;-; I will change them
also those register statements dont throw a LoginException
Done changed
can you send me your whole Discord class
thats the discord listener right
al least the constructor, declaration and event handler method
I recommend changing it to DiscordListener
forgot
Fixed it too
can be through dms
if ur scared of people stealing ur code or something
i dont think they will though
I will send you the whole Discord class in your DMs đ
No one would like to steal messy code anyways
better idea to use that
no character limit
dude
you are adding the event listener three times
because you are doing it in ur constructor
so you are creating an instance, then you are creating another instance and registering it
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.415 s
[INFO] Finished at: 2021-10-14T16:46:24+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project bungeecord-chat: There are test failures.
[ERROR]
[ERROR] Please refer to /home/camar/repos/BungeeCord/chat/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project bungeecord-chat: There are test failures.
Please refer to /home/camar/repos/BungeeCord/chat/target/surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject``` any idea what causes this error?
when building bungeecord
im trying to edit the source
Look at test report and see what failed
i didn't get an answer before, so im asking again
hey! has anyone tried developing plugins with kotlin? is it a viable idea, and how hard is it to set up a spigot kotlin project, and how would i do that?
i think bukkit has built in support for java and scala, but not for kotlin
youre probably going to need to use antoher plugin that implements kotlin support
to build it on top of
i see
i dont use scala or kotlin so idk how you would do that
you can straight up use kotlin
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
It is automatically since kotlin is interoperable
thanks
And all three compile to jvm bytecode
Are there any best practices / must-follow conventions for NamespacedKeys?
I'm adding custom crafting recipes from a config file in a loop.
Can I just give them NamespacedKeys like custom_recipe_1 custom_recipe_2 or custom_recipe_randomString ?
Or is it essential that recipes get the same NamespacedKey again after a server reboot / changes to the config?
Well i don't think theres any definite naming convention, but since namespacedKeys are plugin dependent its really up to you. I don't think it matters all that much
It has a regex
Which you must follow
Iâd avoid numbers also
how does one utilitze Bukkit.getScheduler().scheduleSyncRepeatingTask(); to run scheduledTasks.SQLAutoCheck() once every 5 minutes?
does anyone know what the formatting is? im just finding what looks to be a lot of wrong info from deprecated usages/methods
the page also describes repeating tasks
is it a good way to store coords in a yaml (including the world object) and get it later from the yaml file?
World dest_w = (World) locations.get(dest_name+".w");
Double dest_x = (Double) locations.get(dest_name+".x");
Double dest_y = (Double) locations.get(dest_name+".y");
Double dest_z = (Double) locations.get(dest_name+".z");
``` Im doing something like this
and FileConfiguration locations = YamlConfiguration.loadConfiguration(file);
So long as yoru world is loaded just store teh full Location
its already serializable
You can set a location to a path and the get then location through.getLocation
Location loc = player.getLocation();
config.set("spawns.1", loc);
config.save();
loc = config.getLocation("spawns.1");```
Exactly like this, yes
AHH
i see what you mean now
i dont know why i didn't think about that, i instead get every x, y, z and planned to make a new location class
thanks for the help!!!!
how can I update a score in spigot 1.17? (scoreboard)
Is it possible to tell a particle to go immediately? It just looks completely stupid if you have wings made of particle and then move around
I know
But i rhought there was some kind of special kotlin based api u needed
But thats optional
As ive just learned
what's the best way of getting messages? storing them in a map or something?
No
is there a way to set instead of the ping in the tablist a custom value?
Locale
Oh yeah you do need to shade in the kotlin stuff
yea
with packets
idk if possible with bukkit
Does anyone know which one is which?
ye
Yep
why they changed it to abc đŚ
obfuscated
Yeah
Hey guys how can i set inventory contents before running the command? e.g. i use a tool to open the inventory đ
It's almost impossible to work with them now
use mappings then
Thatâs the intention behind obfuscation
I was going to do so before you answer
So why do allow plugins đŽâđ¨
Wym
because mojang
use mappings
Yeah if you're doing extensive work with NMS you should use Mojmaps
I like the "MojMaps"
đ
mapping is like using a map (aka a dictionary, you can also see it as a dictionary)
you bind something to a value, like a key value pair
in the case of code mappings you bind the obfuscated symbols to the real names to make it much easier to work with them
you basically get access to unobfuscated source
its like a dictionary actually
ChatMessageType.a
ChatMessageType.CHAT
I know the mapping đ My profession is with Python and Python is all about mapping and dictionaries
nice
anyone other know a answer?
use mojang mappings
ok
yes this will be enough
wdym by locale?
a locale is a class full of only chat components/messages
For example
LuckPerms has the same format too
you can then import different translations through a config file
into the locale class
the only issue tho is that you wont get access to the same tab complete enums
you'd have to use manually encoded Strings
like getLocaleKey("ERR_MESSAGE")
rather than
Locale.ERR_MESSAGE
But if you have a ton of messages
yeah
its probably better
but you can configure your own tab complete helper right
for commands its really easy
if you are formatting arguments
that would be a bit more complex
cause you need to apply string#format
i was thinking about an enum with all my messages and a default message
i would keep commands one translation yeah
You should use an interface instead
otherwise it would be way too complex
but why an interface as it are only colored strings?
Because the interface has static final values, and also i can customize arguments
for example
my component can accept an argument
and add it into the component
UniComponent<Sender, String> STARTING_VIDEO = (mrl) -> format(
text("Starting Video on MRL %s".formatted(mrl), GOLD));
I pass the mrl inside
and it can build the component with it
In the example I shown above, it would be STARTING_VIDEO.build(mrl)
where mrl is a String
and it can build the component and display message
with the mrl inside the messsage
For example, if I have a command /video set color BLUE
hmm interesting
and you want the user to get a message
You set the color to [COLOR]
which is blue in this case
you can pass in BLUE
and customize the component
Core, i recommend creating a new thread
https://paste.md-5.net/zapavijufi.java
Alright, so.
I am trying to randomise the blocks of a chunk except air and tile blocks.
I get an error: https://paste.md-5.net/bafepowota.java
There
Oh by the way, here's the getAllBlocks function: https://paste.md-5.net/ujahuxeboz.java
but for what is the S used?
NullComponent<S extends Sender>
the parameter can be any subtype of Sender
so how?
thats just a Sender
you can put whatever in there, I just added it just in case if i wanted to support other platforms or smthing
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(a.getId(), a.getDataWatcher(), true);
^^^^
what is that true at the end of code
what will change if it is false
hello, with my plugin I'm listening to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/PlayerDeathEvent.html#getDeathMessage()
then replacing the mob's name with something else then updating it with https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/PlayerDeathEvent.html#setDeathMessage(java.lang.String)
a person who's on a russian server says this is causing all the death messages to be in english instead of russian.
Does calling setDeathMessage somehow override the language it would've normally used?
without my plugin
with it:
thing is all i'm doing is a string replace from zombie to lvl 25 | zombie for example
not sure why it changes the russian version of was slain by and others
he claims removing my plugin fixes it
that modifies your message
what server version
bump
The error tells you what's wrong, you're trying to access coordinates -144 within a chunk; while the chunk only has a domain of [0, 15]
java.lang.IllegalArgumentException: x out of range (expected 0-15, got -144)
1.16.5
but in other nms versions 1.8.8, 1.9.4 and.... this boolean is needed
Yes. and return a list of the blocks in the chunk
Then your loops should look like this (1.17 with support for the extended world height):
World world = chunk.getWorld();
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();
for (int x = 0; x < 16; x++) {
for (int y = 0; y < maxY; y++) {
for (int z = 0; z < 16; z++) {
Block block = chunk.getBlock(x, y, z);
...
}
}
}
um... just by looking at it, i can't tell entirely what it does
but what i know is its not irrelevant
sorry for not being much of a help
@alpine urchin @quaint mantle the boolean indicated whether the data should be force updated
you likely want this to be set to true.
what do you mean force updated
?
flush everything or only dirty data
wait
i dont get it
what do you mean force updated
update ?
changing for example metadata
?
just set it to true
it should be
int y = world.getMinHeight();
in the for loop
._.
ah you're right, was thinking of the individual chunk sections. They always start from 0.
in 1.18 they wont be anymore :p
They do ^^
u added support for the world height in your maxY equation
but that would cause an overflow
chunk sections start from 0 -> ((minBuildHeight + maxBuildHeight)/16)
thats currently in 1.17
in 1.18, this might be different
also
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight(); // will cause an out of bounds error, replace with
int maxY = world.getMaxHeight();
1.18 i mean
Hello, I'm trying to make a gamemode command but I have a problem, I want to make that /gmc puts you directly in creative mode but I have to do /gamemode gmc, can someone help me in that?
if (label.equals("gmc")) {
p.getPlayer().setGameMode(GameMode.CREATIVE);
p.sendMessage(PrefixUtil.prefix + "Setted game mode creative");
i made that in this way
and i registered gmc as an aliases of /gamemode
where you get this ascii image
yo real quick, on Entity.getUniqueID(), does it return a UUID that looks like cbf8d615-b440-49cc-90de-9e66d7c8ac53 or does it not contain the -s?
None
Itâs just stored in bytes iirc
Whether it uses - or no - depends on the format you want to use when stringifying it
But iirc by default the - is included in toString
UUID#toString contains dashes ^
hello! how can i get the distance between two blocks?
distance is basically sqrt(distanceSquared)
so it might be heavy cause of the square root
my listeners aren't activating at all this is my main class: ```java
public class Main extends JavaPlugin {
public void onEnable() {
getCommand("flystick").setExecutor(new FlyStickCommand());
Bukkit.getPluginManager().registerEvents(new FlyStickCommand(), this);
}
}```
this is my listener ```java
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
if((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && e.getItem().equals(Material.STICK) && e.getItem().containsEnchantment(Enchantment.KNOCKBACK)) {
Vector v = new Vector(player.getEyeLocation().getX(), player.getEyeLocation().getY(), player.getEyeLocation().getZ());
player.setVelocity(v);
} else {
return;
}
}```
can someone help me?
player.getEyeLocation().toVector()
how do you know its not activating
because when I right click my stick it won't do anything
That is not how you compare materials tho
You'll need to actually get the items type
Your ide should be yelling at you anyway
it isn't tho
Sounds like a bad ide/disabled warnings
Lol
getItem returns an item stack
getItem().getType() returns a Material
oh k
Constructing it using the X y and z of the players head location makes no sense
where the player is looking
E.g if the player is at 0,0,0 with their head this would give you 0 velocity
that fine you have to look up to be able to fly
There seemed to be a lack of good guides on how vectors in minecraft work. So here is one now. :)
Index:
- About this.
- What is a vector?
2....
helpful guide
Probably look at Location#getDirection
can help you achieve your goal
player#getLocation#getDirection?
Yea
Also give the tutorial a read as you don't seem to know much about vectors yet
Bukkit.getPluginManager().registerEvents(new Command(), this);```
Interesting name for a listener class
just made it up
actually it is a ComandExecutor
thats where the listener is located
this does work right?
Yea looks good
k thx I am gonna make fixes and test now
does an enum constructor has an access modifier?
heyo, does anyone have an idea for a good clickable / hoverable text thing? i know that was a bad explaination but i mean like Skript, where you can do "tooltip:hihello<reset>" and then if you hover over on hello you will get a tooltip saying hi
Look into Mini-Message and the adventure platform maybe ?
what are those?
Mini-Message has a similar style
yes
Yea
i don't really understand the usage example
do you know how to just make the skript one? it's very easy to use
đŞđŞ
does anyone know how to do it? pls i need help i am big nub
MiniMessage has a very similar syntax
smh how is this valid
Class<?>[]... a
an array of classes
hi
how can i add latest mongodb driver
to spigot plugin
anyone know how to change the anti cheat in the spigot server?
I have a flying plugin
does this looks good?
https://paste.md-5.net/usagacezeg.cs
after like 6 hours i finally did it, it was so frustrating for such small thing.
here is the line of code for the first if statement if u are curious, hope it helps u one day:
if (!((event.getView()).getTitle().equalsIgnoreCase(ChatColor.RED + "" + ChatColor.BOLD + "Choose the superhero"))) {
HELP why is the onPluginMessageReceived Event for me not working? Im Using the newest BungeeCord Version. https://paste.md-5.net/wukoducuni.cs
Please donât compare inventories by title
Use the view returned from openInventory and set.contains
Bro please I've been trying all methods for the past day
I've searched internet
Youtube
Spigot
Everything
And that's the only way i managed to do
Comparing inventory by titles is a sin
Well
you should be using inventoryview
That's easier
İ get NPE now. java.lang.NullPointerException: Cannot invoke "org.bukkit.block.Block.setType(org.bukkit.Material)" because "b" is null
its not. You just use == on inventoryview
Here's the updated code: ```java
public static Block[] getAllBlocks(final Chunk chunk) {
World world = chunk.getWorld();
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();
final Block[] amount = new Block[16*maxY*16];
for (int x = 0; x < 16; x++) {
for (int y = 0; y < maxY; y++) {
for (int z = 0; z < 16; z++) {
Block block = chunk.getBlock(x, y, z);
BlockState state = block.getState();
if (block.getType() != Material.AIR && !(state instanceof TileState)) {
amount[y*16*16] = block;
}
}
}
}
return amount;
}
@EventHandler
public void onMove(PlayerMoveEvent e){
if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
if (!(chunks.containsKey(e.getTo().getChunk()))) {
chunks.put(e.getTo().getChunk(), true);
Block[] blocks = getAllBlocks(e.getTo().getChunk());
for (Block b : blocks) {
Material random = Material.values()[new Random().nextInt(Material.values().length)];
if (random.isBlock()){
b.setType(random);
}
}
}
}
}
Is there a difference?
When
Uhhh
Is that suppossed to fix my problem?
If there is another GUI with the same name, if your GUI names are not correct (comparing GUI names with color codes is very bad)
Use reference equality on InventoryView
oh I didn't think of that
Oh
How do I do it then
So there is nothing in the list?
HELP why is the onPluginMessageReceived Event for me not working? Im Using the newest BungeeCord Version. https://paste.md-5.net/wukoducuni.cs
I am heacking confused rn
No, there is a null in the list
can anyone help me?
Alright, I updated the code. Now the server just freezes.
public static Block[] getAllBlocks(final Chunk chunk) {
World world = chunk.getWorld();
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();
final Block[] amount = new Block[16*maxY*16];
for (int c = 0; c < maxY*16*16; c++){
for (int x = 0; x < 16; x++) {
for (int y = 0; y < maxY; y++) {
for (int z = 0; z < 16; z++) {
Block block = chunk.getBlock(x, y, z);
BlockState state = block.getState();
if (block.getType() != Material.AIR && !(state instanceof TileState)) {
amount[c] = block;
}
}
}
}
}
return amount;
}
i'm looking for something in an enum so you can set a boolean in the values and that would mean a method requires parameters
but i cant force taking parameters
what is the point of that outer for loop
the one with c
i think the server freezes because you are trying to run 16*16*16*16*256*256 iterations of a for loop
remove the outer loop
4,294,967,296 iterations per chunk
or do it async

right. i fixed it.
public static Block[] getAllBlocks(final Chunk chunk) {
World world = chunk.getWorld();
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();
int c = 0;
final Block[] amount = new Block[16*maxY*16];
for (int x = 0; x < 16; x++) {
for (int y = 0; y < maxY; y++) {
for (int z = 0; z < 16; z++) {
Block block = chunk.getBlock(x, y, z);
BlockState state = block.getState();
if (block.getType() != Material.AIR && !(state instanceof TileState)) {
amount[c] = block;
c += 1;
}
}
}
}
return amount;
}
```No, but it's pretty laggy
Well yeah, you are looping over entire chunks
if you need the index
try to do some optimizations
Mmm
arrays are the fastest with insertions
I am confused
they just set memory
It seems stupid to have a fixed size array
nah
HELP why is the onPluginMessageReceived Event for me not working? Im Using the newest BungeeCord Version. https://paste.md-5.net/wukoducuni.cs I think noone will answer :/
it excpects a full array of blocks
Yep
it excpects a full chunk of blocks as return type
its on the bukkit developers to improve it
or mojang
whoever wrote that shit
yeah i can see that, meh what i would do is use a list and then just grab a chunk snapshot before hand and run it async
I am only adding it to the list its not air
u mean like a schematic
oh
yeah
smart
what are u using the method for
@regal moat
the getAllBlocks
is there a way to force this method to take a parameter when some value in my enum is true?
also the Block#isEmpty() would probably work
just check if the args size is over 1 and otherwise throw an IllegalArgumentException
no way to do it at compile time
yea but the user doesnt know if he has to specify an arg
if he doesnt it will look like "player {0} not found"
mmm probably have to make a way around
???
so the user knows he has to specify args
@EventHandler
public void onMove(PlayerMoveEvent e){
if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
if (!(chunks.containsKey(e.getTo().getChunk()))) {
chunks.put(e.getTo().getChunk(), true);
Block[] blocks = getAllBlocks(e.getTo().getChunk());
for (Block b : blocks) {
Material random = Material.values()[new Random().nextInt(Material.values().length)];
if (random.isBlock()){
b.setType(random);
}
}
}
}
}```
since when are biomes 3d
instead of just warning aftet that
why tf are u calling that every time someone moves
what are u trying to accomplish
1.15
But itâs not used in the overworld until 1.18
No. I am calling it everytime someone enters a new chunk
Yes

lemme look at the chunk class
seems very inneficient
Randomising the chunk
Every block of the chunk
randomised
Well, to not to randomise the same chunk over and over again
I am adding the chunk into a hashmap
And checking if the chunk was entered before, before running the code
please tell me you are not storing the chunk in a hashmap - and are using the chunkkey or sommin
uh oh
Why not randomize the chunk on generation
Maybe because I don't want that
@EventHandler
public void onMove(PlayerMoveEvent e){
if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
if (!(chunks.containsKey(e.getTo().getChunk()))) {
chunks.put(e.getTo().getChunk(), true);
regenerate(e.getTo().getChunk(), new Random());
}
}
}
public static void regenerate(Chunk c, Random r) {
// get world
World world = c.getWorld();
// get min and max height
int mn = world.getMinHeight();
int mx = world.getMaxHeight();
// get material enum info
Material[] v = material.values();
int l = Material.values().length;
// loop over blocks and set them to random material
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = mn; y < mx; y++)
c.getBlock(x, y, z).setType(v[r.nextInt(l)]);
}
}
}
they probably want it to change every time someone walks in
@regal moat try that
the code above
static long getChunkKey(int x, int z) {
return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
}
should be more than twice as fast
Map<Chunk, Boolean> hasBeenGenerated i expect this is being used lol
no
Set<long> hasBeenGenerated = new HashSet<>();
doesnt matter when using a hashset
it stores hashes
and a chunk is a reference
same size as a long
i think
?paste
public HashSet<Long> generated = new HashSet<>();
static long getChunkKey(int x, int z) {
return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
} // using olijeffersOn's key function
@EventHandler
public void onMove(PlayerMoveEvent e){
Chunk chunk = e.getTo().getChunk();
if (!(e.getFrom().getChunk().equals(chunk))){
long key = getChunkKey(chunk);
if (!(generated.contains(key))) {
chunks.add(key);
regenerate(chunk, new Random());
}
}
}
public static void regenerate(Chunk c, Random r) {
// get world
World world = c.getWorld();
// get min and max height
int mn = world.getMinHeight();
int mx = world.getMaxHeight();
// get material enum info
Material[] v = material.values();
int l = Material.values().length;
// loop over blocks and set them to random material
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = mn; y < mx; y++)
c.getBlock(x, y, z).setType(v[r.nextInt(l)]);
}
}
}
remove the statics
ur still using the inefficient getAllBlocks