#help-development
1 messages ยท Page 1747 of 1
event.setCancelled(true)
i want to get the ones that are repeating
and convert them to 1 item
example:
Thanks
stone, stone, dirt, stone, grass -> stone, stone, stone -> 1 stone with 3 as amount
just iterate over all the slots and count how many you have. (not sure if theres a stack() method you could use)
Do you know your way around Java?
then Id get started with that
lol
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Hi, I am trying to send a open sign editor packet, but on the wiki, it says it needs a position/location information, but I cant find a method for that on the PacketContainer class. (here is what I am looking at: https://wiki.vg/Protocol#Open_Sign_Editor)
no
I can't think of a single often used packet that would realistically be worth caching its instance
How do I enchant items?
item.addEnchantment(Enchantment.DURABILITY, 2);
not working.
The method addEnchantment(Enchantment, int) is undefined for the type ItemMeta
can u give me sample code?
no
you can read the javadoc
its fucking simple
i literally pointed you to the method you need to use
So you want something like this? https://www.spigotmc.org/threads/signmenu-1-16-5-get-player-sign-input.249381/
ye
well there ya go
I tried that
and?
It doesnt work on 1.17
hmm, i see comments saying it does. maybe some changes need to be made im not sure i havent tried it yet
The chunk packets. Detect if a change appeared in the chunk if not then just send the cached packet instead of serializing the whole chunk again.
Not sure if something like this is actually implemented right now. Its kind of a trade off between memory and cpu time because those packets arent exactly small.
Eh, I guess tracking that might work ? However the amount of work you'd have to put into invalidating those caches seems like a pretty big rip
neither invalidate on change nor invalidate every send (calc some hash ? dunno) works out well
e.g. even tile entities ticking might just break your caching if they update their nbt
just a lot of crap sadly sent in a single huge packet that might explode any other second
How do you check if a block has been broken with spigot?
broken ? e.g. listen to a block breaking ?
What methods would that require
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockBreakEvent.html is published to listeners when a player breaks a block
declaration: package: org.bukkit.event.block, class: BlockBreakEvent
idk if that is what you are asking tho
I know about BlockBreakEvent
What would I do with BlockBreakEvent to tell if a specific block is being broken
ok thanks
pls
you have literally an answer underneath it
no
Is there a better way of getting a player from a command other than?
Bukkit.getPlayer(sender.getName());
no
thought so
actually yes
hmm?
Increment the corresponding variable if it is the specific item
Cast the sender to Player if it is an instance of Player
if(!(sender instanceof Player)) {
// code if sender isn't player
}
Player player = (Player) sender;
yeahh thanks
tho
You can simplify it
in more recent versions of java you can do
if (sender instanceof Player player)
Yeah
or
if (sender instanceof Player player) {
player.sendMessage("Hello")
}
I know java - thanks
yeah
๐
@vestal moat please use a traditional paste bin
lucy's is fine, but dont have it run through a custom link
Huh
?paste
Its lucy's but i improved
Algorithm wise this is not great. It also may contain bugs. But you get the general idea:
public void rePack(final List<ItemStack> itemStackList) {
final List<ItemStack> items = new ArrayList<>(itemStackList);
itemStackList.clear();
outer:
for (final ItemStack next : items) {
for (final ItemStack current : itemStackList) {
if (current.isSimilar(next)) {
final int currentAmount = current.getAmount();
final int nextAmount = next.getAmount();
final int combined = currentAmount + nextAmount;
if (combined < current.getMaxStackSize()) {
current.setAmount(combined);
continue outer;
} else {
current.setAmount(current.getMaxStackSize());
next.setAmount(combined - current.getMaxStackSize());
}
}
}
itemStackList.add(next);
}
}
final ๐
Also i don't have the error now im not on oc anymore wtf
private static List<ItemStack> sumEquals(Collection<ItemStack> items) {
List<ItemStack> result = new ArrayList<>(items.size());
for (ItemStack item : items) {
if (item == null)
continue;
boolean has = false;
for (ItemStack stack : result) {
if (stack.isSimilar(item)) {
stack.setAmount(stack.getAmount() + item.getAmount());
has = true;
}
}
if (!has)
result.add(item);
}
return result;
}```
but thanks anyway
Bruh give me the link back in dm im on phone and i don't have the error with me
This will clone items
Ye now i wanna fix it
Dude hastebin so bad
Anyways i didn't import it
So how
Like logic
its from discordsrv
wdym with clone
Wdym
do you have litebans installed
do it
Had it for test purpose
oh this is your plugin
Yes...
is it still in your pom?
Litebans?
yeah
I use gradle
is it in your gradle?
Yes
then remove it..
you're instantiating a class that imports it
Never called it
I mean it wont clone stacks but it will create stacks that are greater than what they are usually allowed to be.
that is not a problem in my case
final List<ItemStack> items = new ArrayList<>();
for (int i = 0; i < 200; i++) {
items.add(new ItemStack(Material.STONE));
}
final List<ItemStack> post = sumEquals(items);
System.out.println(Arrays.toString(post.toArray()));
Produces:
[22:38:51 INFO]: [SpigotSandbox] [STDOUT] [ItemStack{STONE x 200}]
Never called that for litebans
Ah ok
because i need to show how many items he will need to craft something
would be nice if java actually showed where the exception generated
๐
the plugin is at https://github.com/BlueTree242/DiscordSRVUtils/tree/development
(not on master)
import tk.bluetree242.discordsrvutils.listeners.punishments.litebans.LitebansPunishmentListener;
wait is this why?
interesting
nope still erroring
what is the problem
https://paste.md-5.net/edojijapup.sql this error
what you want to do
fix the error?
๐คฆ๐ฟโโ๏ธ
and why there is an error?
bruh look at it
you have an error?
what u want to do
why is it there
anyways @vestal moat i think because its being imported through the listener
One of the reasons this might happen is when you shade your dependency in.
im not familiar with this, but try and use Class.forName
dont think i did..
no i didn't
its compileOnly
Also this path looks incomplete litebans.api.Events$Listener
no thats just how bad litebans is
yes libertybans alot better
but people requested it so i do it for them
lul... Then make sure the version you are developing against is exactly the version you use on the server.
i would use java try { //call listener here } catch (NoClassDefFoundError e) { System.out.println("litebans not found :D"); }
the error is while loading so there is no way i called it atm
i check if it is installed or not first on enable
you referenced your listener somewhere
this is not reached
Events.Listener litebanListener = (Events.Listener) Class.forName("tk.bluetree242.discordsrvutils.listeners.punishments.litebans.LitebansPunishmentListener").newInstance();
// ...
its because you are importing it i think
but i imported advancedban on the advancedban listener and no errors
maybe because you have advancedban?
make sure the version you are developing against is exactly the version you use on the server.
i dont have any bans plugin atm
wdym by this
Look inside the litebans jar to see if there is even a package named litebans.api
omg
.
Then dont load classes with imports that are not reachable at runtime.
litebans not installed, package correct or wrong does not matter
Just prevent initialization of the class that uses the litebans imports
try catch
thats what i said ๐ฆ
isn't litebans the one that has their api being "just execute the commands" or w/e?
its that bad
but people wont move on
lol
Even worse
U need to use db by urself
Wtf
Maybe i shouldn't extend classes that doesn't exist?
we gave you the fix
pls no spam.......
o ye I was making an implementation for that plugin, an admin wanted to check ban/warn history through a discord command and I just got tired becausew their api is non-existent
libertybans โค๏ธ
Forever
Free plugin better than paid plugin which is a rare case
there's a lot of bad paid plugins though
everything is good, we just dont know how to use them properly
So if the code doesn't even reach the onLoad method, how can i try and catch?
Litebans is not, just see how bad the api is
99.9% not going to work
THANKS
Bc i don't even interact with that class until litebans confirmed installed which is happen after discordsrv bot is online
This error occurs while loading
Then you are initializing the class somehow. Either by calling a static method in it or by constructing an instance.
Ok ig ill look for the last time
litebans/api/Events$Listener its bc of the extend, confirmed
finally got rid of the *** errors
what would be the easiest approach to making something that can detect a button press on a HTML website? for example, i have a button on a html website (which i have hosted) then detect when its pressed then restart the server, i understand
ServerSocket socket = new ServerSocket(port);```
just dont know where to go from there
You will need to have some javascript function callback for the button element, then that function makes a request to your backend thingy
For the website: Use JavaScript.
The mc server needs an open ServerSocket, the website needs a client socket (javascript impl)
Then the js simply sends some bytes to the open server socket
Depends. Do you write the ItemStack in your config with code or do you just define the Material?
You can convert a String to a Material using the static method Material.matchMaterial(String)
Get the lines as a List<String>, translate every line and set this translated list as the lore of the items ItemMeta.
Just dont forget to set the ItemMeta back on the ItemStack
Hey, I made a minecraft spigot 1.16.5 server on my pi and don't know how to add plugins, can anyone help?
like...raspberry pi???!
You will need to access it via sftp so you could use FileZilla or Winscp
yeah raspberry pi
If you're planning to release this server to the public I really don't recommend using a raspi and switching to something else.
It's already released and I have people playing on it currently
They want keep inventory enabled but I can't because it won't let me use commands and I don't know how
so I was just going to use a plugin for that
how do you connected previously to the raspi?
I don't understand
how you added a server to the raspi previously
I found this video on how to build it, it's been running nostop since then
https://www.youtube.com/watch?v=YF83CcrldHY
follow this if you want to access it
Do I need that on my computer or on my pi?
computer
hmm
root
wdym root?
and what does filezilla do? like once i download it what can i do with it ?
Filezilla allows you to connect through ftp and ftps
fill out the credentials it asks for
oooh well i'm an idiot
all i had to do was not add a / in the console and all of the commands would work
thank you guys for the help though <3
Does anyone know how to decrypt a texture pack?
He wants to get the font of this server texture pack
I think the texture pack is for a server called PandaCraft. I dont remember
Sadly dont think anyone here would download that file and check it out for you
Not to mention decrypting something most means you need the encryption key(s)
its loaded by minecraft so not like its actually encrypted
They prob just break some byte that any proper zip reader needs
config file manager
Write a java program
Ok
Thought of a system to allow commands to change fields in certain classes
i thought it would be cool to use annotations
would generally declutter things
but i ran into trouble when trying to define illegal values for the field
e.i. field is an integer but cannot be less than 0 or
field is of type X and X.Y cannot equal 4
so i thought using a predicate in my annotation class would be a smart idea
but i realized that predicates are not allowed in those
anyone have a suggestion for this kind of system?
(tl;dr want to allow commands to change fields in the plugin and define illegal values)
i thought of another way to do it without annotations but i dont like it as much..
hot
This is a bit of an odd question and I am a bit new to plugins, so forgive me if I need to explain a bit more (just let me know and I can ๐ )
@EventHandler
public void onQuit(PlayerQuitEvent event) {
FirmamentPlugin.worldBorder.refresh(false, false, event);
}```
I have the event above listening for players leaving, and then refreshing a list of online players. However, it appears as if the event occurs before the player is actually considered offline, so the player is still added to the list.
Collection<? extends Player> playerList = Bukkit.getServer().getOnlinePlayers();
int total = 0;
for (Player currPlayer : playerList) {
// If the player is online, alive, and valid, add their levels to the total
if (currPlayer.isOnline() && !currPlayer.isDead() && currPlayer.isValid()) {
total += currPlayer.getLevel();
}
}
Event's do not complete until all of their listeners have finished being processed
so do whatever you need to do one tick later
using the bukkit scheduler
Ah, alright
then, I may have a related issue.
java.lang.IllegalStateException: WorldBorderBoundsChangeEvent may only be triggered synchronously.
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:616) ~[patched_1.17.1.jar:git-Purpur-1419]
at org.bukkit.event.Event.callEvent(Event.java:45) ~[patched_1.17.1.jar:git-Purpur-1419]
at net.minecraft.world.level.border.WorldBorder.lerpSizeBetween(WorldBorder.java:169) ~[patched_1.17.1.jar:git-Purpur-1419]
at org.bukkit.craftbukkit.v1_17_R1.CraftWorldBorder.setSize(CraftWorldBorder.java:46) ~[patched_1.17.1.jar:git-Purpur-1419]
at me.coopersully.Firmament.Firmament.setSize(Firmament.java:92) ~[Boxed-in-1.0-SNAPSHOT.jar:?]
at me.coopersully.Firmament.Firmament.refresh(Firmament.java:122) ~[Boxed-in-1.0-SNAPSHOT.jar:?]
at me.coopersully.Firmament.events.FQuitEvent$1.run(FQuitEvent.java:18) ~[Boxed-in-1.0-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Purpur-1419]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[patched_1.17.1.jar:git-Purpur-1419]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.17.1.jar:git-Purpur-1419]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
at java.lang.Thread.run(Thread.java:831) ~[?:?]```
This is what happens when I attempt to run it 1 second later
you are using an async task to interact with the world it looks like
You are running it async
i'm not sure i understand
use Bukkit.getScheduler().runTaskLater
Show your code running it 1 tick later
what u have so far
ah alright
@Override
public void run() {
Bukkit.broadcastMessage("A player left the game; executing correlating events");
FirmamentPlugin.worldBorder.refresh(false, false, event);
}
}, 1);```
1 thread, yes
ok your issue
I should change Async to Sync?
gotcha- sorry im a bit slow
it ok
That would require an entire rewrite of the server end
they are lazy and it will cost them a lot to basicalyl rewrite the notchian server
and they will make nothing out of rewriting it
You can pay them if you want
I mean notch never thought MC would be as big as it got
well they do not benefit financially at all if they do it
that too ^
gonna cost you a good million
Im suprised no one used MC protocol to make a jar from scratch that incorporates multi core support
i think that every time notch tweets something offensive he should rewrite a little bit of the mc servers
we'd have it done in a week
its not that simple
I made a MC server with NodeJS using the MC protocol but its a total bitch to use, i only got the MOTD and server list returning working it wasnt even joinable
Nope not at all
Not really
If anything it would mean you need to add more codebase to the official jar
i dont think anyone would benefit enough to rewrite the entire notchian server
Then patch your own jar like others have done that is specifically designed for the game mode your making
EG, faction jars
Hyperion is a decent example of an optimized spigot fork, its mainly so TNT is more optimized
But hyperion is kinda expensive asf when i last checked a few years ago
how?
Never heard of it, but because a different spigot patch is better than another doesnt make one jar "bad"
When i did work on Mozektot they used Hyperion jar
have fun
What's the point of that exactly?
I mean, isn't that basically the move event ๐
Meh
no one cares tbh
Why would we?
by doing what exactly?
๐คทโโ๏ธ
I don't have my own server, can't say
I personally don't even care about 1.8.8
thats just a interface
and one yoinked from someone else's project as well
^
I could of made an interface just like that in 20 seconds, thats really nothing special it probably uses 10 other classes to actually use but
Why would you even leak a authors source code unless its open sourced, thats just scummy
.
Yea, but isn't that "Implement everything yourself" iirc?
The main difference compared to it is that our implementation of the Minecraft server does not contain any features by default! However, we have a complete API which allows you to make anything possible with extensions, similar to plugins and mods.
.o.
Yea.....and just to get everything a normal jar has it would end up looking like node
and you'd have to hope the libraries you have aren't shit
and if you're depending on one, you'd have to hope it isn't depending on a different variant of the same type of library you already have (e.g. loot tables)
imo, it's just a mess
I mean, if forks actually worked properly I could probably hardfork and do a decent-ish improved server
I mean, I'll have to do it anyways for a different project, so we'll see ๐คทโโ๏ธ
is there some type of event for when tnt explodes
i want to change how big the explosion is
EntityExplodeEvent iirc
bc primed tnt is an entity
player.sendMessage(msg);```
what do i do
it says Cannot resolve method 'sendMessage(java.util.List<java.lang.String>)'
ok thanks
You need to get that list of strings into a single string. You could do a simple for loop and concat the messages together then send it.
can u give me some example pls?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
o
ok
So, I'm trying to create a tpall command that takes the maxEntityCramming gamerule into account. I've already figured out how to split the players evenly based on that number, but I am having significant trouble figuring out how to implement location checks.
In the image provided, I've marked locations where players should be teleported to.
- Gold = The origin point. (Not included in teleportation)
- Green = Locations to check.
- Blue = Further rings if needed.
Obviously, if any of these locations are invalid (lava, can suffocate the player, etc) I don't want players teleported there.
Here's my problems/questions:
-
How should I go about finding these locations?
-- Should I just create a map of locations with a boolean indicating that the location is safe?
-- Can I make these checks mathematical? Ideally, I would like to just calculate locations up to the number of players split, but for a rough prototype, checking every location in green should work. -
How do I check for topology. (I.E different Y levels)
-- Because not every player is going to be on a perfectly flat area.
- How do I check for topology. (I.E different Y levels)
-- Because not every player is going to be on a perfectly flat area.
You'd just use getHighestBlock or something along those lines i believe
just tp them all to y 256
Read the documentation
Getting the highest block gets the highest block
It won't take caves or anything into account
But it's fast
It uses the heightmap so it's much faster than just iterating down to find the highest block
Obviously, getHighestBlock would work if the player executing the command is on the surface. However, I'm trying to account for underground areas as well. 1.18 caves are huge and have plenty of room for players to be teleported there. I could do a Y check on the player to use getHighestBlock if they are above Y64, but I'm not a fan of that approach as some caves can literally generate from the surface all the way down to the bottom of the world.
What if a cave is exposed right under a mountain? If the player is in that cave but above Y64, players will be teleported to the top of the mountain if I were to use getHighestBlock
Is NMS imported to the project
Actually class names still use Spigot Mappings iirc
Might be wrong though
How can you prevent player from spawning entity using spawn egg?
I've tried to cancel PlayerInteractEvent but it doesn't work If the player right clicking it on the entity, it will spawn a baby instead.
CreatureSpawnEvent
But that doesnโt have a player context
Alternatively you can also cancel PlayerInteractEntity
I've tried that also.
createspawnevent has spawnreason
Oh wait a second, I put the wrong event.
But you can't get the ItemStack of the egg, can you?
not that im aware of
Well im trying to use remapped but getting "cannot resolve" when I add ```xml
<classifier>remapped-mojang</classifier> <!-- Comment this out for regular Spigot mappings -->
Oh yeah, the PlayerInteractEntity do the thing, thanks.
Cannot resolve org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT when trying to use the remapped
have you ran build tools
Did you install the remapped version
What is the BuildTools command to download the remapped jars?
whats the buildtools command?
You'll need the --remapped parameter
holy shit i love u
what even is the remapped?
i just know i need it to follow this tutorial
Well, it installs the remapped version of the server jar into your local maven repo
Two technically
When Mojang publishes their server, all of the methods and classes are obfuscated (e.g. single nonsense letters). Spigot source code is build against a mapping of those methods called spigot mappings, that define spigot-decided names for methods needed
Mojang also ships their own mappings, giving names to these obfuscated methods
Spigot doesnโt even map anything anymore
While the server is running however, it is "obfuscated"
In some spigot pages I get "error, you do not have permission to access this site" and I am already registered on the page.
E.g. neither spigot nor Mojang mappings
Legal reasons I assume
hmmmm..
org.spigotmc:minecraft-server:txt:maps-mojang:1.17-R0.1-SNAPSHOT was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced
Ooof, yea that is about the limit of my knowledge of what spigot does with mappings
oof
its letting me use the methods now though
which makes it really confusing..
Well the missing mappings are only needed when reobfuscating your plugin
need it for npcs https://www.youtube.com/watch?v=mnUVroXsyG8&
In this episode of the Spigot MC Plugin series, I show you how to create an NPC with NMS and Packets. First, we make a fake player with a skin. Then, we give that NPC some items and a helmet. Finally, we make it look at you when you move around it. #Spigot #SpigotTutorial #MinecraftNMS
Brain.fm 20% off: https://brain.fm/kodysimpson
My code: htt...
Has the official examples
Scroll down for a bit until you find NMA
NMS
yeah im following that
๐ช sadly that's about as far as I know spigots Mojang mappings tooling
It's not related to java or spigot at all, But I need it for my plugin...
I need to create a 3D database to store data:
D-1: Special Blocks (Consider sth like Slimefun blocks)
D-2: Have Access Or Not
D-3: Players
I was using Json, But it is getting out of hands (More than 10K Blocks and 1K Players) so I decided to use SQL, But how should I implement them in a table?
Just getting started on databases but you should probably use the UUID of a player for the primary key
Depending on what else youre planning on doing
Maybe just have a
| UUID | Array of Blocks | Boolean | where as Shreb said uuid would be a nonnull primary key
I'm just confused what the table should be... Players as Columns and Blocks as Rows ? Then I have to add a new column for each new player... Reverse of that, I should do it per block...
Loading the permission for the user might cause issue with 10K Blocks ๐ค
If youre really enthusiastic you could have foreign keys with another table which just has the UUID of the player and the blocks attached to each Uuid
Hmm ๐ค Maybe that works... But isn't there a simpler way for some who never used SQL before ๐
Just use a document based dB
Im also just getting started on it. Thats as far as I go on this XD
Then you don't have to learn SQL ๐คฏ
I'm using that but now I have about 10K Files in server hard ๐
Huh ? You are using mongodb or the likes ?
Nope simple yaml ๐
Yea, that isn't really a database
Mongodb could allow you to do the same but properly
Or well, some other documented based dB like couchdb
The real issue is the performance Every time the server checks for the permission We get a lag spike (Really short maybe 2 or 3 ticks)
But still annoying
You have multiple servers running?
Not like a database will be magically instant. You have to move IO (such as database lookups) off the main server thread
Everything is on one huge server (12GB Ram and 1TB Hard disk)
And even the 12GB is dying with the amount of blocks now
That's why I want to use SQL
Damn ok. Otherwise you could have had each server have a seperate file
I could give you a start on how to create the table for the data
I now the basics, I'm just stuck at the design of table

Maybe this one works:
Block | UUID | Permission
1/21/-5 | 123... | Yes
1/21/-5 | 123... | Yes
10/2/-9 | 123... | No
Just not sure on how to get the blockarray working
I don't need unique keys ๐ค
Could it be faster to make the block the primary key and then have a list of uuids?
And I always have to check A UUID with A Block
Aka even for the yaml file you could have the blocks and then a list of uuids
Yeah, As I will have atleast 1 row for each block but not all players for every block
That's what I'm doing ๐
The other way around is slower?
I guess so...
Could be worth a try to invert
But as far as I don't get the spike lag and I get to clean the 2GB of hard data I'm ok with it
I dont think it would solve the memory issue but having a Uuid contain a list of allowed blocks could be a good way
Mostly since you have less UUIDs than blocks
Nah, As permission is a 3 way thing in my plugin, Yes -> You can access, No -> No access at all (Block) Missing -> Basic access
Save a hashmap for each UUID containing the block and then a boolean?
The No means they can not even notice it is a special block.. but Missing means they can notice what block it is
And this is what I have saved on the hard disk
But per block ๐
Im not sure if runtime on hashmaps is linear or otherwise. If its linear it would definitely save you time to save the UUIDs instead of the blocks
Since you said you have 10k blocks and 1k players
I'll try that, But I think I might just go for SQL
Yeah it has in best case an O(1) lookup time, removal time and add time complexity
public boolean runSafe(Runnable runnable, Consumer<Exception> errorHandler) {
try {
runnable.run();
return true;
} catch (Exception e) {
e.printStackTrace();
if (errorHandler != null)
errorHandler.accept(e);
return false;
}
}
public boolean runSafe(Runnable runnable) {
return runSafe(runnable, null);
}
``` heres something completely unrelated
just a utility
So its always the same no matter how many entries? Or do you mean O(n)
Yeah
I have one my self in the core plugin ๐
Damn ok so the amount of blocks you have shouldnt have an impact
Its lookup time may be the same regardless of size, with that being said it isnโt always the case
But it is not... If you have the data ready it is, But I have to read it from file and encode it to data and bigger the size more time it takes to encode
And the encoded data isnt serializable?
Yaml ๐คท
Well ideally youโd have a concurrent hash map in which you read the data asynchronous which should be fast enough assuming youโre not performing some sort of bulk update
The statistics of my plugins says it is loading about 10 blocks per second average...
The issue is that the amount of files causing issue, As each block is in a separate file
Idk how you implement stuff so that feels like a pretty vague argument, anyways if itโs startup/bootstrap loading loads of data is okay even if itโs synchronous.
ยฏ_(ใ)_/ยฏ
Might have to start implementing an expiring cache
I agree with that ๐
I have one ๐ It will keep the perms for 1 minute
Also not sure on why each block is a separate file
Probably to isolate and modelize the data
At first it looked ok... I never imagined players start using the blocks this much
And also to keep it easy to manually edit the data
Shreb assume you just want to load player file x, then having it in a separate file could be of help, for instance you donโt have to read all players which would be the case if youโd have all player data in a single file
Fair enough. Thanks for the explanation
What if I want to remove a block permissions completely ๐คท
Then I have to check 1K files
The only thing I can think of is to make the processing of a blocks data take less resources
I usually need to do that manually ๐
I think the SQL fix the issue... No More Huge Folder to look into
I cant really help you there without knowing exactly what youre trying to put into the database
I want to make Custom Trading Gui, where i can trade with my Custom Made ItemStack items, how do i make it, how do i start
Are you trying to open the GUI using a command or a playerinteractevent?
command
Then you should start by making a trade inventory
Not sure how to do that since Im on my phone and cant experiment
ah k
pog i managed to make it wrk
Hello i'm trying to shade lucko.helper in maven but doesn't work
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocation>
<pattern>me.lucko.helper</pattern>
<shadedPattern>com.example.testmaven.me.lucko.helper</shadedPattern>
</relocation>
</relocations>```
Error shown
> Cannot find default setter in class org.apache.maven.plugins.shade.mojo.PackageRelocation
How can i shade this dependencies ??
That thing you sent is for relocating the dependency which in your case, you're struggling with
I'm just trying to include my.lucko.helper dependencies in my final jar.
I don't want to add lucko plugin in the folder but include in my jar.
Can you tell me how to do that correctly ? (im new at java dev)
You shouldn't shade the whole jar into your plugin
Why ?
Although here, they show you how to shade their API:
https://luckperms.net/wiki/Developer-API
i just want to use gui helper found here https://github.com/lucko/helper/wiki/helper:-GUI
I can't explain it at the moment but it's discouraged
' do however recommend just installing the standalone plugins. These can be obtained from Jenkins.'
yeah i read that but i would like to try to shade for my own experience ^^
Huh?
I was talking about shading, but finnaly i just need to change provided to compile. I just want to know what is shading exactly ? I read many things about "shading" but I don't know if it's only to compile dependencies in main jar
It basically includes the dependency to your jar
ยฏ\_(ใ)_/ยฏ
Instead of one block per file why not have it where when a block is placed in a singular chunk, a file gets created for that chunk and store blocks in a JsonArray that way?
ItemStack roteSp = new ItemStack(Material.NETHER_WART);
ItemMeta roteSpMeta = roteSp.getItemMeta();
roteSpMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&cRotter &6Splitter"));
roteSp.setItemMeta(roteSpMeta);
MerchantRecipe recipe1 = new MerchantRecipe(new ItemStack(Material.FIRE_CORAL_FAN), 1);//result
recipe1.addIngredient(roteSp, 2));```
ah i am trying to add my itemstack material to the recipe1 ingridient but it throws this error: ```addIngredient(org.bukkit.inventory.@org.jetbrains.annotations.NotNull ItemStack)' in 'org.bukkit.inventory.MerchantRecipe' cannot be applied to '(org.bukkit.inventory.ItemStack, int)'```
And when you import plugin API's you should be using the provided scope
And in your plugin.yml
It needs to depend or soft-depend on that plugin
That way your plugin loads after x plugin so your plugin gets "provided" the API by the x plugin
Shading a plugin into your own plugin is just kinda pointles
excuse me can you help me above in my code ? ๐
how to for example send a get request to https://api.mojang.com/users/profiles/minecraft/SalC1
and then get the id thing in json as a string
Are you using Spigot? Or is this some other project
spigot
Use Bukkit#getOfflinePlayer(String) then use getUniqueId
the link was an example
and my server is offline mode
Thank you very much for precisions.
But If I want to distrube my plugin, it's the easiest method to share it, with shading no ? I don't need to tell at everybody to add this and this plugins ?
If your using an API from another plugin it needs to have the plugin installed anyways
It's just a librairy, https://github.com/lucko/helper/wiki/helper:-GUI
Noted not helping you
this "plugin" is just a library for dev
Ohhhh
I thought you were using an aspect inside of LuckPerms
Then yes, just shade the jar into your plugin then
Ok, thanks for your help guys. I'm learning java and you helped me a lot
connect to player channelpipe and intercept it there
npc interacting
you save the entity id from the npc you created
and check on the interact packet if its yours
(btw injecting is done on join then disconnect the pipeline on quit)
private void removePlayer(Player player) {
Channel channel = ((CraftPlayer)player).getHandle().playerConnection.networkManager.channel;
channel.eventLoop().submit(()->{
channel.pipeline().remove(player.getName());
return null;
});
}
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
is this the way to make a self-cancelling task?
this.cancel will also return and everything past it
gets stopped
and yeah it can be done through a trigger
you can also store it in a bukkittask and cancel it from somewhere else directly
also put delay 0
unless you want it running a tick later after its called
does this.cancel() makes sure everything after, in my case the traders.forEach doest get executed anymore?
yes
or do i really need the return?
it kills it instantly at that line
aha ok
if you are really worried about it you can also just do a check for cancelled
before executing your traders loop
nah its just a stupid trade command
You still need the return though
this.cancel() will continue the remainder of the task otherwise
Hello, I'm trying to register a command but i get the following error
[12:30:17 ERROR]: Error occurred while enabling Languages v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.davide.languages.Languages.getCommand(String)" is null
Register the command in the plugin.yml
well guess someone bullshitted that info a while ago kept saying cancel also returns๐
name: Languages
version: 1.0
main: me.davide.languages.Languages
commands:
lang:
so?
Yeah, assuming the command you're setting is lang
i've made that but idk why i get this error here
@Override
public void onEnable() {
registerCommands();
instance = this;
}
and I made a private void registerCommands();
where i made private void registerCommands() {
getCommand("lang").setExecutor(new LangCommand());
}
Only reason that error would be thrown is if the command wasn't in the plugin.yml, so just be sure to save, re-export, and double check there aren't two instances of your plugin in the plugins directory
For good measure as well, commands in the plugin.yml generally include some additional information
commands:
lang:
description: This is a description
At the very least, a description
List of possible options are here: https://bukkit.fandom.com/wiki/Plugin_YAML (scroll down to "commands")
Also I understood why, I've made this plugin through the mcdev intellij plugin and it uses maven, it register the plugin.yml that is on the pom.xml
been experimenting with complicated command handlers to optimize performance, but this caught me:
what's the best way to handle commands cleanly?
Oh that's what i was looking for
Performance isn't really a factor when it comes to command frameworks. It's preference
I, personally, just use Bukkit's framework for commands. Nothing extra on top. There's nothing wrong with it
Others prefer annotations, others prefer abstraction, etc.
Who can convert this code to NMS for me?
CraftPlayer craftPlayer = (CraftPlayer) player;
craftPlayer.getHandle().listName = name.equals(player.getName()) ? null : CraftChatMessage.fromString(name)[0];
for (Player player1 : players) {
EntityPlayer entity = ((CraftPlayer) player1).getHandle();
if (entity.getBukkitEntity().canSee(player)) {
entity.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, craftPlayer.getHandle()));
}
}
That is using NMS
Though there is a player.setDisplayName() method that does exactly that in the API
if (!this.playing) {
return;
}
final int time = NumberUtils.randomNumber(2, 5);
this.getArena().broadcastTitle("games.first.green-light.title", "games.first.green-light.subtitle");
this.getArena().broadcastSound(
this.getArena().getMainConfig().getSound("game-settings.sounds.green-light", "GHAST_MOAN"));
this.canWalk = true;
Bukkit.getScheduler().runTaskLater(SquidGame.getInstance(), () -> {
this.getArena().broadcastTitle("games.first.red-light.title", "games.first.red-light.subtitle");
this.getArena().broadcastSound(
this.getArena().getMainConfig().getSound("game-settings.sounds.red-light", "BLAZE_HIT"));
Bukkit.getScheduler().runTaskLater(SquidGame.getInstance(), () -> {
this.canWalk = false;
final int waitTime = NumberUtils.randomNumber(2, 5);
Bukkit.getScheduler().runTaskLater(SquidGame.getInstance(), () -> {
singDoll();
}, waitTime * 20);
}, 20);
}, time * 20);
}
How can I separate 2-3-4 and 5? For example, if 2 comes up, give 1 diamond, if 3 comes up, 2 diamonds, if 4 comes up, 5 diamonds, if 5 comes up, 6 diamonds.
My code only works for 1 version, but I want it to work for 1.8-1.17
Sorry, it's Player#setPlayerListName()
There's API for exactly that
So,
player.setPlayerListName(ChatColor.translateAlternateColorCodes('&', name));
Literally your whole method can be reduced to just that lol
@Override
public void setPlayerListName(String name) {
if (name == null) {
name = getName();
}
getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromStringOrNull(name);
for (EntityPlayer player : (List<EntityPlayer>) server.getHandle().players) {
if (player.getBukkitEntity().canSee(this)) {
player.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle()));
}
}
}```
That's how CB implements it
It's not a spigot plugin development question
yes it is
where is the plugin part?
Why use spigot then?
unless you will work with command blocks(likely not even then) you cant
It's not weird lol
spigot is merely a framework so others can use it to modify
been experimenting with complicated command handlers to optimize performance, but this caught me:
what's the best way to handle commands cleanly?
also how would i cancel events when a bukkitrunnable is cancelled?
but how are those plugins made then?
magic
Like how are the plugins to "change the tablist" made
unregister the listener as well
that doesnt work
it stops the events
it doesnt get unregistered
simple
what's the best way to handle commands cleanly?
Best advice here is to check out other large plugins source codes and see how they handle their commands.
also how would i cancel events when a bukkitrunnable is cancelled?
What do you mean by this?
what's the best way to handle commands cleanly?
Answered this like 10 minutes ago:
Performance isn't really a factor when it comes to command frameworks. It's preference
I, personally, just use Bukkit's framework for commands. Nothing extra on top. There's nothing wrong with it
Others prefer annotations, others prefer abstraction, etc.
i assume you are storing that said listener in a field and use it to register/unregister not creating a new one for unregistering right?
oh u were talking to me
Yes lol
my bad
Anyway do you guys know a place where I could get help with bungeecord? All i try to do is a tablist which is the same for every people accross all servers of the bungeecord proxy
I feel using additional plugins for tablist is just a waste
well thats gonna be rough
also how would i cancel events when a bukkitrunnable is cancelled?
basically i have aCountdownclass
public abstract class Countdown {
private int time;
protected BukkitTask task;
protected final Plugin plugin;
public Countdown(int time, Plugin plugin) {
this.time = time;
this.plugin = plugin;
}
@EventHandler
public void onEntityDeath(onEntityDeath event) {
}
public abstract void count(int current);
public final void start() {
task = new BukkitRunnable() {
@Override
public void run() {
count(time);
if (time-- <= 0) cancel();
}
}.runTaskTimer(plugin, 0L, 20L);
}
}
this is the code structure, now im trying to cancel the event on event cancel [it gets registered in start()]
a tablist its not exactly meant to go cross servers
event.setCancelled(true)?
i dont see it registering
you mean like the players also , just the text people put around the tab list
i was trying to refrain from making an object
nothing is impossible nor difficult Stellrow, I think you have a pretty restricted vision of what's possible
We definitely do this
it's just a question of good practise and courage
Though we also don't use BungeeCord and we have a very, very hacky system for it lol. All custom
so i guess querying bungee to get all online players than later creating fake ones on a tablist is a good way?
idk bout that one
why
you can't otherwise
The event instance if passed once per listener (pre eventhandler method), so that's the only way you'll be able to cancel that exact instance
what about unregisterAll?
It's pretty much the only way, yeah. We synchronize players through proxy messages
What about it?
Then yeah, fake players w/ custom names
Just pass an event object into your count function
would it also not work?
It will not add any extra load
private Listener gameMechanics;
@Override
public void registerMechanics() {
pl.getServer().getPluginManager().registerEvents(gameMechanics,pl);
}
@Override
public void unregisterMechanics() {
HandlerList.unregisterAll(gameMechanics);
}
also the event gets registered in the constructer
instance based listener
how about "scoreboards which have an objective of displayslot=sidebar", then we createTeam() and .addPlayer(), ain't that supposed to replicate a tablist?
In that case the event will only be used once
if hes registering it on start
Why would he register it every time
always pass a new instance of the listener your working with
to achieve instanced events
wich is what he wants
i use this for my minigame engine
Does anyone know how to update the xrot (head going up and down) of an entity properly? I'm trying for an iron golem to look from 0 to 45 in 20 ticks, but it just looks at 0 the whole time and doesn't update, even though the value does change...
I tried doing just #setXRot(...) too, but same effect.
each game instance has its own listener
yes exactly
its a minigame
i know my code sucks and i wanna rewrite it but im lazy
Oh there we go, more context
Which was important
Because at first it looked like a global event that runs each time someone kills an entity
basically, its a 5 minute game that keeps resetting if no one loses
it is actually the game
why not store it as a bukkittask?
man i made this at 1 am
;D
welp time to rewrite it in that case..
im fully open to better approaches
tru
okay so
whats a better approach
Depends on the minigame
for start... make a game engine
All players are given a random way to die, and they must try and die that way before 5 minutes is up. The first player unable to complete their death task within 5 minutes loses. This game is designed for 2 players. Credit for this idea goes entirely to Dream on YouTube. Leave a review if you enjoy the plugin!
lol
oh another one of those..
for start... make a game engine
Not necessarily
no
Lmaoo
let me guess
i need more wealth
making it instance based is difficult?
Why need instances though? This sounds like it can be done in one class
No need to over-engineer it for no reason
if you dont it to be server instanced yeah
i just want it to work lol
if you want nice arenas and multiple games at once per server
yes it needs to be instanced
no
Or do you need multiple of these running on the same server on separate worlds?
its an actual plugin published on spigotmc that i wanna update
Oh, care to link it?
yeah thats why i dont want one instance
You shouldn't be
its poop
Yeah lmao
UHHH
Deathshuffle
1 sec
yes
so it wont work on multiple worlds at once
or a bungee network
It... will... just require more advanced knowledge
Since each instance will have it's own world, win conditions, stats etc.
best way is to start working on a gameengine
then you can create more minigames easly
Depends on how complicated you wanna make it. BUT I assume a random peep off the internet who wants to download a plugin like this will just want a quick plugin for one group that just works fine with one instance. Doubt any server owner wants anything like this multi-instanced.
cool ideea but true
im just bored of creating complex neural networks and wanna code something fun
You obsessed with game engines, darling
cause theyr usefull
made one and now i can create a fully working minigame in 20-25mins
stop creating a utils plugin
enough to handle the game state,the countdown,max/min players,overridable methods for start/stop its own mechanics,interfaced arena to always have a lobby...
Thousand libraries to do the smallest things
also checkers for canjoin,what happens when a player joins,what happens when a player leaves
things you need in every minigame
That's what happens when you don't define a limit?
no thats a good thing
its instance based
it creates an instance of Countdown for each game
So four players can start two separate games?
yes
But they'll be in the same world
no need
Because I assume you're not generating new worlds for each game, are you?
;D
Yeah, if you need inspiration for something else fun
You can explore the spigot resources "fun" category
Ye
also... good training ground i guess? https://bukkit.org/forums/plugin-requests.96/
Got an idea for a plugin? Post it here and someone might make it!
this is the idea:
For every player there is a pit, every player has a pit that they should drop mobs into, each NEW mob is 5 point, otherwise 1 point.
Game ends in 60 minutes, player with most points wins.
Dream game again
theyr not sorted by date
lol wha
it even got attention on reddit
Hello, why do i not receive the "Permissions: " send in the chat when the method called, but receive the send "list all permissions of user..." which is after running the method?
private void printPermissionList(ArrayList<String> permissions, CommandSender sender) {
sender.sendMessage("Permissions: \n");
for (String perm : permissions) {
sender.sendMessage(" - " + perm);
}
}
the permissions list is empty
Oh you don't receive the "Permissions:" either?
but the send which is before output of the list outputs only "Permission"
so how would i pull something like this off?
Are you sure that it runs and that there aren't errors?
yes, thats why i dont understand
Create areas for the pits (two XYZ points) and check if entity falls into it. Add points to the player that that pit is linked to.
have a cuboid set for each player,have a runnable checking every X seconds or w/e if there is a entity inside,checkin if its not player,remove entity,add point..
however thats a long ass minigame round
That can't be true
its fine dream stans will do it anyways
Bro
so how would i make the command that would create the pit?
By using spigot
dream stans have brain size of a peanut they wont figure out getting a server running @quaint mantle
^
i see nothing in the console and the code behind the method runs
You might be catching an exception and not printing the stack trace? Send full class code
i also saw like 10-15 clones of yours
wait really
Peanut brained dream stans have done it thousands of times
i dont use a try catch block in the class so that cant be
Give full class code, please
https://paste.md-5.net/
okey
dont be surprised i bet there are clones in like 4-5 hours
as they just use the current world for it no instances,nothing
good luck to read...
python will struggle with such complex logic..
also theres a reason python is pretty much a baby language beside the rest
no its not
it is
no
yes
no
Any language closer to the bytecode is faster
Python handles machine learning and ai well
than any programming language
lets use assembly :D
yessir
C or CPP
assembly on top
Who is running the command? Are you actually sure it reaches the case "info":?
Is it registered?
Show screenshot
make sure you have a break; in every case
are you sure your not passing a empty list?
If he was it would still show the "Permissions:"
if the list is empty, the send have also to be in the chat
okey
no
How can it be sender if the other thing is being sent to the sender fine
thats not even what you wanna do
the message before the method called also works with sender
you want to getplayerinexact by the name of args[2]
or offline player
and get permissions of that guy
yeah but still test
broadcast also dont work
so it doesnt even go in the printPermissionList
but how?
.
i dont understand
this is kinda odd
i receive the "list all permissions of user" but the method before was not run wtf?
ye
yes!
jup
whats left
i really dont know ๐ nothing
can i see the full switch