#help-development
1 messages · Page 2155 of 1
since you're running that in a server, you should specify the file in your plugin's data folder.
how do i do that
'getDataFolder()' cannot override 'getDataFolder()' in 'org.bukkit.plugin.java.JavaPlugin'; overridden method is final
what is the best economy plugin
search in the spigot website
can i pass respawn screen on death?
why are you saving your mutes in a json file and not a yaml one?
At that point you could simple take the absence or presence of the file as sufficent for the boolean
probably a lot more atomic than the other variants
i cant get target file after running the maven
doing mvn package?
yes
build errors?
or doing stuff in your pom that changes the ouput directory
no
well where is it supposed to output?
target folder?
is the build log also saying that its outputting to that place?
Hello what's the fine methode to get a chunk ?
based on what?
World#getChunkAt()?
I have a map with many detail for a PvP server but we want to allow players to build. Is there a plugin that stops the players from breaking the map but allows the players to place blocks and destroy blocks built by players?
Oh yeah that seems more fit, sorry.
How can I check if a value in config file is e.g. False
FileConfiguration#getBoolean
Ty
And if I want to check if amount is 10, what do I have to.....
do you know how to write a plugin?
Not one bit...
p.getChunk is good ?
just do int amount = config.getInt("your-path")
and lemme see what it will return if its not found
0
0 ye
i dont think you want to save a file every time someone breaks a block tho, I'd say store it somewhere
Ty
idk how to use yaml files
JSON > YAML for data storage
but if you're storing block breaks like this is implying (I missed out on a good chunk of conversation), database
1000%
im trying to use json but Idk how to make it work
You can make use of Gson. If you do a quick search about "How to use GSON", you'll find lots of basic guides on it. How to serialize/deserialize objects and read from/write to them is all you really need
Then so long as you understand how to read from/write to files, you're good
I use json.simple
should I switch to gson?
I mean I suppose that's an option too
If i do Player#setResourcePack but that pack (with the same hash) is already loaded
You can use JSON Simple, but GSON has a lot more flexibility in terms of serialization, and is a bit more type-friendly
bump x)
I want to spawn a custom mob at coordinates (1,1) instead of the players coordinates..
Code: LivingEntity mob = (LivingEntity) p.getWorld().spawnEntity(p.getLocation(), EntityType.ZOMBIE);
What shall I replace p.getLocation() with?
so factory for h2, mariadb thing and others?
yes
you could have an abstract factory
but that might be overkill
idk the exact design of your code but ye
the big advantage with just using a factory as opposed to the coupled enum factories is mockability mostly
New location (world, x, y, z)
i was going to have a Storage implementation which handle stuff
ig reusability also? altho thats quite far fetched
if I use this: try { Reader reader = Files.newBufferedReader(Paths.get("isMuted.json")); Map<?, ?> map = gson.fromJson(reader, Map.class); map.get(1); } catch (Exception e){ return true; }
will map.get(1); return the boolean value of the json? (the json file has only one value in it which is boolean)
or should it be map.get(0);
Deserialize it to a JsonObject instead
(or JsonArray, depending on whether or not it's an object or an array)
You probably wanna use try with resources for the reader
or at least, close it (after you're done w/it)
Which is better h2 or sqlite?
I guess if you're reading or writing a lot h2 is better than sqlite?
how
actually i was just trying to make a class that holds a hikari datasource and has methods to get a connection
seemed that the datasource needs different stuff for each database
so maybe i will handle the initialisation of the datasource in some class that implements Storage, which has methods like connect and close instead of having different connection classes for each db and different ones for the db implementations
sorry for that bible
ok so will this return the boolean value "isMuted"?
Map<?, ?> map = gson.fromJson(reader, JSONObject.class);
map.get("isMuted");```
will this line return it? map.get("isMuted");
so having implementations for each database type and in the connect method, initializing the datasource too + creation of tables etc
instead of that weird enum stuff
It worked
Make it void
And throw excretion on failure
yep
pls answer me
Exception jeez autocorrect
I trash in Java, so I don't want to change it...... if it works don't touch it
it is debatable now that materials may not be enums for long
anyways why does a HikariDatasource implements Closeable?
I mean
wait
does calling some method that gets a datasource in a try with resources also closes it?
Believe so
if it implements Closeable
why would you want to close the whole datasource and not just the connection
I thought it needs to implement AutoCloseable
Hopefully they’ll remain singletons
Fourteen on shutdown obv
Or sth
Hopefully, not doing that would make everything much worse
Indeed
ye but i dont think the whole program is looping in a try with resources, like how would you use it then?
I want my Custom Mob (Entity Zombie) to target a specific coordinate. However, if I write:
Zombie.getNavigation().a(loc, 1.0);
The getNavigation method is marked red (Cannot resolve reference...?!)
What to do?
I recommend using mojmap
Isn’t HikariDataSource just following the design of object pool fourteen?
connection pool ye
I dont think so
Right so in that case close hopefully closes down and terminates the pool entirely
Unless you create a reference to it in the () of the try with
is creating a private static final itemstack with custom item meta for use throughout a plugin a good thing to do or should i do something else
There are better ways of doing it
if i want to give players that item or compare and check if the item they clicked was that item
how should i be doing that
You can just keep an instance and use a getter
where do i put the instance
It depends
on what
Where you're using it
The entire plugin
And how you're using it
Like if it's a currency item, it could be in some sort of currency manager class
i'll have a listener which checks if a player right clicked using that specific item with the custom item meta, and then somewhere else in another file i'll be giving the player one of those items
i mean i dont see a place where you would create a connectionpool in a try with resources and right after the code finishes, it closes the whole pool
Tests
leave the pool open then but close the connections
Unit tests specifically
hmm
Maybe in the plugin?
But again it depends
If you have multiple items maybe have a class that has getters for them
what do you mean "in the plugin" surely everything i'm writing right now is "in the plugin"
where in the plugin
in the onEnable?
or in its own file or something
can i force a player to enter a bed
private ItemStack xyz;
public ItemStack getXyz() {
return xyz;
}
Then do plugin.getXyz();
From your listener or command class
anyone tell me how to Disable JLine
its not entering the bed
With force = true? If it's false, the player won't enter the bed if they're too far, there are monsters nearby, it's night time, etc.
is it good practice i mean
Though there's also no guarantee that if you're doing it during the day that the player will stay in the bed
yes
with true its not entering the bed
If it's a global item, create it on enable and just have a getter for it
have you tried something like -Djline.terminal=jline.UnsupportedTerminal?
yes
IT DOESN'T WORK
AND I'M IN SEVERE PAIN
REEEEEEEEEEEEE
I've even MODDED bungeecord
but it NOT WORK
lol
anyone.
Not sure you can replace the terminal after its started. it needs to be a startup option
just try it as a startup on bungee
no clue then
Alternatively, just yeet jline from the deps and resolve all errors
no?
because spigot uses JLine, and if you add -nojline to the arguments
it does not use this "smart" jline
?stash Alternatively, we can take a look at how spigot does it
Which is basically just https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/Main.java#173-178
So yeah, remove jline and it will not be an issue. I do not believe that jline is a public dep anyways so it should only minimally interfere with plugins
They clearly still use JLine
I should also note to you, that I want to like, edit an already existing Bungee jar, to disable JLine because I'm using an obfuscated BungeeCord proxy, that does have some classes obfuscated.
it's a premium fork

what nobody told me I couldn't edit it
I'm using an obfuscated BungeeCord proxy, that does have some classes obfuscated.
it's a premium fork
idk wtf I just read
because people too damn worry about their code getting ripped
Recaf to the rescue!
Just get recaf premium
hi babe
its premium 😎 😎
Yeah why not
Aegis
anyways why doesnt StorageImpl::new works where this is expected, the StorageImpl has a default constructor kinda weird to use plugin -> new StorageImpl()
Because StoreImpl::new would require a constructor that takes in plugin as an arg
Bro it's really cool and all but it doesn't help.. Because I still didn't find how to disable Jline.
meh i hate it
You need to remove all jline classes, patch up all errors that arise from it and hope that it works
Where as right now you have no arguments I assume
you are a noob basically
have you got any idea how to calculate ender pearl destination location when player throws it?
I'm still so confused as to why you need to disable it ngl
how could I simplify this?
var stream = getFriendsStream()
.filter(f -> f.getName().equals(id) || f.getName().equals(zeroedUuid));
if (stream.count() == 1) {
return stream.findFirst();
} else {
return stream.filter(f -> f.getName().equals(id)).findFirst();
}
Probably because he wants to handle stdin himself
what are you doing?
I want to find the first entry in getFriendsStream where getName().equals(id). If that doesn't exist, I want to check if there's any entry where getName().equals(zeroedUuid) and return that if so
i think u can just remove this 'else' and leave second return statement
but it has to be outside 'if'
in a optimal case the entry where getName().equals(zeroredUuid) should be at the end of the stream so that findFirst never returns it if another entry was not filtered
`
Player p = (Player) sender;
LivingEntity mob = (LivingEntity) p.getWorld().spawnEntity(new Location(p.getWorld(), 1.0, -60.0, 1 .0), EntityType.ZOMBIE);
Zombie z = (Zombie) mob;
Location loc = new Location(p.getWorld(), 10.0, -60.0, 60.0);
this.getNavigation().a(loc, 1.0);
`
Why is there an error (Cant ressolve method "getNavigation") if I want to move my mob to a certain position?
to make the Process console readable and writable,
Bruhhh
return getFriendsStream()
.filter(f -> f.getName().equals(id) || f.getName().equals(zeroedUuid))
.sorted((a, b) -> a.getName().equals(zeroedUuid) ? 1 : -1)
.findFirst();
hmm I think this might work
I would assume sorted doesn't execute when there's only 1 element
and that conditional will make the entry which equals zeroedUuid to be at the end
Does anyone know a good TOTP library or a good Authenticator API I should use!?
should i let my storage interface return futures for each database operation or make a wrapper which handles the futures?
can i block if player f5
hmm i'll probably write some classes that interact with the database and wraps futures around them
so the command stuff doesnt have to care
That is a server related question
no
Or client idfk
Yeah, client sends no packet for that. No reason for it to
Anyone got a World Creator Lib or something, that copies a world and creates it without much lag spikes ?
there is a flag you can send to prevent the player from seeing his coords in f6
and most of the info there.
I'm sure.
Im handling the message from the console and when the message is colored I receive weird symbol, how can I remove that symbol and get clean or colored string? I guess its the § symbol
^ I have this when I send the message to the player
- Dont use 1.8
It's not 1.8
mc 1.8
Then make sure your source files are encoded using utf-8
don't even answer me
I don't color it
Because its a horribly outdated piece of software with a ton of bugs that will never be fixed
I would say otherwise
but
that's my opinion
Thats not an opinion. Its factual.
I would still disagree, but it's still opinion.
Its literally not.
-> horribly outdated piece of software (support was dropped almost half a decade ago)
-> with a ton of bugs that will never be fixed (has been proven true numerous times)
To add on that:
- It lacks a ton of essential API features like PDCs
- The community is really small and shrinking, while half of it are just kids that wanna click their mouse real quick
It doesn't lack PDCs it has NBT, and most of all, Bukkit API is garbage on this version? yes, what about NMS? oh wait, It's still using the same api as it was LITERALLY UNTIL TODAY.
LITERALLY
And those are not opinions. Those are facts that support an opinion: 1.8 is bad
7.1% really is nearly nothing
especially when every other version shown there is at max 2 years old
Oh it fell again. Last time i checked it was 7.8
1.8 does not run natively under J17.
The dumbest part is there really isn't anything you can't do in 1.18 that 1.8 has. It's a myth that people perpetuate cause they don't want to learn new stuff lol
If something does not run under any non-EOL java version, something is really wrong
Some more features that are simply not there:
- BoundingBoxes
- Ray tracing
- A metric ton of events
And the list just goes on.
PlayerProfiles
question, what about optimization between 1.8 and 1.18.2?
uh Smile you forgot the best part. PDC 
no they didn't
@vocal cloud
people using 1.8 should really just acknowledge it's outdated but just stick to it because of the player base and gameplay mechanics
fun fact: they do
Oh missed that part 👨🦯
lmaoo
PDC is good and all, but not really the ultimate gamechanger
fun fact: they obviously don't
they do
The ultimate gamechanger is the new itemstack API
bruh
1.18.2 is quite optimized given all the additional features mojang has added, altho that does not go without saying that 1.8 can run fairly well
@vestal dome you don't though?
I wonder when or if mojang will concentrate on server optimization
I really hope they do one day
If you care about optimization so much you can go for Minestom.
Its 1.18 and can literally hold more players than any 1.8 or 1.7 custom fork of paper/spigot.
You can have >1000 players on a single instance if you really want to.
if i've gotten a block from p.getTargetBlockExact how do i get the face the player was looking at?
I know it's outdated, but just because it's outdated, doesn't mean it is that BAD
okey, maybe a lil bit
they do it all the time altho its not their main focus
All unmaintained software is bad after a few years
Oh yes. Thats one property of bad software: Its outdated
not bad per-se, but painful to set up
bruh
no
bad software can have tons of bugs and be supported still somehow
so DOS is still good software in every way?
what a stupid argument
Use Player#getTargetBlockFace --> https://jd.papermc.io/paper/1.18/org/bukkit/entity/LivingEntity.html#getTargetBlockFace(int)
because of opinion
The only servers that use 1.8 are the servers that can afford to hire 100k engineers to make it better lol
paper??? :0
Thats a false converse conclusion.
Just because outdated software is bad doesnt mean that up-to-date software is automatically good.
See windows
I just use the paper docs but I think the method is on spigot too. Just let me quickly check it
thank u for doing that
?jd-s
Jadss I do understand that you may like the features of 1.8, but the software itself is objectively worse than 1.18.2
Usually you want to call rayTraceBlocks.
The RayTraceResult contains information like the exact hit position and the hit BlockFace
I want to use NMS but if I import it, it cannot be found? Where do I get NMS from?
wowie thank you
Just checked. Sadly yes
Read the this article:
https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-2-release.534760/
And look under Developer Notes -> NMS
... while I have this open
is that how many people use paper
Yes
28.8% of all servers use Spigot
56.8% of all servers use Paper
this is only bukkit based
o ok
A vast majority of servers use spigot plugins though.
damb i don't wanna cut out almost 30% of servers :///
Sponge is on another chart
i will use the raycast
They probably run outdated versions
they only have 674 servers on right now tho
compared to the tens of thousands of spigot and paper
I am impressed how Purpur has 5,6% but I actually use it myself for the performance gain
Its really not that big of a performance gain to be honest. And since paper merged purpur its gotten even smaller.
I still specifically write for Spigot but have some stuff that additionally works with Paper. Currently it's still worth it to support it but the trend seems that that's not gonna hold on for long
they merged tuinity*
*tuinity
Ok tnaks and where do I find the dependency or maven config??
Yes right. Too many forks out there.
They did!? Is there a news artice or release note where I can see that change?
Upsie never noticed it xD
<#492517675680006144 message> (on the paper discord)
Starting with build #232, Paper will contain all patches and changes from Tuinity.
^ from August 2021
Ah thanks! 👍
But I have a small question.
What is the best way to create an API for a BungeeCord plugin that can be accessed by a Spigot plugin?
To explain:
I made a bungeecord plugin with an api in the style of the spigot api where there are just interfaces implemented by the actual plugin. But now I need to access some of the methods in the api for my spigot plugin.
What would the best way to do this? Should I use the Plugin Messaging Channel, should I write a second API just based on the SQL database containing classes and not just interfaces or is there a even better way?
you can use Socket connections
if you have the opportunity, opt in for something like redis or rabbitmq
Would def prefer this over sockets. Sockets can get really unsafe really quick.
forget that
redis is scalable and has a mq implementation :3
ik ik
ye I mean if you wanna get the know-how then the DIY approach might be more interesting for ya
well unsafe is relative
in the sense of reliability, a duct taped socket implementation is probably gonna be slightly more unsafe
What does PMC stand for again? 😅
Plugin messaging channel
Oh never new there is an actively used abbreviation for that 😅
Is it safe to save an encrypted password inside of an ItemStack persistent data container? Or is it easy to find
Programmers make up abbreviations on the fly
Its the first time im hearing about that too. But some are just made up on the spot like CF
afaik the pdc might get sent to the player
^
Cloud Feature?
CurseForge or CloudFlare?
CompletableFuture?
What does afaik mean? Sorry 😢
As far as I know
Okk
How can I check if a player has a item in his mainhand?
You can also write a filter that strips the pdc from outgoing packets. Thats what i do sometimes.
Never worked with redis or rabbitmq 😅 Is it easy to pick up? I don't want to go this extreme because its just for a event that will be maybe 1 - 3 months long
Player -> PlayerInventory -> getItemInMainHand()
yes but what can i check
yeah
redis is quite easy to setup
the item in the mainhand
what? if it is null?
(can be a bit hard to scale horizontally sometimes)
Its an ItemStack
You can check multiple things on it.
If you want to identify custom items then you should use the PDC of the ItemStack.
Check if its air?
Bc this doesn't work
Its never null
using an if statement could work
to check the material
but im not sure
this is what i meant. I just pinged the wrong message 😅
oh lol yeah i was a little confused what you were asking hahaa
no worries
I actually have a question
Just forgot that redis is a database. Why should I switch databases when the plugin is already done? Or has it big improvements or something I dont know? 😅
Im trying to make a command where when a player crouches, they are teleported up into the air
but im having an issue that it will only teleport the player into the air if they are crouching when they call the command
What do you mean by "command"? Because you just listen for the PlayerToggleSneakEvent and launch him up
let me send a picture
You mean a command to toggle the feature and then if they sneak they will be teleported up?
I can upload stuff 🤔
precisely
When they run the command create a Bukkit runnable, checking if the player is crouching , if it is launch it up, if it isn’t do nothing. When they are launched you can optionally cancel the task
the issue im having right now is that only if they are crouching while they call the command, then they are teleported up
Then you need for example a list of uuids where you add / remove the person if they execute the command. And in the Listener for the PlayerToggleSneakEvent you check if the player's uuid is in the list and if they are teleport them up
Or instead put their uuid In a list and when crouch event.is sent remove them from the list and launch them up. This would work as well
fun tagAsLaunchable(player: Player) {
player.scoreboardTags.add("GUMMY_BALL")
}
fun untagAsLaunchable(player: Player) {
player.scoreboardTags.remove("GUMMY_BALL")
}
fun isTaggedAsLaunchable(player: Player): Boolean {
return player.scoreboardTags.contains("GUMMY_BALL")
}
Just use the scoreboard tags to tag a player
if i use p.rayTraceBlocks and there are no blocks, what will the result.getHitBlock() return?
There is a tag feature!? I have missed so many stuff when migrating to the lastest versions xD
it will throw an exception because its null
not switch
ok
you can use redis just for the mq it provides
no need to use the key value db if you dont want to
Redis topics
What does mq staind for again? 😅
as easy as it gets
help
or Jedis
Is there an article or something I could use to get a look into how the feature works and some examples or so?
Thanks 👍 Will take a look into it
This wiki is quite extensible
I think Jedis is inferior in every way besides code size.
// This'll work to copy a world, right?
public static void copyDirectory(String sourceDirectoryLocation, String destinationDirectoryLocation)
throws IOException {
Files.walk(Paths.get(sourceDirectoryLocation))
.forEach(source -> {
Path destination = Paths.get(destinationDirectoryLocation, source.toString()
.substring(sourceDirectoryLocation.length()));
try {
Files.copy(source, destination);
} catch (IOException e) {
e.printStackTrace();
}
});
}```
Okay but how should I use it for my problem? Is this something I need to implement in my existing plugin or do I need to create a second API with this feature? 😅
code size is not an advantage.
https://i.imgur.com/LswMJqP.png
is this for finding the position of a block placed on this face?
*source file size
this is in BlockFace
And it is
World island = Bukkit.getWorld("exampleisland");
File worldDir = world.getWorldFolder();
String islandName = "isname";
FileUtils.copyDirectory(worldDir, new File(worldDir.getParent(), islandName));
WorldCreator creator = WorldCreator.name(island.getName());
World newIsland = Bukkit.createWorld(creator);```
I wanna use this code.
is this reply to me
Just use the FileUtils.copyDirectory method from Apace Commons-Io
it's not an advantage or disadvantage, it's what it is.
could you send me a link, if u dont mind ?
I am using the PlayerMoveEvent but I want to ignore Mouse & Jump/Sneak movements
Basically just when the playeris on ground and isnt moving his mouse
Read a bit on how the class loader in java works. You will see how startup times are affected by simply having
more class files present.
Also for spigot its a very big advantage because of the max file size for plugins. (If you dont count in the runtime dependency loader)
Okay I found I link that works 😅 https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#copyDirectory-java.io.File-java.io.File- (Sorry for the many pings)
do you mean Milliseconds?
like 1-5 more?
hello did anyone see my question
that CAN'T be an advantage...
The chat is currently quite active so yes
Really depends on how the classes are initialized.
And its more in the hundreds of milliseconds
i don't want to be the guy who tells people to move channel but isn't this the help channel not argument channel :x
it doesn't matter still, due to how fast computers are......
literally
Which is crucial if you design highly responsive micro services. Thats why many
get compiled to binary containers using graalvm
·_ .
as far as I'm concerned... java classes get loaded to ram?????
right??
am I stupid..
Please send a Link to the docs and not a image
here u go, i don't know what the method descriptions mean exactly
i'd like to get the block where a block will be placed if you place on a given block face
so i can spawn an entity there
Classes only get loaded once referenced some way or ther other right?
correct
I dont think these method do what you want. But I am actually to confused by the methods to help you out
I mean the Class<T> singleton takes some memory, and some other stuff
Conclure can you help
w/?
bumpy bumpy
Np
Is there a better way to have a timer for events? I'm thinking of just updating a set integer for the remaining time every second with the scheduler
I have no prior experience to redis so would you be able to quickly explain to me how I would use this feature to solve my problem?
redis has a mq feature
in other words, you can send and receive data
which in this case can solve your problem since it can communicate over a single jvm instance
U can schedule a task to run after x ticks or if u wanna account for lag, u can store the time in millis when u want to run whatever and check if current time is >= whatever the stored time is every second
there are possible null pointer exceptions on almost everything ,_,
have to catch so much
No u don't
:v
Just check if it's null
So I can communicate between my Spigot Plugin and my BungeeCord Plugin? I thought they would run on different jvm instances because you need to start the spigot server and the bungeecord server independent
if you are catching everything you are doing something wrong
Sometimes you don't have to check
Like for playerinteractevent, if action is right click block
You don't habe to check if block is null
like, i've done a check to make sure that getHitBlock returns something, but then it is saying that getHitBlockFace might return null
You can juet ignore the ide warnings that it is
like no it won't, i already checked if there was a block
Related to what? 😅 The communicating or the jvm thing
So I can communicate between my Spigot Plugin and my BungeeCord Plugin?
Ide doesn't know everything
you just connect to redis in both your spigot plugin and bungeecord plugin
register a subscriber for a specific channel (similar to plugin message channels) (in both your plugin instances)
and thats pretty much it
so doing
RayTraceResult result = p.rayTraceBlocks(5);
if (result != null) {
BlockFace face = result.getHitBlockFace();
Block relative_block = result.getHitBlock().getRelative(face);
}
this is fine
Okay so its just like the PluginMessagingChannel but more general?
@humble tulip
Never worked with raytrace
Do you have example for them so that I could understand the toppic a bit better. Would be really nice because I am not fully unstanding it all 😅
ok
Thanks but I mean like a code example 😅 xD
conclure i like your dog
how dare you assume their gender 😠 \s
If you know skmething can't possibly be null
I use a library called lettuce, I can show an example using that library
You cna safely call methods on it

If you're unsure just check ir its null
Would be really nice 😍
Hey guys, I am using PlayerMoveEvent to spawn a light at the player location and remove the previous one. But this leaves some lights still there
using LightAPI
only place a light when the player has moved a full block
I'd use a runnable every tick instead of the move event
how do i track that
@EventHandler
public void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event) {
if(event.getPlayer().isFlying()) return;
if(event.getPlayer().isSneaking()) return;
if (!(
event.getFrom().getBlockX() == event.getTo().getBlockX()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ())) {
Player player = event.getPlayer();
if (vLights.getLightPlayers().containsKey(player)) {
vLights.getLightPlayers().get(player).setLocation(player.getLocation());
util.lightPlayer(player, vLights.getLightPlayers().get(player));
}
}
}
why not importing
the class name is same so will cause issues
public class PlayerMoveEvent implements Listener {
private final VLights vLights;
private final Util util;
public PlayerMoveEvent(VLights vLights) {
this.vLights = vLights;
util = vLights.getUtil();
}
@EventHandler
public void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event) {
if(event.getPlayer().isFlying()) return;
if(event.getPlayer().isSneaking()) return;
if (!(
event.getFrom().getBlockX() == event.getTo().getBlockX()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ())) {
Player player = event.getPlayer();
if (vLights.getLightPlayers().containsKey(player)) {
vLights.getLightPlayers().get(player).setLocation(player.getLocation());
util.lightPlayer(player, vLights.getLightPlayers().get(player));
}
}
}
}
Okay so I wrote an abstraction, which if you want I'd give to you, but Ill just show how it might be used
class SpigotPlugin extends JavaPlugin {
Messenger messenger = LettuceMessenger.create();
@Override void onEnable() {
messenger.bootUp();
messenger.subscribe("myplugin:channel",reader -> {
LOGGER.infoformat("Received '%s' from proxy", reader.readUTF());
});
getServer().getPluginManager().registerEvents(new Listener(){
@EventHandler void onJoin(PlayerJoinEvent e){
messenger.publish("myplugin:channel", writer -> {
writer.writeUTF(e.getPlayer().getName()+" joined!");
});
}
},this);
}
}
class BungeePlugin extends Plugin {
Messenger messenger = LettuceMessenger.create();
@Override void onEnable() {
messenger.bootUp();
messenger.subscribe("myplugin:channel",reader -> {
LOGGER.infoformat("Received '%s' from backend server", reader.readUTF());
});
getProxy().getPluginManager().registerEvents(this,new Listener(){
@EventHandler void onJoin(PostLoginEvent e){
messenger.publish("myplugin:channel", writer -> {
writer.writeUTF(e.getPlayer().getDisplayName()+" joined proxy!");
});
}
});
}
}
``` @sand frost
Annotation on same line as the method? Conclure are u feeling okay? 😟
lol ye tried to keep it concise
yea thats curesed AF
Okay thank you really much ❤️ And I would be happy to see what abstraction you did
yeah let me push the project to github and you could have a look there
Thats really kind of you 😄
would anyone know how to get a player's luckperms group? the docs just keep recommending to use player.hasPermission, but i'm opped on the server and still not passing conditions
yeah but i'm checking if my players have these groups:
https://github.com/Conclure/Eventful/blob/master/common/src/main/java/me/conclure/eventful/shared/MainRunner.java
@sand frost
Line 25-39 is where I just check if the messenger works by itself but yeah, using lettuce and then an abstraction over it basically :3 (Messenger and LettuceMessenger) I do have another system on top of it, but that probably does not interest you
and adding myself to those groups, and i'm still not passing the conditions
??
Thank you so much! May I know what the plugin in general does 😅 I am not really understanding what the project is for xD You have some commands, something with uhc but not really much xD
uh yeah
Because it's firing for main hand and offhand
:V thank you
Oh nice. But is it done? Doesn't look that finished 😅 Many abstract classes to simply the coding experience but not really any kind of content xD
its not done cuz the project got disbanded kinda
Uff sounds like its one of my projects xDD
yeee
well, I do work on it from time to time
but I do more modding than spigot plugins as of now
But modding sounds cool to
https://i.imgur.com/RAPFKet.png
^ I have this in my onEnable, it creates a static ItemStack
I have the line
if (p.getInventory().getItemInMainHand().equals(Waystones.waystone_item)) {
in a listener, but when I right click with this item: /give @p clock{CustomModelData:400000,display:{Name:'[{"text":"Waystone","italic":false}]'}} 1, the if statement doesn't succeed, why is this?
I am currenly trying to do the second season of a event I did for a german youtuber but I am always just doing a bit and then stopping because I lose motivation quickly and some other stuff 😅
yeah, the best way not to lose motivation is to get stuff done
and dont be so minute about details and perfection
but I can totally relate
they're simply not equal
Thats wright 😅 I just got demotivated because of some bugs in PlotSquared that they are currently fixing xD
Conclure what do i do, I thought I made them equal
And also because it's a lot of work that I've taken on all by myself. 😅
I am always getting new ideas to add to the project and making it even bigger and then getting even more demotivated because its so much stuff to do xD
well
wouldnt it be better to create the itemstack based on your code?
I don't know how to do that
p.getInventory().addItem(stack);
did you write that on discord >_<
abhorrently yes
@ivory sleet But cool to see that u are currently working on your Eventfull plugin xD (or is it just open for releasing it on github? xD)
well
guess both
but I am planning on putting it on spigot resource section once its done
Did I get you to continue to work on it? xD
well, both yes and no lol
I work on it occasionally, but might do it a little bit more now
Okay then kinda happy noises xD
ye
Sounds cool 👍
tho trying to give this dino mod some love as well lol
Thats nice. The problem with myself is that I want to publish some stuff on GitHub or Spigot but then when I put a lot of work into it I suddenly feel so selfish that I want to keep the plugin just for me 😅
Thats also the reason why my GitHub is so empty and there is only one finished bugfree API there xD
Nice I can send photos now
Some spigot plugins and small projects for myself. I mostly don't upload these because of one ore more reason:
- I don't quite finish it. Just so much that it works hardcoded xD
- I abandon the project xD
- I feel like I want to keep it for myself
- It's so bad that I am ashamed of uploading it
Let me take a quick lookie xD
Question
lol yep
Looks like you have a lot of forks and some projects you made yourself. And other stuff I don't what it does xD
But its certainly more than I have xD
But on that note. Time to take some repos private xDD
im trying to Develop a command so that when first executed, any time a player shifts, they will be launched into the sky. When the command is ran again, this will no longer occur. The issue I'm having is that you must be sneaking when you call the command, otherwise you won't be launched into the air! Any thoughts?
damn my plugin is at 4885 lines of java now (excluding blank & comment lines)
this is my code that im trying rn
How many do you have? xD
in total its ~100
see conclure that is why I just have all of my stuff in a private-all org
lol, thats actually kinda smart and organized
I am assuming you put all of this code inside of an onCommand block, this would however not work because this is triggered one time
You would want to save the players UID or smth and then check if that players sneaks with a listener
OMG thats a lot. I only have like 15 projects + 1 on my organisation that is also public xD
But the most of my projects are local (I think around 100+)
quite a lot 
I did put it in a onCommand block lol. So would you reccomend I just use an event handler instead?
Well if you want it to be toggleable you would need a command and an event listener
Ok
Okay I ran my "java script" again and there are 354 projects in total. Maybe more because the script only searches in 2 folders xD
I got 60 repositories but I only use like 10 of them actively
altho replit for instance, is bombed with over 100 py projects
But then there are also 2 projects I just have for testing stuff like for example this xD
no forks?
ah ye
I delete forks after I'm done with them
but there's a few in there
yeah I dunno why people don't delete their forks
I mean you do it?
my plugin was forked 6 times but only 2 of those forks ever got additions
oh ye
I used to fork stuff in case the original repo would be deleted
but now I just fork when I might be pring
seems niche
but did that ever happen
i've got a playerinteractevent listener and rn it's firing twice cause both hands, how do i check for the hand of the item used
(which was why I started forking almost everything I could get my hands on)
check for the main hand probably
seems so weird to me lol
wdym check for main hand, check for the item in the main hand?
tho idk if the event offers a way to tell which hand used said item
tho like
use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getItem()
declaration: package: org.bukkit.event.player, class: PlayerInteractEvent
instead of getting the players main hand
oh yeah Lynx got your back here, im a bit outdated
that way your player can still use an item in offhand
thank you lynx :)
🙌
does this looks good as a beginning?
I assume disconnect shutdowns eventual connections?
@ivory sleet Took a bit to do but I have a question now xD Do you also have a project for testing small stuff like me here? 😂
I have no idea what you are doing spefically, but only thing I can see is the HikariDataSource seems out of place considering everything else is abstracted
oh I do that on replit so nope
lol
Whats replit? 🤔
ye i'm looking for a way to fix that
also what is your main class name
Xkingdoms
I mean like, it works just dont look right to me
Oh nice. Never new about it
if it extends JavaPlugin Id name it XkingdomsPlugin or sth
And there are your test projects? xD
yup
Id rather have it be like XKingdoms personally
Can you show me a example or a number of how many there are? xD
what you add after up to you, I just dont like the k not being capitalized
altho I for the most part create a new project every time I want to test something since I cant find old test projects that I wrote
Is there a way to load worlds that are not in the main file, for example "./islands/worlds/%world-name%/" <- Directory.
push not showing on github i guess stuff is broken
?tas @quaint mantle
merging brrr
I like Epic Game and kap1 - kap19 xD Just a question. What does 'kap' mean? xD
this is what im currently having
https://github.com/FourteenBrush/xKingdoms/tree/master/src/main/java/me/fourteendoggo/xkingdoms/storage
kap for kapitel which in english means chapter
what does updatePlayer(p) do?
or whats the intent rather*
its intended to save a player to a database and if it doesnt exist, create it
might want to change it to 'savePlayer' but ye
you made my day LOL
and create just creates an instance and puts it in the cache?
no database talkie talk whatsoever?
i wasnt doing implemtation yet so things are very weird 😆
it has to take a kingdomsplayer parameter ye
oh right
and somewhere else put it in cache
but my problem was about that datasource
like i dont want to write a different connectionfactory and different storage implementation for each db type
so i thought lets put it in the enum
So you are from Sweden right? The cool thing is that in German (I am from Germany) there is also the word Kapitel and it means the exact same thing (chapter in english)
understandable
But why do you have chapters in programming? xD
oo nice
althought the storage needs the connectionfactory in order to get a connection
so in fact the issue is where to put the implentation for each datasource
I have second highschool (gymnasium) and there we learn basic programming in Py, so those were projects coupled to specific chapters of our programming book
german?
Ohh cool. I am also going to highschool (Gymnasium in German) and we only have computer science (Informatik) 1 year in the 11th grade. But sadly we only learned there ruby for some time and now are just doing some other general stuff
Yes indeed xD
oo woaw
german programming education is dogshit
I mean py is pretty underwhelming, especially for people who know programming already
unless you go and find an internship
Yes but its dependent on the school you are going
If you have a modern school with enough teachers that know programming it can actually be cool. But our school has only 1 computer since teacher and just recently got some new ones
anyone know how to shortcut this block of lines?
@EventHandler
public void onClick(PlayerInteractEvent e) {
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || e.getAction().equals(Action.LEFT_CLICK_AIR)) {
if (e.getItem() != null) {
if (e.getItem().hasItemMeta()) {
if (e.getItem().getItemMeta().hasDisplayName()) {
if (e.getItem().getItemMeta().getDisplayName().equals("Speed 3")) {
// Action
}
}
}
}
}
}
Dont put them all in separate lines xD
But also you could use a general method that uses the item to check all that stuff you are doing in that event method
Yes if you are repeating this make a boolean method
Yea that was what I was thinking
yeah use explanatory variables, and favor implicit else to explicit if else
What does implicit else and explicit if else mean again 😅
if (condition) {
//TODO
} else {
//TODO
}
if (!condition) {
//TODO
return;
}
//TODO
latter is implicit else
it reduces the nesting
which is good, because developers dont read the code that does not fit on their screens (mostly)
what is better way for custom nametags (via armorstands)? Use normal armorstands or register my own one like "nametag" with armorstand model?
Ohh thank you 😄 I new that the second thing is better but I never really new their names xD
normal armor stands should suffice unless you're doing some rather specific stuff
Oh oki. The thing is I learned java via learning by dooing and over time just adopted those things (and maybe some other things from reading the java naming conventions xD)
mye, idk how I learned Java now when I think about it, but mostly by doing it over and over as well
is there a way to get the absolute path of a file without creating a file object?
plugin.getdatafolder().getabolutepath + fileseparator + file name
I had a funny start xD I started by literally just copying the code from youtube tutorials my typing it xD
well the absolute path should be ~/user/mcserver/plugins/myplugin/database.h2
not just plugins/blablabla or it wont find it
And then when I made a java programm that wasn't a plugin I really googled something like 'main method java' or 'enable method java' . Idk what it was I googled but I actually didn't knew what the main method of java was xD
wait 😂
yeah that was a rather counter intuitive concept for me as well
Why don't u wanna create the file?
But oh well now I know it and have some more experience xD But I am now programming in java for 3 - 4 years I think xD
oo right
It's the easiest way and a one time tjing so it doesn't matter
How long are you programming in java?
I am impressed. Then we are pretty close. Thought you had more xD
idk i was wondering if there was some oneline method
I think I started late 2018 or 2019
yeah, well I did get some advice on what to study/focus on from enterprise developers
which was probably a crucial underlying factor in learning Java and other stuff
That sound actually cool. I wish I knew some enterprise developers as well 😅
yuh, tho with that being said, there are some great videos that might enhance your understandings of OO, software and Java
for instance uncle bob would be one guy
Uncle Bob sounds a bit of a funny name xD
ye find it quite hilarious also
and passing plugin.getDataFolder().getAbsolutePath() and "database.h2" to that method.
ye
I think resolve is part of the Path object rather than Paths
getDataFolder().toPath().toAbsolutePath().resolve("subfile.extension") or sth would work
stop mr conclure using ::
nvm i think it was the h2 thing or hikari who made the file
its #
nonono
you make my blood boil as a rust user
Thats just lambda xD
method reference
😮
I am not writing html anchors here
just use .
Eww HTML xD
because :: is for rust only :<
then it looks like static
it isnt?
bruh ur confusing tf outta me
what does :: do in rust then?
like uh
uninstanced
mod something {
const HI: &str = "Hello";
}
fn main() {
println!("{}", something::HI);
}
ah
you can see how i'd get annoyed right 😦
yeah
im gonna continue to use :: then :3
Bruh
:: in rust is for enums too
Please just paste the code with ``code here``
.map()
smh
That looks freaky as hell xD
dude the streams are beautiful
i thought in some newer versions println!("{some_str}") worked too
maybe
idk
havent used rust for a while
oh yeah it does
wheres the dark mode on that site >->
that Hi: &str confuses my brain xD
fn main() {
let msg = "hi";
let msg2 = "bye";
println!("{msg} {msg2}");
}
didnt know that worked
set the background-colour to something black in your css
anyways
looks good tho
looks so simple but yet so powerful
Intellij supports hyperlinks in those context messages
but no, they'll provide long ass package paths instead
i guess i will do it like this now
https://gist.github.com/FourteenBrush/d0a719ed545596cec51f79dcf0c92d7e
dont ask me why i made a gist thing, i just wanted to try
that
Okay so, is there a way to loop thru all directories in a certain directory, for example
Load all worlds from directory "./island-worlds/player-uuid/", but instead of giving the id, loop thru all the directories in "./island-worlds/"
sure is
Could you provide me a quick code sample, if you don't mind ?
Hi! My plugin works with a number the value of which I want to keep in the event of a reboot. Would you recommend saving that in a .txt file and if so, how can I read/write such .txt file?
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
for (Path path : stream) {
//TODO
}
}```
use the inbuilt config file
Would it be smart to use this in a plugin where I need to load island world for each player individually ?
hmm I guess?
For example, load all the worlds when the server starts up, so there wont be any lag later on.
the value changes every so often so I don't want it to be overriden if someone has the config open and when they save it they save it with an old value
Or that's a dumb idea?
how many worlds are there
Well, there will be 1 world per team.
yes thats a terrible idea
So let's say there're like 100 worlds, it'll take quite a bite of time to load.
Then, I should load/unload them as they leave/join, right ?
Wouldn't that cause a bit of lag spikes ?
altho if possible you could try to reduce the amount of worlds
just make sure teams are separated enough from each and another
why not use single world and divide it into regions
^
I thought about that, but the problem is I've never worked with regions.
I don't know how to do it.
Yes, it's alot better to just use regions, but I've never done that.
you could just define coordinates and prevent players from leaving them maybe
start by trying
just do something that looks right to you, after that we can discuss it here
can you help me with this?
chances are youll b able to come up with some quite desirable results
WilliamD
Is it possible to have multiple world borders in a single world ?
yes but
the value changes every so often so I don't want it to be overriden if someone has the config open and when they save it they save it with an old value
it has to be separate from the config
oh
so stupid that you cant just put a comma here
missed that part, well in that case, sure
ye fourteen agree
if its just internal plugin data perhaps use a file extension like .temp or sth
how would I save and read the file? i have but a few hours of experience with bukkit plugin development
is there any way to declare a list which can accept both the impl object and its derivative:
List<? extends Foo> list = new ArrayList<>(); // Works only for extended classes. Cannot add Impl classes. I need to add both. super seems a good way to do it but im not sure.
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
it has to be separate from the config
dovidas do you mean derivatives of Foo?
both the Foo interfaces
and the its derivatives
i think ? super Foo would work
super keyword inside wildcards state that it has to have at least one superclass that foo has
myes but then you turn it into a write only list
assuming you abide by the types concretely
I mean Id just have List<Foo> if possible
Okay so, a long time ago i saw an article that you could change the spigot world path, but the problem is that idk where that was. What configuration file.
For example, all the worlds to be in ./worlds/
just use symlinks 
but if you return both a super type of Foo and a sub type of Foo like List<SuperFoo> or List<SubFoo> List<?> might be what you need since theres no real contract going on anymore
why bother changing source code when you can use junctions in windows and symlinks in unix
eh
is this it?
BufferedReader reader = new BufferedReader(new FileReader("~/plugins/Name/.val"));
String val = reader.readLine();
?
nonono
dont think the plugins folder is in your home directory
try (var reader = Files.newBufferedReader(Path.of("path"))) {
//TODO
}
it is
tbh i think it doesnt matter
it's a docker container
ye
so im using extends correctly
implements
inside wildcard
Ah
dovidas problem is, (and I see it a lot) people try to make sense of generics by talking about instances
which often leads to unnecessary wildcard declarations
these are very low level generic classes
for abstraction only
to support multiple platforms (sponge, bukkit, etc.)
for sure but point persists, when you do generics you only wanna consider types (and type constructors)
oh im not familiar with that
im just trying to decouple bukkit api from my abstraction classes
how does it look now?
https://gist.github.com/FourteenBrush/d0a719ed545596cec51f79dcf0c92d7e
ik i haven't seen the context of this question, but it seems clean enum class for me.
its for something like
void updatePlayer(KingdomsPlayer player) {
try (Connection conn = connFactory.getConnection();
PreparedStatement ps = conn.prepareStatement(s)) {
// do db stuff
}
}```
so the StorageType enum is able to get a datasource which corresponds to the type of database the user wants
good idea, enum abstraction is on point there.
better than long method which tries to resolve what the player uses
// Okay so I've created something that I'd like to use.
Create a world where all player islands will be, make the spawn point at 0/65/0 and on every 500 blocks each direction there will be an island for a team that a player will create, is there a way that that could somehow be done or?
I feel like You should have actual implementations of ConfigSupplier. Like H2ConfigSupplier.
Yes this can be done. Its not too hard.
sounds like acid skyblock
the thing that i dont really want to write a Storage implementation and a configsupplier thing for each type of database, just one thing
or i could store suppliers to them so i can get them from a storagetype constant
Acid Skyblock /
I would just look at the chunk system and scale it up.
So create a SkyWorld which contains a Map<SkyTileCoordinate, SkyTile>
And each tile is 250x250 blocks. The rest should come naturally