#help-development
1 messages ยท Page 2087 of 1
when ur in a conversation with an npc ur chat is only the dialogue and then it switches back to regular chat when its over
mmm
I gotta rewrite some code in a plugin which still uses the bukkit conversation api ๐ค
it's been on the server since 2013, and I recently just refactored the code to use the new (by new, I mean it was made in 2017) command framework
maybe chat system with channels is good?
I made a very very very simple & weh weh version of a chat channel plugin we use on our server, because my friend wanted to test chat ranges in one of his builds on his build server ๐ค
take a look at this https://github.com/sVoxelDev/sChat it's pretty good imo
but rip user's chat log
can't imagine how that'd look if you played on a smaller chat size
can you cancel an event from another function that you pass event into
i think you can, yes
yes
As long as it's not async
like you register an event callback OnBlockPlace
then pass the blockplace event to another function
and modify it there?
do you think its a smart idea to use a plugin from someone else and then attack its data structure?
you didnt say that anywhere before
that is what is supposed to happen
fork WorldGuard and change it
it's always going to do that
i have the library installed and it still errors
send pom
pom?
having trouble shading CustomBlockData, Intellij seems to recognize the dependency, but it raises a NoClassDefFoundError
https://paste.md-5.net/apebojehet.xml
its the minimize jar plugin
?
lol
i dont think its that line i think its the plugin, i changed a setting and it worked
looking for it
actually
why are you even relocating it
shouldnt alex get his credit?
idk
seems dicky to include someone elses code and at the least, not even put it in the directory that specifies the author
whats a pom
it says to relocate it
and how do i send it
im using gradle
since when do we have to override callbacks? aint they hooked automatically by the api?
idk im following tutorial
remove the override annotion
ok but how can i fix the import issue
why its hooked automatically
is it tho
its for clarification
and in older java versions its required
go into any project with abstractation and you will see @Override
realizes nitro runs out in 2 days
thats tough now why isnt it working
did u just
download the jar
i added it as the thingy
its in dependancies
of what
on spigot website
of intellij
well as for me i just ever let the parent class JavaPlugin handle these standard callbacks but i also use the latest version of the jdk
yeah no. add @override
gradle dependencies or literally just project dependencies?
if i really wanted to argue i'd just @ choco cause he can explain everything
gradle has build.gradle and stuff
it doesnt. also havent tried building yet as intellij shows an error
nah id pass on arguing over that
it shows in both
this doesnt even include the spigot jar
its just dependencies
oh
im pretty sure its for building spgiot
show where the thing is
not actually running it
where do i get the spigot jar then
anyway its weird
screenshot
?bt
or just add it as a dependency in gradle
on the one hand it recognizes the JavaPlugin class
which is way easier
do i have to build it?
no
you dont have to
on the other hand it doesnt recognize its members?
just add it into your build.gradle
probably should show him how to do that
lol
ok how do i do that
i hate gradle thats the main reason why im only a spigot dev and not a fabric dev
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
or a forge dev
it requires you to use gradle
i think intellij does it automatically, the thingy i added before is in build.gradle
plugins just need to port to fabruc
oh u can?
dont forge servers require their playerbase to have well forge installed?
nah its not like thats how modding works or anything
if forge wasnt required on both ends
- minecraft would be a virus
- spigot or any server fork wouldnt exist
how long does building it take
technically it could be faked as its just a packet spam that keeps the client and server together
oo
you said to build
lol i was just checking through channels and found a spammer
im so confused rn
little child
not u the kid in the screenshot
i figured lol
anyways @quaint mantle ya figure out what u did to fix the maven stuffs
so do i just put the build output as a dependency?
i have no idea what ur saying ยฏ_(ใ)_/ยฏ
might as well just use maven
guy on another server said to use gradle its easier
ok its done building @quaint mantle
how is gradle easier
didnt work
maven > gradle > building the dependencies yourselves
@ivory sleet
ok for me the problem was i didnt specify the execution phase, like clean package
are you sure the build command contains package
i am creating a plugin with placeholdersapi but it says Cannot resolve symbol 'PlaceholderAPI'
where?
uhhhhhhhhhh
import it
what am i supposed to do there
I did
then it cant give you that error?
should learn how to program before trying to do stuff with plugins
mmb > mavem > gradle > self
ant >
@lavish hemlock s minimal buildsystem > all
why is it that you can't directly deserialize any map from a yaml config that doesn't have string keys?
what other keys would it have?
i think i found it
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
so what do i do for the package like what am i supposed to define
nothing
like for settings and stuff
its just the build command
oh
mvn clean package
where tho
๐
as in the map i serialised had Location keys and the values were a type i made that implemented ConfigurationSerializable
the type i made deserialises just fine on its own but then when it comes to deserialising the entire map i can't do that because getConfigurationSection returns a Map<String, Object> and i have no idea how to convert those string keys back into locations
keys can only be strings
still didnt work
you'd have to make a method to turn a location into a legal key string
was this what i was supposed to do
you can remove the mvn, its implied
the other annoying thing is it seems to cut half the location off because
world: world
x: -96.0
y: 83.0
z: -177.0
pitch: 0.0
yaw: 0.0```
became
org.bukkit.Location
world: world
x: -96.0```
when i looked at the value of the string key in the deserialised result
oh
but does that make a difference
just try it
i added it to my build.gradle and the import is erroring heeeeeeeeelp
when i run it i get Unexpected input: '{' @ line 8, column 14. repositories { ^
nope didnt work
idk
do u know gradle syntax
i feel like there should be an easier build system
no
the implementation of a Map is <T1, T2>
just look at the way everything else is , because those brackets arent the right thing
wait i got it
i hate these things {}
they were messed up
still doesnt import though
are u talking about me?
or the other guy
everyone
i noticed that build artifacts and the mvn clean package build buttons do separate things in the build log
when i run it it just does gradle heeeeeeeeelp
not fair cuz i cant send pictures here but np wait
lol
maven is really not that difficult
anyways, what am i supposed to do rn
its slow
its not
idk bro i told u everything i know
mhm
is the clean package exporting to the same place as artifacts?
did you enable threads and increase the resources maven is allowed to use?
just as an idea, put ur locations as x,x,z... and then String.split using ',' as seperator
yes and its still not that fast
returns a primitive array from which u can create ur location
cuz what is clean package actually doing
have you tried using a different compiler?
don't have to use the one mavens likes
my maven builds are usually pretty quick
for most people it is
just annoying how i feel that even if i copy/paste the same pom in a new plugin it doesnt work half the time
but most people also don't realize you can configure maven to be more optimal if you have the resources to give it
out of the box maven is conservative
those darn liberal build systems
at least its not gradle
gradle takes like 10 mins to build for me
also if map keys must be string classes and u put another class the data is prob corrupted but maybe not
gradle takes a while to spool up for me but building its pretty good
also, most people use clean as part of the default build
using clean will remove half the benefits maven has
most of the time you don't need to use clean
i dont even know if clean is actually building to the same place as the build artifacts button
that could be a reason it doesnt work
clean just removes existing build directories
maven can do incremental building
but if you use clean you remove the benefits of incremental building and caching
because i have it set in my project settings to build to my plugins folder
but idk where the maven builds
target
clean is a life cycle that removes the entire build directory
is there a way to change that
probably
why do i still need to run buildtools to have a local maven repository? like whats the advantage?
id check maven-jar-plugin configuration
you don't need build tools for local maven repo
but putting the spigot repo as dependencies yada yada throws errors if i didnt run buildtools for that version of the server
build tools just conveniently installs the api to your local maven repo because that is one of the few areas when using maven to build your project that maven will look at to see if you have dependencies already there
hm
its not
Hey guys, I have an issue. My plugin for some reason doesn't work on ApexHosting. What can cause this?
error?
generated-sources just has an empty annotations folder
Apex Hosting can cause this ๐
doubt that helps though
yeah no youd see a jar like right in the first level of the folder
did u restart the server
I'm getting this from one of my plugin users
(not me cause i dont have an apex server)
ur running mvn package right
like to build
server version is 1.18.2
You need 1.18 in your plugin.yml
not 1.18.2
oh
did you even test your plugin
:p
lol
@arctic moth
wut
clean package*
u can just package smh
i am
hmm
Can someone compile a modified plugin for me?
package doesnt clean though
no
like @noble lantern said. you specify the major version not the minor patches
u dont need to clean tho
):
i have clean package
always gives errors without cleaning on my end
says theres already an existing archive
for me thats never happened im just trying to figure out why CustomBlockData doesnt wanna shadow
isnt customblockdata just pdc for non-supporting block types
am i right to asume that pdc just accesses nms methods and namespaces the keys?
idk
i mean basically just namespaces the keys by plugin instance
i guess
kinda
why not decompile server and look at source ๐
so i could access pdc values with nms methods if ik the namespace ? :P
ye
you can access them just by getting the plugins instance you want to use
without nms
pdc is just a bukkit front for nbt isnt it
just trying to understand what pdc actually does
main point of the pdc api is the resistance towards changes, lets say minecraft dont want to use nbt and snbt anymore
in that case pdc could stay completely unaffected
snbt?
myes
because the backend would be adapted by spigot and we dont feel the difference yaya
string representational nbt basically
but see i dont think this is actually building to anything
it takes about a fifth of a second
i doubt even saving an empty txt is that fast
no need. the buildtools leaves all class files as java files from the bukkit api
buildtools does the decompiling for u yes
i mean it leaves the entire bukkit api
as source files
so u can look any bukkit class up at any time really
where lol
in the target/src/bukkit/org or whatever its called directory
wherever u ran buildtools
i dont have anything like that in my target
idk would have to look it up
this is my entire target folder
but ive searched it recently to find out how to tabcomplete commands
and figured that JavaPlugin has a member for it
xD
ye
so
basically the fallback cmd executor + tab completer for all commands declared in ur plugin yml iirc
yes
x)
ye no worries lol
ive noticed that it has the library in external libraries
i just dont know why its not in the build
yea basically what happens in the plugin.yml is that all specified commands get put into one command executor
so where for vanilla commands every command has its own executor
every plugin has one for all of its commands
so technically
are you getting cnf exception?
yuh
every plugin is one command
no
has*
gradle or maven?
or whatever the setting is called in maven
this isnt the issue
oh
i mean
maven
u can try and remove that
and it would probably work
but that wasnt the issue for me
lets go i made a functional clear command
epic
@ivory sleet ive recently figured(overridden the vanilla /op command), that a plugins command executor is being handled by bukkit like single vanilla commands xD
and so is the tabcomplete*
still didnt work :(
whats the right way to send messages when the plugin is starting? should i use the logger or is printing fine
logger
ok
the logger is a wrapper
myes
to put everything into log files as well
By default spigot already says your plugins starting btw, but yeah use logger or println function
I know there is a lot of hackery
especially since the underlying system has heavily incorporated brig
whilst bukkit stays away from it
basically every vanilla command is being registered into the command map by namespaced command and non namespaced command
hmmm what to make now
and every command is a VanillaCommand
yes
but thats just to make the api proper
heres my pom if that helps https://paste.md-5.net/wivevinopa.xml
and the ignoreequalscase is just the function "internal" splitter
(it works now, so thanks)
although i cast the cmd to lower case and switch it cause java can cast strings to sha hashes
๐คฃ
wait i dont see how this knows what command is being run...
its just going straight from on command to ah yes clear command
nothing checking it
bad tutorial!!
yea it is. funny to actually see it in action tho that every plugin is being treated as 1 vanilla command xD
mind enlightening me about the issue?
am i being stupid for serializing my permission map? xD
oh
trying to shadow CustomBlockData, getting the NoClassDefFound error
dont blocks have metadata?
no
tile entities I believe
did u have the stacktrace? :p
its just nested function spam with the NoClassDefFound error saying that CustomBlockData isnt defined or smth
ig ill run it again but it lags the server cuz its a nested function
sure
Block.rayTrace(Locationย start,ย Vectorย direction, doubleย maxDistance,ย FluidCollisionModeย fluidCollisionMode)
``` is this new? didnt see it 2 years ago when i needed interpolation
i dont remember it
myes
its a bit new
okay
so do u know that when u use maven you should be getting 2 jars right
at least with the shade plugin
no clue honestly, but possibly
cause like
like in the target directory
original and dependency included
back then ive written my own very precise but poor performance method for it xD
theres nothing in the target directory but a bunch of classes
what maven tasks r u runing
I am creating a custom generation plugin, and I set a chunks biome to DEEP_OCEAN yet there is land there. f3 shows that it is deep ocean to. It is a large landmass even though it is supposedly DEEP_OCEAN. Any ideas? Thanks in advance! ๐
like the build commands?
im just running clean package
i dont think changing the biome would do anything
until after the blocks are placed
ill try ig
I am overriding the default biome provider
and I know it works
so why doesnt it
hey, so i load in a jar from another jar but there's an issue. ( not a plugin, it's a module system im doing kind of? )
jar1 loads jar2
issue is jar2 has a config.yml AND jar1 has a config.yml, and jar2 loads jar1's config.yml
jar2 is loaded on jar1's classpath
URLClassLoader loader = new URLClassLoader(
new URL[]{file.toURI().toURL()},
Plex.class.getClassLoader()
);
InputStreamReader internalModuleFile = new InputStreamReader(loader.getResourceAsStream("module.yml"), StandardCharsets.UTF_8);
YamlConfiguration internalModuleConfig = YamlConfiguration.loadConfiguration(internalModuleFile);
String name = internalModuleConfig.getString("name");
if (name == null)
{
throw new ModuleLoadException("Plex module name can't be null!");
}
String main = internalModuleConfig.getString("main");
if (main == null)
{
throw new ModuleLoadException("Plex module main class can't be null!");
}
String description = internalModuleConfig.getString("description", "A Plex module");
String version = internalModuleConfig.getString("version", "1.0");
List<String> libraries = internalModuleConfig.getStringList("libraries");
PlexModuleFile plexModuleFile = new PlexModuleFile(name, main, description, version);
plexModuleFile.setLibraries(libraries);
Class<? extends PlexModule> module = (Class<? extends PlexModule>)Class.forName(main, true, loader);```
have you shade it?
is there any reason this exception handler doesnt trigger? works in normal java projects but just doesnt work on a server
handler:
private static final Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
Bukkit.broadcastMessage("Exception"); // doesnt trigger
handleException(throwable);
};
public static void start(){
Thread.setDefaultUncaughtExceptionHandler(handler);
Bukkit.broadcastMessage(Thread.currentThread().getName()); // Server Thread
Thread.currentThread().setUncaughtExceptionHandler(handler);
}
exception trigger test:
@EventHandler
public void testException(PlayerFishEvent event){
Bukkit.broadcastMessage(Thread.currentThread().getName()); // Server Thread
Bukkit.broadcastMessage(Thread.currentThread().getUncaughtExceptionHandler().toString()); // correct instance
String a = null;
a.toString();
}
probably since its overwritten
well
if u're willing to jump over to gradle
I'd be glad to assist you
as my field of expertise isnt maven per say
gradle is scary
nah
people just spread fear, uncertainty and doubt
but its really not that bad
well
they're both not bad
try to use version 3.2.4 for the maven shade and relocate it
and use mvn package to build
still not working
Hey I'm new to plugin dev, so forgive me if this is a stupid question but how do you set a wait command which will pause the execution of code in that class?
i checked that in the Bukkit.broadcastMessage(Thread.currentThread().getUncaughtExceptionHandler().toString()); line, and it appears to be correct
runnable
yes
but like
send updated pom
the runnable declared inside the thread could just catch any throwable
yeah thats what i was thinking
Is there a way to override a chunk generator without adding it to the bukkit.yml like shown here
it is updated
which might be annoying
ye
just 3.2.4 in the version of maven-shade-plugin
i mean ur pom file, i want to see after you change it
relocate the thing
why would that do anything
people told me not to relocate it
who specifically?
might as well try
idk imajin i think
some of libs will conflict if not shaded
welp gtg now
ive been on this one problem for almost 4 hours
I thought maven was supposed to, like, be easy or smth
This exact pom has worked with other plugins, but now its just deciding to not work
I kinda wanna learn Gradle sometime for stuff like fabric and forge anyways, so maybe I will ยฏ_(ใ)_/ยฏ
noice, well gl
hey thanks a lot for replying! i also have the runnable inside a command executor, how can i pass my arguments into the runnable?
waut
wait
im stupid
it's pretty easy lmao, i never had that problem but yeah sometimes it's weird
how do i do newlines in a logger or chat message?
Send another message
ok
or with \n
ok
Would ThreadLocalRandom.current() have any performance issues by chance?
Or should i just create a Random instance in my main class and create a getter for it
no not really
but it offers no reproducability
which kinda sucks
so I'd use SplittableRandom
also really fast, even in parallel environments
in case you wanna use it over threads, could go with ThreadLocal<SplittableRandom>
and invoke split on it
Nah im not gonna be using it over threads, im just using a random to calculate how many veins of ore should generate in a given chunk so i was wondering what would give the best performance as it would likely get called shittons when players fly through the world like the nether
For this i don't really thing reproducability would be an issue as i necessarily wouldn't want to reproduce any values just have random ones like here
I'm receiving "An internal error occurred while attempting to perform this command" upon running a command. Compiling is fine. How can I diagnose the problem? Is there a way to see what line it is?
check your console
how do i add custom structures to my custom generator
you would either manually set each block using block.setType or paste a schematic at a given location
pasting schems is the best way
what about if the schematic is too big for a single chunk and the others are not loaded
good question uhm
no idea ngl, i would assume you would have to split the schem into multiple parts
and paste accross those chunks
would be rather complicated
right, dunno why i didnt do that haha thanks
Im a noob with java so forgive me if this is a stupid question but what does this mean:
java.lang.IllegalArgumentException: Plugin cannot be null
It means the plugin instance your are using is not set
Show the command code
I also recommend properly learning java before taking a whack at plugins
Does anyone know why im getting this error in console. For some context im trying to make a respawn packet using protocol lib, I recently switched to 1.18.2 and reused the respawn packet I had when I was working in 1.16, making some slight updates. So far everything else works except this, any reason why?
oh and also how do i make schematics?
respawn.getWorldTypeModifier().write(0, world.getWorldType()); - Line were error occurs
Might be an issue with ProtocolLib tbh
you could create them in game, then upload the files to your plugin and past them using WorldEditAPI
Oh, that really sucks
Might be worth opening an issue on theyre github asking about it
idk if they have a discord
Alright.
mb
plus thats the error
dot
your actual command class yes
oh right haha
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
fyi this issue came up only when i added runnables https://pastebin.com/krBtggWz
that is the class
you never set Plugin
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
pass your plugin instance to the command class, that is that dependency injection is
see that link
yes i do see it
currently reading
oh i see so i needed to write this.plugin = plugin; in the constructor
where in the craft bukkit this is called?
i really need it
or is there a way that i do something like entity.damage(damage, damager) and that event with that constructor is called
Damagable#damage(double, LivingEntity)
that's also not a NMS method either (The one i shown)
wait hold on my bad
thats not a Damageable method
actually it is
okay so how we do it is just getDamager() on EntityDamageByEnetity it procudes a Entity
And using the method you shown damage(damage, damager)
No NMS really needed here
Unless you are on a version that doesnt have that event?
Hey Im really stuck with this code, would someone be down to call and help? I would really appreciate it
uh sure
sweet
?scheduling
https://paste.md-5.net/qebimovalo.java
So I'm randomly getting a location in the nether dependent upon whether or not my code runs into the ceiling or floor
Pardon my math but I can't seem to get the actual location anywhere other than 0.0 86.0 0.0 (Where y always moves but x and z are always 0)
Is this something in the logic of my code that's not letting the x and z values iterate? Or some type of math I'm doing when converting the block-chunks location to a real-world Location?
You already are verified
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.
my own stupidity gets the better of me somtimes smh
i reckon if getX or getZ return 0, then x * 0 = 0
yeah that and on top of it the way i was converting was so wrong too lmao
i did this instead:
Hey what would be the best way to determine if the player has a permission (permission.number.#)
Where # would be any number
I feel like a loop wouldn't be the best way to go about this but thats the only way I can think about getting this info other than using vault
loop is the only way i guess
yeah, I found a nice way to do it with a loop, just finished testing it and it works as well as expected lmao.
public int getNumberedPerm(Player p, String node) {
// Loop through all players permissions nodes
for (PermissionAttachmentInfo perm : p.getEffectivePermissions()) {
// Find the permission node that starts with the desired node
if (perm.getPermission().startsWith(node)) {
// Format node to take into account the extra "."
node = node+".";
try {
// Format the perm to only have the number in it
// Convert the string of the number into an integer and return the int
return Integer.parseInt(perm.getPermission().replace(node, ""));
} catch (NumberFormatException numberError) {
// Let the server owner know that there is an error with their permission
plugin.getLogger().severe("Player ("+p.getName()+") has an invalid permission number, permission name: "+perm.getPermission()+" \nPlayer's UUID: "+p.getUniqueId() + "\nPlease submit the following error to Brand0n_ if you cannot resolve the issue:");
// Print the stack trace to make it easier to debug what happened
// This should never be useful as no one should be putting in something that isn't a number
numberError.printStackTrace();
}
}
}
return 0;
}
Made it so that if it can't find the number or if the number is wrong it tells the user in the console and results in a 0 being sent in its place
can for sure make it loop prettier tho
I would just return 0 if the number is invalid instead throwing an error
yeah that would be better
what do you think about redis as primary database
map.put(player.getUniqueId(), false);
new BukkitRunnable() {
public void run() {
if (!map.get(player.getUniqueId())) {
player.teleport(new Location(player.getWorld(), finalTeleportLocation.getX(), finalTeleportLocation.getY() + 1.0, finalTeleportLocation.getZ()));
map.remove(player.getUniqueId());
}
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
if (map.containsKey(player.getUniqueId())) {
if (event.getTo().getX() != event.getFrom().getX() || event.getTo().getZ() != event.getFrom().getZ()) {
map.put(player.getUniqueId(), true);
}
}
}
```Hello! I am trying to create a cancel teleport on move event using hashmap boolean. Here is a brief piece of the code. See anything out of place? The issue is after moving the TP cancels but you stay in the hashmap.
use putIfAbsent not put, that way you dont need checks and your not possibly putting in duplicate entries
Well I also use a cooldown and messages to tell the user whether they cancelled the teleport, or are in cooldown etc. That is just a trimmed code.
why not mysql or mongodb?
im using arangodb but redis is just better i think cuz i can store Java Objects without converting them to a jsonobject for example yk
and redis is faster
and i use redis pubsub a lot
if you want to store JavaObjects without converting them the MongoDB driver does this
If you use mysql/redis youll likely need to convert
Redis isnt really meant to be used as a persistant database
You can change it to be persistent tho
I dont reccommend it
You can use HashSet maybe instead using Map to store a boolean
Unfortunately that seems to have lagged the teleport. And the player still teleports even though they moved, its just delayed
Darn videos arent allowed here lol.
get verified
Thanks. Thats fancy
Notice that kind of lagged it lol. And the player still teleports now, where as with just 'put' the user only stays in the hash
if map contains player... insert player? wat
im a little confused about that as well lmao
Because when the user types the command to TP they are added to the hash
so the map is like a queue of players to be teleported?
so do u mean to remove them from it if they move
Yes and after the teleport they shall not be in the map
so then remove them on move and on tp id think
In my code I showed above I have map.remove(player.getUniqueId()); when they finish teleporting
Hm it seems with Burchards correction you are removed from the map however you can still teleport if you moved during the moment before teleporting
Use HashSet please
Ive changed that now, assuming for efficiency?
yes, and that's not how you use a map
also you want to remove player from the set when they move
My bad. Ive rarely messed with it
if (!map.contains(player.getUniqueId())) {
map.remove(player.getUniqueId());
```And on teleport/command
that will never happen
๐
if player is in the set, remove from the set
Whats strange is it still let me teleport
when player move, you add them back again instead removing them
I just figured having add the player on move, it would defeat the purpose to remove them on move aswell..
I may see, so I should add them first thing on command, and continuously remove on move?
so when player execute the command, add them onto the set
and listen to playermoveevent
if they move, remove from the set
Great. Ill give it a go
and after the cooldown or warm up
check if player is still on the set
if player is still on the set, teleport them and remove them from the set
The reason I had a if statement to check if they are in the set is to make sure they dont run the command a second time to bypass it
you can add a check on the command
Awesome thanks ๐ So simple yet mind twisting sometimes
is it possible to give a falling block a potion effect like levitation?
Sounds like youve got some crazy antigravity plans. Unlikely you can give a potion, youd have to either cancel the fall event or use armor stand animations
oh then i think ill do it with velocity
does anyone know why the bot is sending multiple messages instead of one? (i'm using jda) the code: ```java
@EventHandler
public void chatEvent(AsyncPlayerChatEvent e){
String message = e.getMessage();
TextChannel textChannel = jda.getTextChannelById("963443913362927666");
assert textChannel != null;
textChannel.sendMessage("" + e.getPlayer().getDisplayName()+ ": " + message).queue();
}
@Override
public void onMessageReceived(@NotNull MessageReceivedEvent e) {
super.onMessageReceived(e);
if(!(e.getAuthor().isBot()) || !(e.getAuthor().isSystem())){
String message = e.getMessage().getContentRaw();
User user = e.getAuthor();
Bukkit.broadcastMessage(user.getName() + "#" + user.getDiscriminator() + ": " + message);
}
}```
How many
change the || to && in the isBot isSystem check
hang on lemme try
ur effectively saying
if user is not a Bot(false) OR user is not system(true)
==True
instead of
if user is not a Bot(false) AND user is not system(true)
== False
is the listener registered more than once somehow?
You can simplify !(e.getAuthor().isBot()) to just !e.getAuthor().isBot(). Much more readable.
nope i dont think so
random nag but i think the super.onMessageReceived isnt needed since that JDA method should be empty
nothing else in that code immediately screams duplicate send, idk
i think that is a jda problem maybe? idk
maybe
thanks anyway for the support ^^
hi
i want help
i put levelledmobs on my server when they kill then show lvl 23 en all i want to do that show zombie lvl when alive how :?
does any1 know how to play the block break anymation and then break the block when the block is placed down? im using spigot 1.8.8
is there any way to make particles move slowly or last longer
tried the extra parameter and count to 0
yeh but how to like use them ik dis one but i cant import it is it from protocollib ??PacketPlayOutBlockBreakAnimation
yeah doing it right now through a runnable
gonna do task timer for this
how may I find these particle data
not that familiar with particle data
thanks
checked the wiki.vg, no particular data for smoke large unfortunately but the repeating task works fine
Hello, I'm trying to code custom enchants in spigot 1.18.2, but this code doesn't seem to work. It throws NoSuchFieldExceptions, but if I look into the class Enchantment.class, there is a field which has this exact name. I checked for typos, but there are none. Please help.
public static void registerEnchantment(Enchantment ench) { boolean registered = true; try { Bukkit.getConsoleSender().sendMessage("accepting " + Enchantment.isAcceptingRegistrations()); Field f = Enchantment.class.getField("acceptingNew"); f.setAccessible(true); f.set(null, true); Enchantment.registerEnchantment(ench); } catch (Exception e) { e.printStackTrace(); registered = false; } if(registered) { Bukkit.getConsoleSender().sendMessage("Enchantment " + ench.getName() + " registered"); } }
your using a Namespaced key in the super() correct as in 1.18/more recent this has changed
also
use getDeclaredField
not getField
also look into this from chocos post: https://www.spigotmc.org/threads/making-a-custom-enchantment.226403/#post-2308129
Hello, im trying to create a custom api for my plugins, but when i try to access the api from a diffrent plugin it gives me a java.lang.ClassCastException
How are you getting your API and how are you casting it
how does this API run, is it compiled in or running as a seperate plugin on your server?
Its running as a seperate plugin on my serer
and your depending on it in plugin.yml correct
this too
private RideManager rideManager;
@Override
public void onEnable() {
rideManager = JavaPlugin.getPlugin(RideManager.class);
}
this is how i try to get the main class of the other plugin
i tried multiple ways, none seemed to work. first i used getServer().getpluginmanager().getplugin
It works now. Thank you very much! ๐
depend:
- RideManager
and you used the string for this on as well correct
if anything
just make a static getter for the plugin
RideManager.getPlugin()
wait i can do that
will be loads easier than using the plugin manager
xD
ohh hwhahah then im going through a lot of trouble for nothing
i already have a static instance of the plugin in the main class xD
yep your fine getting it this way, its how a lot of other plugin API's do it
That is why I asked here lol
I set the biome, then Minecraft generates it, and what Minecraft generates is generally correct, except the plain barren land when there should be deep ocean
have you tried using PluginManage#isPluginEnabled("thatpluginsname")?
try checking the value of that
Yeah im doing that now
java.lang.ClassCastException: class eu.ridemanager.base.RideManager cannot be cast to class eu.ridemanager.base.RideManager (eu.ridemanager.base.RideManager is in unnamed module of loader 'base-1.0-SNAPSHOT.jar' @34f798f2; eu.ridemanager.base.RideManager is in unnamed module of loader 'operators-1.0-SNAPSHOT.jar' @6c2f0ff3)```
im so confused xD
you included your Ridemanager plugin with your second plugin
ohh
could definatly be a possibility, what scope for the import are you using miners?
should be provided
Yessir
For a plugin dev what would be a good way to read timings? Is using 1% of a servers load decent without any optimized flags for generating in additional ore veins in new chunks? (in the nether)
This is also while flying around generating new chunks on top of the above ^
looking at your code
you make a chunksnapshot
you can process it async btw
also aikar's timings are quite better for debugging
yeah im using the chunk snapshot however
one sec
?paste
Method for generating random block location: https://paste.md-5.net/aqesiviqot.java
It looks for a chance for it to spawn either on the nether roof or nether surface
ChunkLoadEvent: https://paste.md-5.net/jumepumulu.java
I dont really thing i could do this async as getting the block from the world would throw an error, as well as setting the block would throw an error as well
ChunkSnapshots can be processed async
you can make it a CompletableFuture<Block> getRandomNetherBlock
and call .whenComplete
I see let me give it a whirl
And when I supplyAsync this will make the CompletableFuture run async correct? or should I still wrap this in an async BukkitRunnable?
sounds good thank you! ill come back with my results in a few mins
holy shit
no way
I need to use CompleteableFuture's more often I guess i underestimated how good they were LMFAO
yeah when the completeable future finishes im returning the chunk.getBlock() method
weird bukkit isnt throwing me any async errors
unless your only talking about the block scanning from ChunkSnapshot
ahh i see
i don't really mind this processing async though, as I'm not doing anything with these blocks once they're generated, i just set theyre BlockDataMeta and the other events handle everything from there
but ty for that tip definatly saved a lot on the reports it seemed
just seemed odd to me that generating one block randomly in a location used that much power :p
package me.snazzeh.main;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
event.setJoinMessage("Welcome to the server," + p + "!");
}
}
anyone know why it doesnt work? Console doesnt throw any errors
needs @eventhandler
ohh cheers
its a test lmao
no it doesn't implement handler no @eventHandler annotation and it isn't registered
its a test Maow
plus im not making plugins for other people its for my own server calm down lol
shit how do i register again lol
I believe it's uhh
in onEnable
Bukkit.getPluginManager().registerEvents(this, <listener here>);
although I may be wrong
Bukkit.getPluginManager().registerEvents(this, PlayerJoinEvent); Like this?
this, this
implement listener
ye
ohh cheers
and add the annotation
package me.snazzeh.main;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
public void OnEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
event.setJoinMessage("Welcome to the server," + p + "!");
}
}
Like this?
idk probably
The method registerEvents(Listener, Plugin) in the type PluginManager is not applicable for the arguments (Main, Main)
wait nvm im dumb fixed it
cheers for the help
why did you make your own is my qusetion there are like a trillion join plugins
nah im just testing
i wanna start learning how to make java plugins but i gotta start somewhere
its a good learning project too
yeah lols
your OnEnable should be onEnable
and might be useful to have @Override before it
what does @Override do exactly?
ensures you are overriding an actual method defined in the interface/class
oh okay ty
it's optional
so i usually do it
we aren't coding in c#
arent we?
I also usually do it but no need to point it out if it isn't there
makes it more readable tho
reason to point it out is, he's learning
teach 'em while they are young
also it gives compile time errors when your signature is incorrect
I want to implement a vanish feature to my plugin
Is there a simpeler way then taking off the players armor and applying an invisibillity effect?
player.hidePlayer
Oh, does that hide the player even if he has armor on?
yes
wanna take a look at my vanish plugin?
yes, smh forgot my github password
grr
ah finally
@Override is a must as it simplifies updating by a lot
the hell is wrong with my fonts lol
Is it better to pass the same instance of random around, or to generate a new one when it's needed? If the latter, should i manually set a seed or no?
depends on use case
?paste
that font isnt cool lol
ThreadLocalRandom.current does the job 95% of the time
Hey @echo basalt i used the Completable future system but it seems the server cant really handle calling these in each and every chunk generation? I get a thread dump error like this: https://paste.md-5.net/eyuyamisez.cs
replacing blocks with a random chance in an area using a BukkitRunnable
sec ill resent the code im using rn
unsafe stuff hmm
That would be great!
then as Imll said, ThreadLocalRandom
Generation event: https://paste.md-5.net/nomipigifo.java
CompletableFuture method: https://paste.md-5.net/ujevomilew.java
(its called max of 3 times per chunk)
i just send the github repo above ^
Thanks ๐
you're distributing that right
maximum of 400 blocks at once so no
its not like the chunk shit where i had to generate 20000 blocks at once
i would do CompletableFuture#thenAccept instead of whenComplete if you're not using the throwable
it wont run if the throwable is != null too
ill try that, not sure if it would fix the stacktrace im currently getting but ill try it
thats alot of loops
also
if(block.getType() == from && randomChance())
block.setType(to);
//or
if(block.getType() == from){
if(chance==1.0){
block.setType(to);
}
else if(randomChance()){
block.setType(to);
}
}
```?
ayo what the fuck
some stuff seems to be broken here
honestly this is weird asf, even just generating the chunks in a player radius it just crashes the whole serer with CompletableFuture in a for loop
ah i see theres a max thread pool allowed when using these async
what's the sound name for when lava and water collide?
how to check if a spawner is naturally generated
How do I call this method given a Player? https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.Spigot.html#getHiddenPlayers()
Player player = ....
player.spigot().getHiddenPlayers()
Thanks!
np ๐
Managed to fix this using .join() instead of thenAccept however performance seems to have suffered from this but i am generating more of these random locations per block so that could be the issue
No good way to do this without listening to when a chunks generated and storing its location, i dont beileve theres any vanilla methods for checking naturally generated blocks
oh interesting seems to stable itself out over time
Ty for the pointers guys 
this always checks wheter or not a player is known to the server right?
if (player.isOnline() || player.hasPlayedBefore())
because hasPlayedBefore seems to only check if a playerfile exists but idk how exactly it works
from which list it retrieves its info
hasPlayedBefore() will indeed check if they exists by the playerfile iirc
I mean isOnline would always imply that the latter is true
^
yea isonline always returns true ofc if that player is online rn
was more about if its still an oversight to check like ths
based on hasPlayedBefore
hasPlayedBefore() is more or less something you use in PlayerJoinEvent
after that fires thats marked as true if it was false before
ye, well Idr exactly the implementation, but it probably just checks the cache or sth
i use it in my command to modify that player if he is a valid target
offline target or online
UUID uuid = NonReflectables.getPlayerUUID(args[0]);
if (uuid != null)
{
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
if (player != null)
{
if (player.isOnline() || player.hasPlayedBefore())
{
also
if a player is offline
player gets nullified
so your isOnline() would throw an NPE to my knowledge
yes
iirc it does
but implementation might have changed
huh?
no that doesnt make sense
isOnline wont throw npe
Player or OfflinePlayer one of the two inherits the other
ye
nono
if i explicitly want the online player
i just check if hes online by getting him
and if its not null
its a valid target
this is to target offlineplayers
ye
so just use hasPlayedBefore()
no
who log in for the first time ever
u may use isOnline before hasPlayedBefore
kk
cuz if online is true, it definitely hasPlayedBefore(), therefore skipping IO Checks
i think hasPlayedBefore uses IO
yes but he said hes checking if Player was null beforehand so isOnline() would always be false
not sure tho
so this if (player.isOnline() || player.hasPlayedBefore()) i suppose is accurate to use?
yes 2hex
by this isonline should be checked first
but like File::exists isn't as heavy as writing or reading IO
ig
but isOnline() will be better
to start with
yup
yea but if java isnt completly janky this should it
iterating the conditions left to right
^
and executing on the first true return value
if u wanna check if a player has joined ur server before yeh
on logout
it should
disconnect of a player
when the data is written from memory
to his file