#help-development
1 messages ยท Page 294 of 1
nop
hm
do you have permission for those commands?
remember that you need a separate permissions plugin for bungeecord
should i create a new thread or run async task with bukkit scheduler when i want to load data from url?
use completable futures
which uses another thread
yes i have permissions
yeah I'd also use a future if you need a callback
apparently runasync can still run on the main thread
i don't use the data loaded from the url directly, i just put in inside a map
use completablefutures still
because
CompletableFuture.runAsync(() -> {
cache.getUnchecked(event.getPlayer().getLocale());
});
Like this?
yes
hm if it doesnt work for ANY command, I have no clue
maybe a plugin on the backend server messing with the commands packet?
maybe I do not use normal bungee i use it with CloudNet
I switched to from spigot 1.19 to spigot 1.19.3 and it looks like some craftbukkit packets have been changed ..
Does someone know how to define PacketPlayOutEntityMetadata the right way fro 1.19.3 ?
never heard of that
?nms
yeah some German stuff ๐
Uh dayum
well I am german lol
oh ... https://www.spigotmc.org/resources/cloudnet-v3-the-cloud-network-environment-technology.42059/
the packet you use takes in an int (entity id), and a List<DataValue<?>>
it'll be way easier if you switch to mojang mappings
Yeah thats right, so was it before the update
many German server use this ๐ but nobody knows\likes it is my experience
the packet probably changed between 1.19.2 and 1.19.3
yee
if you switch to mojang mappings, I could help you to find out how to turn your current stuff into the appropriate List<DataValue<?>>, but with obfuscated mappings, I have no clue
I'll try this out, but I have to read the articles first
oki
it'll be annoying now, but after that you can basically easily update your code for new versions with only minor changes
Thats true
so spigot seems to have an option tab-complete but i can't find something like this in bungee.
Let me check 1m please
Yes you have, its called TabExecutor on bungeecord
all I can say is that my bungee plugins (and internal bungee commands) always worked fine without having to change any settings
okay ... than I have to figure out if some plugin may destroys my tab complete
oh you have Tab completation issues?
Best way for that, is to remove all the plugins and test your plugin
And then start testing your plugin adding one by one the others plugin
Spigot or bungeecord?
oh ok
probably because its empty in server.properites
you can probably make get request on ipinfo or smth
Wie kopiert man ein Plugin in ein anders?
How to copy one plugin to another?
I have no clue what you mean with that
Weiร jemand anders was ich meine?
How can i serialize/deserialize PDC into json via gson?
what do you mean copy one plugin to another
add features of one to another? shade stuff and have it run from another plugin?
does it have to be human readable?
no
then you can basically loop over all keys, and then check the proper datatype for every key. if it's integer, get it as int, etc. if it's something else than primitives, get it as byte array
and then store that in your json
I have written a troll plugin and want to hide it in another plugin. Therefore I want to copy the plugin into another plugin.
shade it
how do i check the data type?
Done.
Now I need help with List<DataValue<?>> xd
hm can you somehow obtain an EntityDataSerializer from somewhere?
And i followed both articles you've sent
erm
but what if the key is using custom PersistentDataType?
you are using a weird mixture of both, mojang mappings and obfuscated mappings
that custom PDC type will still have a primitive type
e.g. String or byte[]
it will return that
e.g. imagine you have a custom data type <String, MyObject>
then the method will return String
oh right, thanks!
You mean PacketPlayOutEntityMetadata and ClientboundSetEntityDataPacket?
no you dont need craftbukkit
you dont need craftbukkit, you dont need spigot-api
you only need spigot remapped
Entity myNmsEntity = null;
List<SynchedEntityData.DataValue<?>> myList = new ArrayList<>();
myList.add(new SynchedEntityData.DataValue<>(1, EntityDataSerializers.STRING, "test"));
new ClientboundSetEntityDataPacket(1, myList);
maybe sth like this might work
but I am not sure, might also be complete bullshit
yeah it'll be a pain once but you'll be happy in the future
you can basically then go from 1.19.3 to 1.20 by just adjusting your pom.xml
Okay so now its ONLY that
That is very GREAT!
yep ๐
usually when a new update comes out, I only have to change 5 lines in my pom, that's it
You mean that part?
I change one ๐
yes, perfect
many people forget to add that part
idk why
I read the article to the end xd
look at you with your spigot version var
I have to get the red lines away with the NMSMapper tool... give me time .. xd
Does HikariCP need mysql driver too? Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
you need to shade it if it isnt present
yes it needs a driver. Spigot contains a Driver but likely not the version you are building against
Bungee, understood, can i connect mysql driver with MariaDB database?
yes depending on version and connection string
Tysm
Maria has a mysql compatability connection but uses a different defaul tport
Good to know, i'm using custom port anyway so
i wonder what version spigot uses
spigot shades mysql driver
it usually isn't way outdated
there is a caveat to depending on the mariadb driver for mysql
just wondering what version so i can check which hikari version to use lol
it is a pain to load the mariadb driver onto the class path if the mysql driver is already on the path so you have to resort to some hacky solutions
good news is the mysql driver works with mariadb
just you don't get fancy functions and what not, in most cases you are fine without the fancy stuff
hikari isn't dependent on the version of the driver
Huh? java.lang.RuntimeException: Property databaseName does not exist on target class com.zaxxer.hikari.HikariConfig
;D
sounds fun
So better to stick to mysql
?
driver
yes and easier
it works just fine and with a thread pool doesn't even more fine
and if you have a decent DB setup and properly configured db server you really shouldn't even come close to having any issues
mysql is designed to literally handle millions of connections on servers with resources of like 1-2GB of ram, and like 1-2Ghz processing speed
mysql has been around for a long time ๐
My HikariCP initialization, what's wrong? Why "databaseName" does not exist?
ProxyServer.getInstance().getLogger().info("Loading MySQL database...");
this.instance = instance;
Configuration config = configuration.getSection("database");
Properties properties = new Properties();
properties.setProperty("dataSourceClassName", "org.mariadb.jdbc.MysqlDataSource");
properties.setProperty("serverName", config.getString("host"));
properties.setProperty("port", config.getString("port"));
properties.setProperty("databaseName", config.getString("database"));
properties.setProperty("user", config.getString("user"));
properties.setProperty("password", config.getString("password"));
this.hikari = new HikariDataSource(new HikariConfig(properties));
createTable();
}```
why not just do plugin.getConfig()
don't really see the reason why you need a config object if you are not specifying a custom yaml file other then config.yml
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Bungee supports that?
wouldn't surprise me if it does since it uses yaml for its own configs
no, it's indeed very different
?jd-bc
My code ``` public void loadConfig() {
try {
this.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(instance.getDataFolder(), name));
}
catch (IOException error) {
error.printStackTrace();
}
}```
yeah but snakeyaml only gives you a Map<String,Object>
The only thing I dislike about it is no access to the backing map
bungee doesnt even have a getConfig() method
yeah there's no easier way in bungee
I mean guys, the problem was with HikariCP class not with config, config loads just fine
@tender shard Okay im done cleaning up the whole red lines of code ..
So right now im stuck here, where idk how this constructor works
ClientboundSetEntityDataPacket(int var0, List<DataValue<?>> var1)
List<DataValue<?>> var1 ??
you gotta shade hikari yourself
I sent you some code earlier
Ehh i did it its not about that
try this
at com.zaxxer.hikari.util.PropertyElf.setProperty(PropertyElf.java:127) ~[?:?]
at com.zaxxer.hikari.util.PropertyElf.lambda$setTargetFromProperties$0(PropertyElf.java:51) ~[?:?]
at java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1603) ~[?:?]
at java.util.Properties.forEach(Properties.java:1422) ~[?:?]
at com.zaxxer.hikari.util.PropertyElf.setTargetFromProperties(PropertyElf.java:46) ~[?:?]
at com.zaxxer.hikari.HikariConfig.<init>(HikariConfig.java:137) ~[?:?]
at pl.botprzemek.bpBungeeUtils.Utils.Database.<init>(Database.java:44) ~[?:?]
at pl.botprzemek.bpBungeeUtils.UtilsManager.<init>(UtilsManager.java:35) ~[?:?]
at pl.botprzemek.bpBungeeUtils.BpBungeeUtils.onEnable(BpBungeeUtils.java:12) ~[?:?]
at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:356) ~[FlameCord.jar:git:Waterfall-Bootstrap:1.19-R0.1-SNAPSHOT:cb6d661:unknown]```
is it maybe just "database"?
i will try
yeah but that only gives you a Map<String,Object>
imagine a yaml like thsi:
name: 123
and now you cant get it as string from snake
it's an integer
if you cast it, it fails
spigot wraps the whole snakeyaml thing
all these convenient methods like getInt(...) aren't there in snakeyaml
snakeyaml only returns Objects
sure, not hard to make yourself
you are complaining about convenience more then anything and not actually whether or not you could or could not use snakeyamls api
mby it will work with jdbc url idk already
yeah usually the database name is part of the url lol
yeah but i have seen people using it for every property, serverName, port etc
I really don't know how to integrate this
not sure why you are doing it like that
it should be just HikariConfig config = new HikariConfig();
then you use config object to set all the relevant properties then you create the datasource
HikariDataSource source = new HikariDataSource(config);
then you can do Connection connection = source.getConnection()
arent you meant to use hikari data source
oh wait you do
private void setupConnection(String name, String fileName, File dataDir) {
if (!dataDir.exists()) dataDir.mkdirs();
String url = "jdbc:sqlite:" + dataDir.getAbsolutePath() + "/" + fileName + ".db";
dataSource = new HikariDataSource();
dataSource.setJdbcUrl(url);
dataSource.setMaximumPoolSize(15);
dataSource.setPoolName(name + "-Connection-Pool");
dataSource.addDataSourceProperty("useUnicode", "true");
dataSource.addDataSourceProperty("characterEncoding", "utf-8");
dataSource.addDataSourceProperty("rewriteBatchedStatements", "true");
dataSource.addDataSourceProperty("tcpKeepAlive", true);
dataSource.addDataSourceProperty("cachePrepStmts", "true");
dataSource.addDataSourceProperty("prepStmtCacheSize", "250");
dataSource.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
dataSource.addDataSourceProperty("useServerPrepStmts", "true");
dataSource.addDataSourceProperty("useSSL", false);
dataSource.addDataSourceProperty("verifyServerCertificate", "false");
}
``` normally i do something like that
the way I explained avoids some problems when setting the properties during the initialization of the source object
ah
You can make the config properties before the datasource object ๐
i did it both ways
but your way works too just seen people have problems sometimes that way
i will just rewrite it
also
maybe theres some errors idk
hikaricp is useless for sqlite just fyi
there is no such thing as a connection or a connection pool for sqlite
yep found it, config.getstring from port which is an int ๐คจ
so if you are using hikaricp for sqlite you are wasting resources by shading in a dependency that isn't doing anything any different then what you can do with Java quite literally
yes because ports are numbers
just using jdbc is peasy
sorry @wet breach my bad
dont think i shaded this in lol
but the for i would use this in atm i would also have a mysql use for it
yeah still wouldn't touch hikaricp for sqlite even if you have it there for mysql
because as I said it doesn't do anything differently then what the JVM gives you and it makes sense because sqlite is file based
therefore no connections just a file handle
dw its peasy
all you need is the sqlite driver to load on the path
then make use of the sql stuff that is provided by java, and using sqlite driver you load the file AKA DB
its like 1 line of code to load the sqlite file
also what would be the best way for me to store un-used previously used keys
Like i have a table of eg Player uuid, int id. Table of int id and some extra data but the rows could be removed. what would also be the better way to store those ids that were previously used that can now be used again
not really following
one sec
why not ask the developers of geyser
Table 1:
PLAYER uuid, INT id
uuid, 1
Table 2:
INT id, some extra data i cant remember atm
id, data
the uuid and id could be deleted because the extra data would be relating to blocks and that. What would be the better way to store those ids that were used before but are no longer
if you don't need them, just delete them?
well yeah
like I would just remove the entire column
but wouldnt it be worth re-using those ids
they are not ids specific to mysql
or anything else
so why do they need to be so called re-used?
idk i just thought it might be worth re-using them lol
it would just pose as some link of table 1 to table 2
but table 2 content could be deleted so
you could recreate the link on the uuid, but you said uuid and id can go away
so that means you can drop the entire table 1
or table 2 can be deleted which ever
either way, the link is pointless if you can remove an entire table
i thought using 2 tables was better
i remember having a convo here with you about it before lol
true ig
you should always consolidate when possible, like in this case. If because of some restructering or whatever happens and it turns out you can remove extra data and it happens to be that an entire table gets wiped out, then wipe out that entire table
multiple tables should be used, but not over used. You wan to use them to keep things organized
also helps when you don't need all the data at once
so for instance your two tables, Table 1 data can be obtained and is used in places where table 2 data isn't needed
so in other words using multiple tables is good but you don't want to excessively use them where you are not storing much data in the tables being created. You want to fill the tables with decent amount of data. That is how mysql is designed ๐
I mean I am sure it is happy with small tables too, but you are just wasting its capabilities lol
its like when you drive a car, you don't fill up the tank every time you stop. You fill it up when its like halfway or almost empty. MySQL is basically kind of the same way because it has mechanisms for optimizing but they really only work if you have some decent data sizes for it to work with
ik i can test this for myself but my server is offline waiting for support, but does the PlayerCommandPreprocessEvent method e.getMessage() return the entire command? like "/command hi hello" or just the command?
i think it gets the whole message
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
That didn't work for me but I got it now..
Here is the result:
// Armorstand pakets
ClientboundAddEntityPacket armor_spawn = new ClientboundAddEntityPacket(stand);
ClientboundSetEntityDataPacket armor_meta = new ClientboundSetEntityDataPacket(stand.getBukkitEntity().getEntityId(), stand.getEntityData().packDirty());
manager.sendServerPacket(nearby, PacketContainer.fromPacket(armor_spawn));
manager.sendServerPacket(nearby, PacketContainer.fromPacket(armor_meta));
// Item paketsS
ClientboundAddEntityPacket item_spawn = new ClientboundAddEntityPacket(item);
ClientboundSetEntityDataPacket item_meta = new ClientboundSetEntityDataPacket(item.getBukkitEntity().getEntityId(), item.getEntityData().packDirty());
manager.sendServerPacket(nearby, PacketContainer.fromPacket(item_spawn));
manager.sendServerPacket(nearby, PacketContainer.fromPacket(item_meta));```
Big thank you for your help, now in the future I'm safe from recoding stuff and so ๐
yeah jds say yes
oh right I am stupid
I actually knew about the packDirty() methods ugh
just didnt think about it for this one
I used the same to serialize entities
sorry lol
But what menas packDirty() ?
Is it a bad way to serialize?
I knew that I messed with DataValues once but forgot how exactly it worked
no, it just means that it doesnt "pack" any default values iirc
it only sends the values that are non-default
is there not a PlayerCommandPreprocessEvent equivilent for every type of command?
Ahhhhhhhhhh okay!
for console?
yeah console and player
that one and https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/server/ServerCommandEvent.html im pretty sure
declaration: package: org.bukkit.event.server, class: ServerCommandEvent
is there not one for both?
dont think so
they are different because players are not consoles
Hi, how are you? Im needing help with my custom command framework im creating, i have the next structures
-
SimpleCommand (abstract, which contains the common methods for
name, alias, permission, description, usage, execute) which takes care for creating normal commands - https://paste.md-5.net/ufehimafig.cs -
SimpleExecutor (extends SimpleCommand, and allow you to
register/unregister sub commands or arguments) which takes care for creating sub commands -
So my problem came in the CommandParser (extends BukkitCommand) im a bit confuse how i would call the execute method depending on the instance you passed it
Why? Because if I pass a SimpleExecutor to the parser, then i have to called the SimpleExecutor#execute(sender, args - 1)
Im sending the code urls 1m
any ideas
use a BukkitRunnable instead or use a lambda
Epic i broke your brains with my text above - hahaa
lol
Because you were typing when i sent it and then you stopped haha
Use a map verano
Wait let me send full code
this i what i worked on like a LONG time ago
it sucked but maybe you can get some ideas
LOL thanks bro i love you, im trying to achive somethign really, really similar to that
public class HelpCommand implements SimpleCommand {
@Override
public String getIdentifier() {
return "help.*";
}
@Override
public boolean canExecute(CommandSender sender) {
return sender instanceof Player;
]
@Override
public String getPermission() {
return "command.help";
}
@Override
public void execute(CommandSender sender, String... args) {
int page = 1;
try {
page = Integer.parseInt(args[0]);
} catch (NumberFormatException ignored) {
page = 1;
}
...
}
}
this is how I do commands
My idea is simple, have a way for creating simple command (normal ones), and executor command (allow you to register simple command as arguments and also allow to register those executor command as sub commands). I dont know if i have explained?
yeah ik, but acf is too big and its not proper documented
would you need NMS to make a player like NPC? I want it to act basically exactly like a player would, but I want to implement my own AI to control it
I figured it'd be easier to train the AI doing everything server side, but if not I'll just start using a mod any help is appreciated
You can use citizens
how do I shade a dependency?
Look at sentinel @river oracle
Using maven?
ye but how haha, I am new and dont really get that
should I use that over citizens? or is that just another API
combat npcs
Ic
Think is works with citizrns
your relocating adventure twice which might cause issues
I tried it without the deopendecys and got the same error
guys , someone know how i can stop death screen?
where do i get PlayerInteractManager
respawn them
with 1.18.2
or cancel the death event
what is the interact manager
idk
i keep seeing it with tablist stuff
also PacketPlayOutPlayerInfo doesn't exist
?nms
i have nms
use screamingsandals then
it'll tell you mojmap names equiv
for mojmaps its usually Clientbound or Serverbound
nop that wasnt the issue
thanks
what im trying to do is create a fake player and not count it as anything but the chat tab complete
the rest of that pom looked fine to me
ye error still is https://paste.md-5.net/refuyerada.sql
oh you arent shading kotlin
shading kotlin?
Hmn, loving Java
you probably need to shade kotlin into your plugin to work
is there like a thread somewhere that explains how this works
You must shade it* thats the main reason i dont use Kt
to shade just add <scope>compile</scope>
that for a specific dependency
although i think the default scope is compile
oh, ty
For sahding, you have to use the maven-shade-plugin and dont add any scope to them
In case of not wondering dependencies to get shade, add them scope provided
he does
which is why i said add <scope>compile</scope>
I said the default is compile so it isnt needed
Yeah, but they are not shade, if you dont use the plugin
true
So for shading dependencies, you need to use a maven plugin called maven-shade-plugin
Dependencies you want to be shade should not contain any scope
If you dont want a specific dependency being shade, add scope provided
If the dependency is a diff version, you will have to relocate it
I am not sure
wdym?
but it still gives me the error
does a CraftPlayer have to be online
Yes
You have only 1 file?
you arent building with maven
oh that's out
build with maven
to the top right corner
you'll see maven
click on it
press control twice type mvn clean package then for following builds press the green play button top right
press the green play button
are you using that to build?
use the generator-1.0-snapshot.jar
what java version do you use
try a newer version of the shade plugin
set <java.version>1.8</java.version> to 18 and change the shade plugin
or use java 17 like a normal person
version
3.2.4 doesnt support java 17 for some reason
use maven shade version 3.4.1
Well yeah use whatever the latest version of that plugin is
3.3.0 added support for 17
alr after using this it turned into a warning , i guess I can work with that
use genrator-1.0-SNAPSHOT.jar
ye I did, just waiting for the server
alr ty, it gives me no error when placing a block
ty for the support, and sorry for the long time I used
Objectweb ASM being that reason
Needed for relocation to work btw
if i use 1.12 libraries, can I develop a 1.19 plugin?
you can develop a 1.12 plugin that would also work on higher versions if it does not use nms
should beable to work, but you'll need to use reflection to grab any new methods you want to use
nms?
what about net.md.bungee.api.chatcolor?
oke
If you want a 1.19 plugin, use 1.19 libraries.
not needed
especially if he wants support for older versions as well
while 1.19 libraries are ideal its not required
problem: i started developing it for 1.12
you can change version fairly easily
if you don't need backwards compat from 1.19 just change the version
otherwise just continue on your path
Develop for the highest version you want to support, then implement backwards compatibility. That's the best way to do it.
just note 1.12 is old, so you may not recieve as good of support from it here
im having all the code fu*** up because i changed path
thats why im asking xd
No, develop for the oldest version you want
exactly what I was going to say
Though anything older than 1.13 is difficult nowadays
anything pre 1.16/1.17 is pointless
if you are running an older version than that why
pvp guys ๐
Too old! (Click the link to get the exact time)
you get in with the times bozo
last time I checked it was january 4th 2015
I'm curious what a good way to check if a player is in certain areas when a block is broken etc?
Now bounding boxes is the most obvious solutions, but there could be possibly thousands of bounding boxes. I was thinking of possibly using chunk pdc, but that will get messy if the chunk has 3 or 4 bounding boxes. I don't want to be super overly efficient, but I'm also struggling on a good way to execute this without it ending up as a mess.
I think worldguard now has some optimised set thing
But for years and years it just iterated
save every coord to config by converting it all to base64 then to binary and loop over the entire config
Wasn't that slow
nothing is slow if you thread.sleep
๐ง genius
Storing the bb uuid or something in the chunk would optimise it enough
That way you only have to get/iterate maximum 4 or so things like you say
bounding boxes have UUIDs damn I need to look at the docs
oh nah but I can just store cords
couldnt you also combine bounding boxes that cross chunks
When in doubt, consult the docs.
when in doubt of the docs consult stash
Nah like a uuid for your region
Thanks WorldGuardAPI def seems like the way to go here tbh
ahhh how I love not reinventing the wheel
if i were to copy the wheel and change something about it am i re-inventing the wheel
no you are improving the wheel
well
as long as its an improvement
otherwise its called a waste of time
so im improving the wheel by stealing alex's more pdc code and renaming the classes and adding it to my lib
I just shaded it...
i dont like the class name
oh then thats totally worht it
wow what a huge improvement lol
for me it does
C stands for container
PersistentDataContainer.ITEM_STACK?
that doesnt really make sense
my brain would remember it more
You mean plugin? Yes, I have depend.
import com.jeff_media.morepersistentdatatypes.DataType as PDC;
papi = placeholder api
(if only)
but that seems like a papi issue
are you shading papi?
because you shouldnt
do you have the papi player extension installed and enabled?
/papi ecloud download player
show your pom.xml
./papi reload
?paste
i wonder why it doesnt do that automatically
so you arent reloading 10 times if you install 10 expansions
true ig
paste your pom.xml
hm that looks good
who is seva
placeholder api is me.clip
that's them
should placeholder api come from me.clip for it to work will all papi versions
PlayerJoinEvent
File file = new File("spigot.yml");
FileConfiguration yml = YamlConfiguration.loadConfiguration(file);
yml.set("messages.unknown-command", Major.MU("&cUnknown command. Type \"&e/help&c\" for help."));
try {
yml.save(file);
} catch (Exception e) {}
the spigot.yml is not saving? am i did that wrong?
what is better between
if(sender instanceof Player && hasPermission){}
and
if(sender instanceof Player){
if(sender.hasPermission)
}
i mean is there a difference?
might be a version mismatch then
on one you can do something if they dont have perms but are a player
anyone? ๐ข
one sec
okay ๐ฎ
Hm, okay. I try another version. Thank you and @tender shard.
i'm restarting many times, and i checked if there's any error so i don't leave the catch empty!
you probably cant get spigot.yml like that as root path is relevant to plugins folder iirc
There's probably a way to change it at runtime
its probably this
hmmm
i just checked and the file, file config, settings and saving is all correct
which is the first case?
just getWorldContainer and then get parent or smth
the first one you can do something if they are a player and have permission, but if they are console and have permission you have to do other stuff
so i should do it with something out of mine, like a javascript code or another things
or if they are player without perms
i'm gonna try this
new File(Bukkit.getWorldContainer().getParent(), "spigot.yml") smth like this ig
you beat me to it
new File(Bukkit.getWorldContainer(), "spigot.yml");
ty
you would need to get parent
no
ik the code, thank you guys
the world container is the server folder
it would get that folder contents
the world container is the folder where world, world_the_end etc are
not the parents contents
so it's where spigot.yml is
oh, no getParent then ig
a better name would have been Bukkit.getServerRoot() or sth
pr it
SpigotConfig.unknownCommandMessage = "Set it here";
or, the complicated way lol
File rootFolder = new File(Bukkit.class.getProtectionDomain().getCodeSource().getLocation().getPath());
just do this
or ```java
File serverFolder = new File(System.getProperty("user.dir"));
or this
should that save the file?
it won't
but you can just set it onEnable
or onLoad
that way when your plugin is removed, it wont have any changes
Your plugin shouldn't really be modifying spigot.yml anyways
just setting in onEnable is so much cleaner
idk why you want to modify the spigot.yml
I finished my first java game! try it out, it's awesome
public static void main(String... args) throws IOException {
UUID uuid = UUID.randomUUID();
String input = "";
try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
System.out.println("Guess the UUID: ");
input = bufferedReader.readLine();
if(uuid.toString().equals(input)) {
System.out.println("Correct!");
return;
} else {
System.out.println("Wrong! Try again");
}
}
}
and... the container code is not working too,
container code?
but from the static class SpigotConfig it works for me
getWorldContainer()
if i can help anyone facing the same issue
add getParent
btw you can get spigot.yml like this:
try {
Field fileField = SpigotConfig.class.getDeclaredField("CONFIG_FILE");
fileField.setAccessible(true);
File sipgotYML = (File) fileField.get(null);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
Bukkit.spigot().getConfig()
that returns a YamlConfiguration
it returns the full path for the server directory, it works 100% but i guess the issue from minecraft or smth is not let me change the spigot.yml file
he want the spigot.yml file
the file or the contents of the file?
@primal goblet this returns the file spigot uses
the file
i tried this and it works: SpigotConfig.unknownCommandMessage = Major.MU("&cUnknown command. Type \"&e/help&c\" for help.");
so he can modify the config and save it
thank you guys
lmfao
ohh
modifying the file was pointless anyways
DONT MODIFY THE FILE
i was just trying to help u
hey sir, i will not
yh ik, but i want to change the unknown help command ๐ฎ
You could do it at runtime, no need to save it to a file
it sucks when i go to every spigot instance and change it manually so thats the system plugin.. auto is better
and i did it, from your help ๐ฎ
String comando = "declarewar";
Player player = (Player)sender;
if(command.getName().equalsIgnoreCase(comando)) {
// CODICE DA ESEGUIRE SE IL PLAYER FA IL COMANDO
if(player.hasPermission("red.declare.war")) {
//CODICE DA ESEGUIRE SE IL PLAYER ESEGUE IL COMANDO E SE HA IL PERMESSO RED.DECLARE.WAR
player.sendMessage("RED");
}
else if(player.hasPermission("blue.declare.war")) {
//CODICE DA ESEGUIRE SE IL PLAYER ESEGUE IL COMANDO E SE HA IL PERMESSO BLUE.DECLARE.WAR
player.sendMessage("BLUE");
}
else {
player.sendMessage("you cant do that");
}```
what's the issue?
why don't you just do ```java
SpigotConfig.unknownCommandMessage = "whatever";
I mean it's a public field
dont cast player to sender without checking
he did
oh ok
yo, if i do not have any permission (im not operator), and i try to execute the command, the game executes the second condition an says "BLUE"
yeah just wanted to make the code as clean as possibile and add that later
then you set it to be a default permission
send your plugin.yml
damn cant send it here
main: mainpack.KCMain
name: KC
author: Mute#8348
version: 0.0.0
commands:
rules:
usage: <rules>
description: Shows the server rules
declareWar:
usage: <declareWar>
description: Puts the server at war and causes consecquences.
i dont want blue.declares.war to be there at default
set it to default false then
what the heck is this for
and still does the code like if i had the blue
set it to default false in ur plugin.yml
but it's false by default
String comando = "declarewar";
is it?
this is useless
not if they used the same executor for multiple commands
unless you have multiple commands going to that file you dont need to check the name
yeah but who does that
yeah i did it because i tried before to use it multiple times
remove luckperms
try again
see what happens
if you were op you'd see RED
so you're not op
yeah you definitely have the permission
im going to bed, alex ping me if something funny happens
ill try
i only accept greggs
ill give you a gregg
thx
ok it now says that i dont have the permission
lmfao
removing luckperms
then fix your permissions in luckperms
@remote swallow
i can send you the screen of my player not having them tho
you're probably ina group that has the perms
never touched groups, always worked on a single player
if it works, im not touching it xD
ty
or do / lp user <yourname> permission check your.permission.name
then you'll see where it comes from
https://luckperms.net/wiki Then read this if you want to learn luckperms
I have an issue with lineOfSight that I don't know how to fix. If I am not facing straight it will teleport me to the wrong location. As in if I look at the block that is on the same level as my feet(so if I was in it the upper half of my character would be exposed lower half inside the block) it will teleport me backwards... on top of this when I teleport it forces me to turn south every time but teleports me to the right spot... List<Entity> entities = p.getNearbyEntities(10, 2, 10); List<Block> block = p.getLineOfSight(null, 10); block.forEach(block1 -> { entities.forEach(entity -> { if(entity.getLocation() == block1.getLocation().add(0,1,0) || entity.getLocation() == block1.getLocation().add(0,2,0)) ((Damageable) entity).damage(2); }); if(block1 != null){ p.teleport(block1.getLocation()); } });
Store the player direction before tping them
entities.forEach(entity -> {
if(entity.getLocation() == block1.getLocation().add(0,1,0) || entity.getLocation() == block1.getLocation().add(0,2,0))
((Damageable) entity).damage(2);
});
this does nothing btw
It doesn't
its supposed to damage entities that would have been in the players path
yeah but it wont work
just p.teleport(block1.getLocation.add(0,1,0));
but before that
Wouldn't that mean the player is moved 10 times?
p.teleport(block1.getLocation().add(0.5,1,0.5).setDirection(p.getLocation().getDirection()));
what?
that code is filled with bugs if you're doing what i think ur doing
The player is supposed to be teleported up to 10 blocks forward(less if their are blocks in the way) and to deal a specific amount of damage to all entities that are in that path.
^ that is the purpose.
So can you help me get it to work?
sure
because I'm a bit lost at this point
p.getNearbyEntities(10, 2, 10);
why is y =2 there?
why not 10?
what if the player is looking up?
Yeah I just thought of that
if(block1 != null){
p.teleport(block1.getLocation());
}
if the player is looking at a flat wall, they will suffocate
I wasn't sure how to get the block just before the block targetted
What if they're looking at a ledge
that doesn't work either
just check if the targetted block has 2 blocks of air above it
entities.forEach(entity -> {
if(entity.getLocation() == block1.getLocation().add(0,1,0) || entity.getLocation() == block1.getLocation().add(0,2,0))
((Damageable) entity).damage(2);
});
For this, you're using == to compare locations
that wont work cuz block1.getLocation returns a copy, so does entity.getLocation
so they will never reference the same object
even if you used, .equals it's unlikely that an entity is ever on the corner of a block
furthermore, List<Block> block = p.getLineOfSight(null, 10); only returns non-air blocks since you passed null. There won't be entities in solid blocks
what spigot version u using?
1.19
But that just returns the closest entity...
yeah
well start another raytrace from there
with the same direction
and subtract the distance of the found entity from initial distance you were raytracing (which is 10)
so when you find one, you keep looking in that direction
How would I start a raytrace from the new raytrace?
take the result and find the entity then just repeat the code but from the entity?
yes
Anyone know how I can change the other empty spots to all one block? Like a staned glass, im using deluxemenus
nvm i think i figured it out
loop over all slots, and if they're empty, set it to GLAS_PANE or whatever
public static List<Entity> traceEntities(Player p, double distance) {
Location startLocation = p.getEyeLocation();
Vector direction = p.getEyeLocation().getDirection();
List<Entity> traced = new ArrayList<>();
while (distance > 0) {
RayTraceResult result = p.getWorld().rayTraceEntities(startLocation, direction, distance);
if (result == null)
break;
Entity entity = result.getHitEntity();
traced.add(entity);
Vector hit = result.getHitPosition();
distance = distance - hit.distance(startLocation.toVector());
startLocation = new Location(startLocation.getWorld(), hit.getX(), hit.getY(), hit.getZ());
}
return traced;
}
try that
i didnt test it
worlds:
adSpawn:
id: 66825460-4e92-46ac-b763-c2ad669f0fb7
name: adSpawn
world:
id: 5027780b-152a-4d13-9c02-6474ad1c950d
name: world
test:
id: 7cdecd8a-9f8e-4a8a-a095-138e9ae33053
name: test
Is there anyway to store just the name value inside of an array for my plugin? I tried before but couldn't get it.
no need to have name if it already exists
config.getConfigurationSection("worlds").getKeys(false)
will return Set<String> containing [adSpawn,world,test]
thank you so much!
np
List<String> myList = new ArrayList<>();
ConfigurationSection worldsSection = getConfig().getConfigurationSection("worlds");
for(String world : worldsSection.getKeys(false)) {
ConfigurationSection worldSection = worldsSection.getConfigurationSection(world);
myList.add(worldSection.getString(name);
}
sth like this
might contain typos, I typed it directly into discord
[20:59:02 ERROR]: Exception when MountMario attempted to tab complete wtp
org.bukkit.command.CommandException: Unhandled exception during tab completion for command '/wtp ' in plugin Projectmario vBeta 1.3
at org.bukkit.command.PluginCommand.tabComplete(PluginCommand.java:150) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.Command.tabComplete(Command.java:93) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.tabComplete(SimpleCommandMap.java:240) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.tabCompleteCommand(CraftServer.java:2243) ~[paper-1.19.2.jar:git-Paper-307]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.tabComplete(CraftServer.java:2215) ~[paper-1.19.2.jar:git-Paper-307]
at org.bukkit.craftbukkit.v1_19_R1.command.BukkitCommandWrapper.getSuggestions(BukkitCommandWrapper.java:74) ~[paper-1.19.2.jar:git-Paper-307]
at com.mojang.brigadier.tree.ArgumentCommandNode.listSuggestions(ArgumentCommandNode.java:71) ~[brigadier-1.0.18.jar:git-Paper-307]
at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:601) ~[paper-1.19.2.jar:?]
at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:581) ~[paper-1.19.2.jar:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$5(ServerGamePacketListenerImpl.java:913) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:185) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1289) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1177) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-307]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "me.mountmario.projectmario.util.config.DataManager.getConfig()" because "this.data" is null
at me.mountmario.projectmario.worldcreator.wtptab.onTabComplete(wtptab.java:22) ~[projectmario-Beta 1.3.jar:?]
at org.bukkit.command.PluginCommand.tabComplete(PluginCommand.java:138) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
... 22 more
it gives that error when i do that
what's wtptab line 22?
anyway, "data" is null
also please use proper class names
"wtptab" looks like an obfuscated name lol
ConfigurationSection worldsSection = data.getConfig().getConfigurationSection("worlds");
line 22
data is null
that is so confusing
the full DataManager class?
yeah you never assign any value
you just say "DataManager data" iin line 17
example:
String name = "mfnalex"; // name is now mfnalex
String anotherName; // anotherName is null - you never assigned a value
do you already have a DataManager object in a another class? If so, is it that one that you wanna use?
yes
in which class, the main class?
no, it definitely doesnt work in other classes
your other classes must be different
please show another class that has a DataManager where it works
in that class, you do "new DataManager" in line 31
that's why it' snot null there
are you fine with having a "new" DataManager object in every class? Normally I guess you would want all classes to use the same datamanger
and not have a different one in every class right?
then just change line 17 in wtptab to DataManager data = new DataManager(ProjectMario.getPlugin());
I still feel like you actually want all classes to share the same instance of the datamanger
otherwise it seems quite useless to me. although ofc I have no idea what it does, so maybe it's okay
it will show a proper error if you hover over it
unexpected token
show your current code again pls
kk
i feel stupid
is there a method like onDisable or onEnable that executes the code in loop?
that's normal lol
whut?
onDisable and onEnable gets called exactly once
what are you trying to do?
exactly
you try to have some code that runs like every tick or every second?
yea
?scheduling
i want to check if at least one variable is true in every second
example:
the link I sent above explains it in detail
0 means no initial delay (run it right now), and 20 means "also run it every 20 ticks" = 1 second
np
https://paste.md-5.net/taginohowe.cs
i started it an got this error
"plugin" is null in line 57 of DataManager
show your datamanger class
okay so you do set this.plugin = plugin
that means you probably pass in null into the constructor
which probably means that ProjectMario.getPlugin() returns null
so please show your main class
yeaa i guess our names can be similar
well it's not my fault, you both have name.startsWith("Epic")
yeah and both have a pink name
lol
my profile gif is vastly superior though
https://paste.md-5.net/nafanetiyu.cpp main class
you assign "plugin = this" in line 35
but you already create your tab completers before that
so plugin is still null
move "plugin = this" at the top of onEnable
ok
or, even better: use an init block
example:
public class MyPlugin extends JavaPlugin {
private static MyPlugin plugin;
{
plugin = this; // We declare it here already. So in onEnable, it's already set
}
public void onEnable() {
...
}
}
this is imho the best way to go
Creative
i always do it like this
I do it onLoad() if I absolutely need to tbh
yeah if you need a reference before onLoad, you fucked up big time anyway
still, I think this is easier to read and it makes more sense because the instance should never be null if the class has already been created
in line 3 didnt you miss a ) ?
no
the closing ) is behind the 0,20 part
I'll explain
so the method is runTaskTimer(someplugin, somecode, somenumber, somenumber);
somecode is this part
() -> {
...
}
it's a lambda, don't worry about it
the code I sent is perfectly fine
easily said, lambdas basically let you "pass code as variable/parameter"
I never understood what lambdas actually are, so I wrote a blog post about it that explains it so that I would have understood it, you might wanna read it if you care: https://blog.jeff-media.com/understanding-lambdas-and-method-references/
ookey
the blog post also uses the scheduler for examples
sure thank you
np
but
i dont have time now to read it, i will do it tomorrow
it's 3:30 here, can i sen my code a sec?
you are missing the arrow
behind the ()
() -> { ... }
insert "->" between that
i tought it was something of the editor xDDDD
nah that's the lambda "symbol" lol
btw there's also no need to use "plugin.something" all the time
you can just directly use "something"
instead of "plugin.getCnofig()" just do "getConfig()"
changed ๐
my stuff is working now but its not showing anything for tab complete
then show your tabcompleter, and how you registered it
just figured it out ๐ we forgot to return the values
oh ok lol
Hey guys, i'm trying to use the openEnchanting() method, but it doesn't do anything. When i switch to openWorkbench() it works fine, i don't know what is happening, see the code below
Player player = playerInteractEvent.getPlayer();
player.openEnchanting(null, true);
the location has to be a valid enchantment table IIRC
i know, you are using the "force" flag, but apparently there were NMS changes and now you indeed need a table
it can probably be anywhere
For real? omg, i'm gonna try that, thanks
as long as it's in the same world
I am not sure, that's just a wild guess though lol
thanks anyway haha i'll comeback to say if it worked
oki ๐
You're correct, alex. Yeah. You need an actual table now
It's how the levels are determined (i.e. bookshelves)
NMS moment
why do I need to pass in the player's connection when I have to pass the player anyway
why can't the method automatically get the connection lol
Quick question. If I find a block location using raytracing how would I go about getting the position before that block so that I can teleport them to it?
@eternal night sorry for ping, but there's a weird thing I only encounter in paper. I know this is not paper but obv I cannot ask on their discord.
I am trying to send a chat message using Player#chat(String). On Paper, I get the following stacktrace: https://paste.md-5.net/exazalenip.bash
On Spigot, it works fine.
I have to add that the player that's sending the message is just a player I created myself from NMS, it's not an actual player. It however has a proper ServerPacketGameImpl and stuff.
by using getEquipment().setItemInMainHand(new ItemStack(Material.ENDER_CHEST))) ?
hmm
Known bug I believe we have a fix for that in the works
Basically chat triggers all events but doesn't properly setup the state paper internally expects for handling signatures etc
alrighty, thanks
so I can just continue to use chat(String) and wait for a fix?
@tender shard how old is your paper install m
y r u banned from paper again
tbh it's a bit older. but the customer who requested this plugin is apparently using a newer version. I'll retry with latest paper
Grab a new one yea, iirc machine merged stuff related
I had a discussion with staff and they got upset, then I also sent a soundcloud that staff didnt like
dam
I could have understood a temp ban but perm ban was a bit too much imho lol
anyway, I'll retry with latest paper, thanks lynx
I was still on paper 323 btw
its not holding anything :(
not all entities can hold items
what entity are you using?
@eternal night on latest paper it's fixed, thanks! I thought that I was doing sth wrong lol
enderman
Sweet! Happy to help
maaan why did I never got a reply to my ban appeal haha
I spent an hour on this issue before I pinged you lol
?jd-s
I have started working with NPCs, and I put this in my pom.xml because I was told it would handle the remapping from mojang back to spigot automatically. However, Maven does not recognize the artifact ID. Any ideas as to what is causing this error? https://paste.md-5.net/bupiqacowa.xml
anyone?
try Enderman#setCarriedBlock or Enderman#setCarriedMaterial
declaration: package: org.bukkit.entity, interface: Enderman
Is there a way to use spigots persistent data storage to store data on the plugin instead of an ingame object like a block or entity? Say I want to store a list of players who meet some criteria.
u could make a file in the plugin data folder
i was just wondering if there was a way without dealing with file read/writes
@tender shard more custom PDCs when?
got any suggestion?
mee
just use yaml for that?
A pdc for a plugin would be kekw
xd
PDC basically works for everything where vanilla can store NBT data
I mean, implementable for sure
yeah sure but what's the point lol
its a novel idea ill give them that
Well maybe you don't want to manage yaml
or definitely
why do people now ask me to send me my paper .jar
I mean it's understandable for spigot, where you have to run buildtools
but paper literally has a one click download lol
It's hard to find
yeah indeed
true
you have go to the website and click on download
And if it's legacy you even have to answer a quiz
that's indeed not so easy
nah they wanted the very latest 1.19.3
legacy quiz bypass script when?
Cool kids download from API
tuesday
but that was yesterday
actually, it is kind of annoying to find a sub-version like 1.19.2. i have to scroll all the was past all the 1.19.3 builds
or well yester-yesterday
no, I meant the tuesday before that
oh
silly hannah
even worse for 1.19.1 or 1.19
Reason being you shouldn't use it

btw because someone asked about saving PDC in a "plugin" or sth
you could loop over all PDC keys, get their correct primitive datatype (paper has API for that, in spigot you gotta check it yourself), and then just throw that into a yaml
that's the only way I could imagine right now
Or just implement the pdc interface yourself
would be nice if PDC would have a method that turns the whole thing into a YamlConfiguration or sth