#help-development
1 messages · Page 360 of 1
nope
https://www.rapidtables.com/code/text/unicode-characters.html
Happy searching
Unicode character symbols table with escape sequences & HTML codes.
If you can join the server then you could simply take a look at the NBT data of those items btw.
Not my screenshot, but my friend have one server that has the feature, he's not responding atm
is anyone else having an issue where intellij takes all your RAM at random when you type something and then you need to kill it since its freezin?
been happening to me a lot lately
I've heard that it can be caused by the mc dev plugin. If it happens often try disabling or removing it and see if it helps
I haven't had that happen to me in quite a while so they probably fixed the issue
my intellij dies if i ctrl+z something with Material.SOMETHING in
its very painful
oh yeah same
and on copy/pastes
not all the time though
but often enough to annoy me
that happens sometimes
pisses me off so much
okay well atleast I am not alone in this then haha
can anyone help me with my code please?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!


i need to somehow delay a task in my class but i dont know how. i tried Thread.sleep() but that lagged the server or smt
yeah dont use thread.sleep
?scheduling
thread.sleep simply stops the server thread
You can schedule a method which is being run after N ticks at the start of a tick.
put it in a scheduler
public void doSomething(JavaPlugin yourPlugin, Player player) {
// Send the first message right now
player.sendMessage("> First message.");
// Schedule the 3rd message to be sent after 5 ticks (approx 100ms)
Bukkit.getScheduler().runTaskLater(yourPlugin, () -> {
player.sendMessage("> Third message.");
}, 5);
// Send the second message right now
player.sendMessage("> Second message.");
}
Bukkit.getScheduler().runTaskLater(pluinInstance, () -> {
player.getInventory().remove(customItems.activeDecapitator());
player.getInventory().addItem(customItems.entityDecapitator());
}, 20 * seconds);
`
doesnt that just repeat the task later
However you will have a lot of problems with your design.
What happens if a player drops items? Or he dies? Or he enchants the items?
i get that
it will only ever run when you call the method its in
For now just look at the examples above 👍
the pluginInstance is red
you need to supply a plugin instance
oh right ** i dont understand **
?di if its in another class, use this if its in your main class
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
what
...
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.
how do i do this
its right here
read the link the bot sent
best way to store large amount of data?
database
mysql probably
hard drive
yes but which one
whichever you prefer i guess
i want offline storing
if you want to suport the db being elsewhere, mysql, if not use sqlite
what's the best way to use sqlite
imo using hikari cp but other people will say just to use base java stuff
ok im gonna try hikari cp
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
gotta read or you wont do well making plugins
Does anyone know how bukkit/spigot loads plugins? DI?
PluginClassLoader iirc
5 ticks is 250ms
1 tick = 50ms
yes
is there a way to send a border around a specific region like a spawn ?
Spawn protection?
Ik how to do it with blocks but I would prefer to use a actual border
world border?
packets
that is per world not per player iirc
pardon i was in my project for a moment which is has 50 TPS
^
in base stuff
what
borders are per player now as well
How
fuck am i looking at lol
Class<?> jarClass;
try {
jarClass = Class.forName(description.getMain(), true, this);
}
Class<? extends JavaPlugin> pluginClass;
try {
pluginClass = jarClass.asSubclass(JavaPlugin.class);
}
plugin = pluginClass.newInstance();
they are?
jnak probably
spigot code in a nutshell
are ya talking to me or some1 else
does JavaPlugin have an abstract newInstance() method or am i going insane and is that part of object?
the code
ah
how
Makes sense
mm
wut
can u do that in multiple places?
no
world or each player
this is, weird someone else was saying about this yesterday
8 players online 0_0
37129 players online 0_0
Here is the weirdest bit... when i try to do a heap dump in spark...
it goes back to normal and doesnt record
whats casing it
i cant find anything about it being offline
normally with hikari you create the db where you want to save it
so it doesnt care if its online or not
not kikari, sqlite
What are we seeing here? 50-70 what exactly?
deditated wham
% ram usage im guessing
Of what?
how do I send imasges here
total ig
The system? The process? The jvm?
images?
verify
Not verified? Upload screenshots here: https://prnt.sc/
Could be as simple as: Panel uses ram to buffer saves, gc doesnt bother cleaning up until it needs to.
how do i think of plugin idea
??
so im trying to find the PluginClassLoader to check in my IDE and apparantly it doesnt exist where the stash says its located
on 1.8, packets
whats the correct path for this one
what packets
nms
couldnt tell you
ah that'd do it
org.bukkit.plugin.java.PluginClassLoader
Beware that it may be non-public
ah
ye class aint public
im trying to look at the decompiled code in my ide
any idea how
Use recaf
50-70% of 24gb of ram
raziel :susge
Oh god Crazy here to chastise 😉
wtf
yeah
I have no susge
im gonna need more context than that
"recaf java"
memes aside any ideas? Ive been wracking my brain about this all day. Playing catch up with some of the legacy descisions from old dev team lol
you ran spark or timings yet?
Of the system? The process? The container? Do you have any jvm arguments?
There are a million things that could be wrong here.
sounds like multicraft wonky. but I have no idea of it
Its legit the servers entire collective accessible ram is at 70% usage. After a spark heap dump
whats your jvm args
Im guessing that the gc kicks in and collects all the garbage
and what are your old gen gc's looking like
@geol heres what im trying to find: the newInstance() method used in this code snippet
Class<? extends JavaPlugin> pluginClass;
try {
pluginClass = jarClass.asSubclass(JavaPlugin.class);
} catch (ClassCastException ex) {
throw new InvalidPluginException("main class `" + description.getMain() + "' does not extend JavaPlugin", ex);
}
plugin = pluginClass.newInstance();
Reaosn i wanted to open the decompiled bytecode was so i could hit f4 on the newInstance method but since class aint public
Thats a method from Class<T>
ah i see kthx
can you please help me
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
i still dont know why my pluginInstance is red
?learnjaba
?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.
learnjaba
That too. Both are relevant.
F
does verification give external emotes
cant you just help me
no
sad
Nope. You need the decadence status aka server booster

can you send a screenshot of the code
learning java will help you
we arent just gonna give you all the code
you have to read as well
and yes, knowing java is surprisingly helpful in plugin development
....unless you use kotlin
but yk.
@livid dove ?
pluinInstance?
he just copy pasted an example someone gave
ah
without changing it or understanding it at all
fair enough
Here is the help (given you know the very basics of Java):
You need to get an instance of your JavaPlugin class to your other instances.
In Spigot you commonly refer to this instance in your onEnable method as this.
Then you either store it in a static variable which has a getter or you pass it in the
constructor of your other classes (also called dependency injection or di)
yall didnt explain it in the first place
we did
Will lyk in a bit quite literally tidying the flat rn
no, you chose to ignore it
cool, just wasn't sure if you seen it
.
nah ur good man ❤️
ye but no that a monkey would understand
if you dont understand it, you need to go learn java
didn't see anything about it in the recent chat, so I assumed he just came here lol
Prayge

ok, now as for why I'm actually here
get dabbed on crazy ;0
D:
bro i started today im happy with my work
so LivingEntity.addPotionEffect() (I always write PotationEffect jesus)
is it supposed to add the potion effect alongside existing ones or is it supposed to overwrite an existing effect of the same type
(in newer versions)
or if it is supposed to overwrite, is there any way to make it behave as potion effects do in game (assuming I'm not being bald and different levels of the same effect do coexist and replace one another once one runs out)
ok i got it to work thanks
i have 1 problem tho and that i can figure out
when i apply ItemMeta then no enchants apply
section of wiki that explains what I am referring to
Based on what the documentation says, it should add the potion effect to the player. Meaning that if you give them multiple potion effects with different amplification levels with differing times, it should work like the game normally does.
alright
I guess I'll make a small test thing, to see how it actually behaves in a void
pepecringe
Adding an attribute with NMS
any java dev?
no
ok yea in a void it behaves as expected. now time to figure out why it doesn't in this plugin lol
a bit of a nonsensical question
Too old! (Click the link to get the exact time)
stfu
public ShapedRecipe getRecipe() {
NamespacedKey key = new NamespacedKey(this.plugin, "Refined_Dagger");
ShapedRecipe recipe = new ShapedRecipe(key, getItem());
recipe.shape("MMM", "MSM", "MMM");
ItemStack metalShard = new MetalShard().getItem();
metalShard.setAmount(16);
recipe.setIngredient('M', new RecipeChoice.ExactChoice(metalShard));
recipe.setIngredient('S', new RecipeChoice.ExactChoice(new SmallDagger(this.plugin).getItem()));
return recipe;
}
The amount isn't working. I only need 1 item to craft the item. Any ideas?
Im getting Fortnite enjoyer, 1.8 pvp kiddy vibes
hi guys i am going to start a quest system project. I started making an uml diagram for this. But I couldn't decide anything about the class architecture
gotta click that mouse button real fast
just as bad
Which method do you think I should use for Action requirements? Abstract class or Interface
ingredients always have 1 as their amount. This is a limitation from minecrafts side.
Oh really? Damn
Do you know the packet name in nms?
PacketPlayOutWorldBorder?
lol no. I have not looked at 1.8 code for years. Who even has?
You might want to either group item and money requirement into something like StateRequirement or also
bring them under ActionReqirement with MoneyChanged and ItemChanged events
It really depends on how you check for requirement fulfillment
Why do I need the Money Changed and Item Change classes?
.
Which
This way you can standardise the ActionRequirement and use them for both money and item triggers.
Then you would need to differentiate between state and progression.
Example:
Requirement: Own 1000 Gold
-> Trigger OnMoneyChanged - Check total money (state check)
Requirement: Earn 1000 Gold
-> Trigger OnMoneyChanged - Check gained money (progression check)
Same goes for Items.
Scropy Id say interface
cause then you avoid implementation inheritance in this case
Agree. The state is pretty irrelevant as shown above.
But if you add more functionality and statefullnes to the ActionRequirement then go with the abstract class
Or if you are fancy:
Throw out your abstraction and go for composition
But the concept looks suitable for abstraction
Do you prefer to divide it into State Requirement and Action Requirement?
Well the state requirement would be pretty trivial
public interface StateRequirement extends Predicate<Player> {}
The Problem is when to trigger a check.
Yes, how can I solve this problem? I don't want to do it by clicking on the task menu
with the method you mentioned above?
I mean its fine to only check the state when the user looks at the task
and when the user wants to finish the task. But if task fulfilment is automatic
then you need triggers
I want the task to be fully automatic so should I still use the Action class Interface
Fk im trying to write an example but this is close to a full blown task system...
Where can I store a timer to re-generate a structure loot without lagging out the server, for example if there is 200 chests with timers waiting to be re-generated
actually the Money State Requirement doesn't make much sense because if she has that amount of money she can complete the quest as soon as she starts it
Store the refill time as data in the PersistentDataContainer and check when the next
player opens or breaks the chest. No need for any timers.
But I don't want the player to just keep re-opening the chest and getting more loot
I want the loot to be re-filled every 2 days for example
Thats what the timestamp is for
thats why u check if X amount of time has passed
Sure but you usually have more than one requirement for a task
Is it ok to create Earn Money Requirement class and implement it in Action interface?
what is the idea in your mind 😁
One more question, how can I protect randomly generated structures from being broken by players?
I was planning on using worldguard and creating a region for each structure, is this bad?
This one is a bit tricky. In 1.13 i did something like that and finding the constraints of the structures was one hustle through nms...
Maybe spigot has an api for that now but if not you need a bit of work for that
Na thats fine
Like the first time I create the world, as the structures spawn, it will create a region for each
But finding the border for the structures might be a problem
But they are like the minecraft structures, so don't they automatically have one
Using the structure block
Ah one more thing, how do I check if a chest is a structure chest and not just a normal chest?
They have custom nbt data iirc
Won't it lag, to check too many chests opening
Very probably not
Let's say estimated 500-700 players in the server, would it lag to check everytime a chest opens
No. Players can open thousands of chest each second if they want to
Okay thank you
Everything above 100 players lags in general unless you have special precautions
I'm just tryign to make it as optimised as possible
I have a huge server budget as well
@lost matrix In a moment, can you wrap up everything we talked about? I'm really confused
I don't want a big server to go to waste because of unoptimized plugins and datapacks
Yes?
Is there a problem??
Does a Task have multiple requirements or always just one?
Why?
Depending on that i can give a summary
Always just one
But why would I do that when datapacks does it easier?
Ok one moment then
My datapacks are very optimised
So you rather a server with over 100 players was unoptimised?
Why do you think datapacks are unoptimised 🤔
It's just generating dimensions, biomes, structures
I want to add a dependency to my plugin but it just gives me a classdefnotfound exception anytime I wanna use something from it
It's a one time thing
I think I missed a step but idk what
It does manage some custom achivements, items and other stuff
Ok so lets start with the simple stuff.
public record Task<E extends Event>(TaskRequirement<E> requirement, TaskReward reward) {}
Task always have two components:
- A requirement
- A reward
Tasks also only correspond to one type of event.
The reward can be very abstract: Its just an action applied to a Player. So we can define it as
public interface TaskReward extends Consumer<Player> {}
A concrete implementation could look like this:
@AllArgsConstructor
public class MoneyReward implements TaskReward {
private final double amount;
@Override
public void accept(Player player) {
MoneyManager.giveMoney(player, amount);
}
}
@sick ermine Makes sense so far? Or do you need clarification?
has both
I wrote the stuff so im just gonna keep rumbling... maybe he reads it later
lul
Is there a possibility that there is a task with a State requirement?
I will get to requirements if you understood the TaskReward. Its quite crucial that you
understand what interface TaskReward extends Consumer<Player> means.
TaskRequirements are checked every time their typed event is fired. Doesnt matter if it checks
the state or the progression of a requirement
public interface TaskRequirement<E extends Event> extends Predicate<Player>, Consumer<E> {
Class<E> getTriggerClass();
}
We store the task in a central manager called TaskManager
public class TaskManager {
private final Map<UUID, TaskContainer> playerTaskMap = new HashMap<>();
public <E extends Event> void addTask(UUID playerID, Task<E> task) {
playerTaskMap.computeIfAbsent(playerID, (key) -> new TaskContainer()).addTask(task);
}
public <E extends Event> void triggerEventFor(Player player, E event) {
playerTaskMap.computeIfAbsent(player.getUniqueId(), (key) -> new TaskContainer()).applyToTasks(player, event);
}
public <E extends PlayerEvent> void triggerEvent(E event) {
triggerEventFor(event.getPlayer(), event);
}
}
Here we can add a TaskContainer for each Player.
computeIfAbsent simply gets something from a map if it exists in there or creates a new object with the passed lambda.
Our Listener is therefor very simple. We just need to add all events we want to expose for triggering progression and propagate them
to the manager
@AllArgsConstructor
public class TaskListener implements Listener {
private final TaskManager taskManager;
@EventHandler
public void onBreak(BlockBreakEvent event) {
taskManager.triggerEventFor(event.getPlayer(), event);
}
// Add as many as you want for triggering
}
If you wanted to check the state of something every second then you simply create a SecondTickEvent and schedule it every 20 ticks.
Now to the complicated stuff. How do we achieve good performance with many tasks? We should not iterate through
all tasks a player has and check for their trigger class. We simply use a Map<Class, List<Task>> where each Task with
a trigger class is grouped inside a List
public class TaskContainer {
private final Map<Class<?>, List<Task<?>>> taskMap = new HashMap<>();
public <E extends Event> void addTask(Task<E> task) {
List<Task<?>> taskList = taskMap.computeIfAbsent(task.requirement().getTriggerClass(), (k) -> new ArrayList<>());
taskList.add(task);
}
public <E extends Event> void removeTask(Task<E> task) {
List<Task<?>> taskList = taskMap.computeIfAbsent(task.requirement().getTriggerClass(), (k) -> new ArrayList<>());
taskList.remove(task);
}
@SuppressWarnings("unchecked")
public <E extends Event> void applyToTasks(Player owner, E event) {
List<Task<?>> taskList = taskMap.computeIfAbsent(event.getClass(), (k) -> new ArrayList<>());
List<Task<?>> copyList = List.copyOf(taskList);
for(Task<?> task : copyList) {
TaskRequirement<E> requirement = ((Task<E>) task).requirement();
requirement.accept(event);
if(requirement.test(owner)) {
task.reward().accept(owner);
removeTask(task);
}
}
}
}
Guys, how long does the update url take to... update lol. It's been nearly an hour since I uploaded a new jar but the update string hasn't been updated =[
Yeah and thats basically a decent Task system which supports pretty much everything you could think of.
did you change version?
Well... Yes this code is not beginner friendly at all. But it is very modular 😄
OH SHIT you know what, I think I forgot to update the version string in the plugin yaml haha
I updated the string on the spigot website
classic
but not in the yaml
You know what. I think you should just go with your system and fight your way through it. Thats how you learn stuff.
that's what I've been doing for the past like 6 years and it has been working
Yes, I think that's the best way to find out. I'm sure I'll rewrite this plugin a few more times in the future.
Yes especially with quests and task systems you will fight forever.
Wait until you have to make everything serializable...
thats why we use '${project.version}' and resource filtering
or just be like me and keep it at 1.0 forever
Oh snap, could you elaborate on that a bit? I would love to have a single place to update version number
maven or gradle
I do have maven and am using a variable for version numbers there, but it doesn't apply to the plugin.yml
in pom you got something that has src/main/resources?
I do indeed =]
make sure thats enabled, then in plugin.yml change the version to '${project.version}' then it should inherit whatever version you set the version to
should be the version tag in pom
woah no kidding, it automatically does that? I had no idea 😮
I'm down with a little black magic =]

Hmm I must be losing my mind though, the update url is still not showing the correct version =[
drop the link
returns 1.3.1 for me
it does??! What in the world haha
spigot says 1.3.1 too
clear cookies
jank
firefox also shows 1.2.0 and I have never once booted this guy up haha
What in the world is going on
might be ip results caching
ohh like on the router level?
no idea how that would work
well, as long as it works for other people haha
How could I make this?
Nevermind did it 😂
that might help
Thank you though, I just needed a regional_compliancies.json file
ah
It's easier with a resource pack, you can just add a language text, and add another file to pop it up
Bro you have to have been trolling me lolol, even on my mobile connection so no caching its still returning 1.2.0
I see 1.3.1 on the actual spigot site, but the update url just returns 1.2.0
try adding a ? to the end of the url idk
we hope
well, I guess I gotta do ANOTHER version bump now with the proper URL hahaha
thanks winn 😉 not sure why that ? actually fixes it but it does
adding a query to the url typically causes the cache to be invalidated pretty sure
its a not-so-hacky-but-kinda-hacky workaround i do in some projects
Hey, i was wondering if it is also allowed to ask a mysql / pool size related question here 😛 can't seem to find any discord that is focused on this part
this must be some php stuff I am too dumb to know about haha
php is one area I have never messed with in the slightest
dont even need php to use url queries :p
can do it clientside (in browser) with like document.location.query or document.location.search , one of the two exist iirc
oh yeah I am aware of url queries, I just figured this particular case had to be related to php
but I am talkin nonsense of course haha
finally got resource filtering working lol, I was just missing a stupid tag >< my brain is fried from hours of doing backwards compatibility stuff lol I'm making stupid mistakes
I am tracking when a player equips armor, and if I pick up and place the item slowly, it registers as an event and I can track it, but if I do it as quick as I can it doesnt register and it doesnt trigger the event, yet the player is wearing the armor. Is there something I can do to fix this?
listen to the drag event too
why does block setType with applyPhysics set to false still cause block updates 💀
it doesn't
it's making concrete powder fall
You right you right the plugin jar just wasn't updating properly i guess
can someone help me figure out what im doing wrong?
im trying to register event but this happens to me
'PlayerFirstJoin(org.bukkit.event.player.PlayerJoinEvent)' in 'bettermobs.iawelcomemenuaddon.Events.OnPlayerJoinServer' cannot be applied to '()'
getServer().getPluginManager().registerEvent(new OnPlayerJoinServer(this).PlayerFirstJoin(),this);
public class OnPlayerJoinServer implements Listener {
Plugin plugin;
public OnPlayerJoinServer(Plugin plugin){
this.plugin = plugin;
}
@EventHandler
public boolean PlayerFirstJoin(PlayerJoinEvent event){
if (new GetPluginInfo(plugin).isPluginEnabled()){
return false;
}
if (!new IfFirstPlayed(event.getPlayer(), plugin).Check()){
return false;
}
event.getPlayer().openInventory(new WelcomeInventory(plugin).getInventory());
return true;
}
}
Should probably learn java first
to fix the issue you need an instance of the class not a boolean
getServer().getPluginManager().registerEvent(new OnPlayerJoinServer(this) ,this);
how would you find the milliseconds since the last tick within the main thread?
nah, one missing letter confused me
getServer().getPluginManager().registerEvents(new MenuClick(this), this);
notice s in events
You literally just showed me completely different code
ok lol
Tricky with Spigot. Paper has a ServerTickStartEvent which you can use for setting a timestamp.
Hi, i try to create a placeholder but i doesnt work and i dont get any error som1 know why ?
https://paste.md-5.net/efowifukup.java
Nvm i just find the error
[02:46:58] [Server thread/WARN]: [PlaceholderAPI] factions_member_1 is attempting to register placeholders via deprecated PlaceholderHook class. This class is no longer supported and will be removed in v2.13.0!
[02:46:58] [Server thread/WARN]: [PlaceholderAPI] factions_member_2 is attempting to register placeholders via deprecated PlaceholderHook class. This class is no longer supported and will be removed in v2.13.0!
[02:46:58] [Server thread/WARN]: [PlaceholderAPI] factions_member_3 is attempting to register placeholders via deprecated PlaceholderHook class. This class is no longer supported and will be removed in v2.13.0!
[02:46:58] [Server thread/WARN]: [PlaceholderAPI] factions_member_4 is attempting to register placeholders via deprecated PlaceholderHook class. This class is no longer supported and will be removed in v2.13.0!
[02:46:58] [Server thread/WARN]: [PlaceholderAPI] factions_member_5 is attempting to register placeholders via deprecated PlaceholderHook class. This class is no longer supported and will be removed in v2.13.0!```
som1 know how i can fix this ?
Dont use the outdated PlaceholderHook?
What is the new one ?
okk
thx
Not working, its detected but the placeholder doesnt work 
Som1 know how i can made it work ?
I want to display 5 member of the player faction (in different placeholder)
Erm can anyone think of any settings that could stop a plugin's titles ? All our plugin's titles are no longer working
maybe another plugin 🤷🏽♂️
binary search (remove half the plugins if the issue persists remove half of the plugins left and so on until you find the problem plugin) to find the issue! WOOO!
have fun
nope
We have made a test server
all the same configs
and plugins
no issue
clearly not or the issue would have persisted
something changed between your test world and production
if you zipped the productino server up and copied it to a test server and had no issues that'd just be wack asf
but if you just copied plugins and configs etc there still could be differences
.
imho you are best off asking in the papi discord
already post ahah
I dunno what to tell you. All the plugins were ported over.
And the problem persists across all worlds in the main server
why not backup your production server than use that with the method I mentioned
could be 🤷🏽♂️ no point in ruling it out before you test it
true ture
some weird shit can happen man
#general message
How would i make it more efficient and fill quicker
Ideas
If I have a command that's
/command <add> <message>
How can I make message ( Which is args[1] ) be a group of everything that goes after. Like what if message is This is a message
Is array methods good enough?
for (int i = 1; i < args.length; i++) {
message += args[i] + " ";
}
Technically, right?
hi
i have a sql database where i wanna store an item, but how should i store the item?
should i like serialize the name of the item and store that?
or is there like a unique int value or index or something like that i can store and use to retrieve the item whenever i want?
by item, i mean just the Material class for the item.
Best thing is to store the string for the materla name and then make the material back using Material#getMaterial(String) @quaint mantle
probably just iterate over the array of args i assume.
Yeah it's done
or maybe there could be a way to get the raw message somehow not sure.
Nah dw about it
ok
Did you see my message to you?
You could also convert the item into a json string. serialize it. store that string and then deserialize
But you can't store any datatype you want in a sql database.
yeah but i am also querying the material pretty often
seems kind of a waste of space to store all those names like that.
hm.
maybe i could compute a hash or something to make it an int and be more space efficient as well.
I mean could just store the stuff in a list and then update that every so often
Same thing as string, you won't notice the difference. Doing query from database isn't that resource intensive
also, is there a way to get all the material constants in an array list or something?
mostly just storage space efficiency.
ah okay. Appreciate the help!
Consider using PDC if you're doing a lot of stuff tho
PDC?
Depends
There's chunk pdc, item pdc, player pdc, chest pdc
But it's really good
And you can store entire objects if you want
i kind of wanna have it in a separate file of sorts that could be more convinient to work with.
If you need them editable then yes
makes it easier to move data across different servers and world folders even i guess.
plus, i am using sqlite, switching to a mysql database should probably not be too difficult.
plus i should be able to use the data over multiple servers, accessing it from one database server.
not sure if spigot persistent api can do that.
efficiently at least.
sounds like you want to use a database
also, i am also storing chunks in my database for something, how would i go about storing the dimension the chunk is in?
like the nether or the end?
make a new column
i know
how do i go about serializing the world the chunk is in to some kind of unique value of sorts?
is there a unique int value or index for the dimension the chunk is in?
to store the chunk's dimension in the database?
the world has a UID
is it unique for each dimension in each world folder?
not sure how the dimensiones are indexed. maybe there's a 0=nether, 1=overworld and so on
otherwise store it yourself like that
or just store NETHER, END, OVERWORLD
hm.
its unique for each world
you are thinking way too far. just store it as it is
Does anyone have a good resource for setting up storing player data in a yml. I understand how to create the file and everything but I'm having trouble figuring out how to set up configurations, saving and reading information to pass to a class
something like this maybe: https://www.spigotmc.org/threads/yaml-configuration-tutorial.444987/
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
👋
I'm currently making a tool as part of my Gradle plugin suite to automatically set up a test server. Right now I have it run BuildTools as normal (java -jar C:\path\to\BuildTools.jar --rev 1.xx.x) and it seems to work fine until it reaches this stage Applying patches to Spigot-Server...
It seems to freeze up/hang on ```
[BuildTools] Falling back to patching base and 3-way merge...
[BuildTools] Something did not apply cleanly to Spigot-Server.
[BuildTools] Please review above details and finish the apply then
[BuildTools] save the changes with rebuildPatches.sh
I can't tell if it's just taking a while or if it's actually stuck. It's been going for 28 minutes now...
i need help i am trying to make a plugin minecraft server using the server file
and i cant get it to work
skip arg 0 and args length -1
Count from 1 instead of 0
@regal scaffold
Fair, works the same tho
that code already counts from 1 no?
anyways is it still broken?
looks like it should work
Arg0 would be message
go to #help-server unless its about plugin development itself
you are more likely to get help when you are in the right chat
Hi guys, I need some help with a plugin, I am making a plugin to ban players if they die 10 times, would I do this with event listeners or in a different way.
Save the amount of deaths into a config
listen to death event, increment the death count of the player and then add them to the ban list if needed
Listener for deaths
and yeah persistently store them in a yml file or something should be sufficient
ok thanks soo much
I have been thinking about how i could optimize my cube block filler plugin
It sets 1 block every 10s
Maybe more tasks?
do anyone know how can i spawn falling block with nms on 1.19.3
public class PacketFallingBlock {
private FallingBlockEntity fallingBlock;
@Getter private Location loc;
@Getter private Material material;
public PacketFallingBlock(Location loc, Material material){
Level world = ((CraftWorld) loc.getWorld()).getHandle();
this.loc = loc;
this.material = material;
fallingBlock = FallingBlockEntity.fall(world, new BlockPos(loc.getX(), loc.getY(), loc.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState());
}
public void setVelocity(Vector velocity, Player player){
fallingBlock.setDeltaMovement(velocity.getX(), velocity.getY(), velocity.getZ());
ClientboundSetEntityMotionPacket packet = new ClientboundSetEntityMotionPacket(fallingBlock.getId(), fallingBlock.getDeltaMovement());
PacketUtils.sendPacket(player, packet);
}
public void show(Player p) {
Bukkit.broadcastMessage("asdawdaw");
ClientboundAddEntityPacket addPacket = new ClientboundAddEntityPacket(fallingBlock);
ClientboundSetEntityDataPacket dataPacket = new ClientboundSetEntityDataPacket(fallingBlock.getId(), fallingBlock.getEntityData().getNonDefaultValues());
PacketUtils.sendPacket(p, addPacket);
PacketUtils.sendPacket(p, dataPacket);
}
public void hide(Player p){
ClientboundRemoveEntitiesPacket packet = new ClientboundRemoveEntitiesPacket(fallingBlock.getId());
PacketUtils.sendPacket(p, packet);
}
}
this doesnt work
i just want to make it packet based
yes but it calculates velocity i think and i just wanted to make it with nms for performance
do falling blocks have a state? Thought they were treated more like entities 🤔
falling blocks are entities
no idea but it requires blockstate
but display a block state
ye
try sending the entitymetadata packet
it doesn't need to contain any metadata but try sending it anyways, generally works for spawning entities
Hey, I just want to add upgrades to my minigame.
I'm currently storing the upgrades as a string list in my team class with a getUpgrades() and addUpgrades() method and so on.
But I think there is something that works better than using strings e.g. with enums so I can use Upgrade.NAME . And then I would use a list of these enums.
Would this be the right way to do it or does anyone have a better idea to implement this?
i already did that
why does your upgrades have to have names?
is PacketUtils yours?
ye
problem might exist there as I don't really see anything wrong with what you posted
but that works for my nms armorstand
public class PacketUtils {
public static void sendPacket(Player p, Packet packet){
new BukkitRunnable(){
@Override
public void run() {
((CraftPlayer) p).getHandle().connection.send(packet);
}
}.runTask(CustomEnchants.getInstance());
}
}```
jeh like speedupgrade, healthupgrade... and so on
probably shouldn't have it static
but that doesn't answer why your upgrades in code must be named
its just a function, thats not the reason i believe
never know at this point
uhm something weird happened
did that, everything is working
rn it just spawned falling item but it was nms
how did that spawn an item for fallingblocks
yep
so there is a caveat with static
that you probably are not aware about
but still i cant see the falling block
if the value of the static changes, it changes the value for all objects of that static
in your case that caveat is kind of bad since you have multiple packets and don't really want all your static objects to just magically change to the same thing 😛
the NAME in Upgrade.NAME is just a placeholder for the name of the upgrade
just for short: what are you talking about? the only static thing i see is a method
check the wiki
with an anonymous inner class
is there a wiki for nms 🤔
not really
they are referring to http://wiki.vg
which contains pretty much all the packets that exist
hi
i accidentally messed up some stuff and ended up deleting all the files in trying to get back to a previous git commit.
how do i go back to a git commit i previously made and have it replace everything i currently have?
without dealing with merging and conflicts or whatever.
i have not really used git a whole lot to know what to do.
are you saving every file to git? like you dont ignore any?
in that case you can just remove it from your local pc and re clone it
or you can stash your changes, and switch to the right commit
lol i am just cloning the repository at this point.
contains 3 different scenarios of reverting
last one I think is what you are wanting
yep, it was the last one, got it.
i was just undoing and redoing stuff in the IDE and it just deleted stuff to the point where i was too lazy to write all that code again.
i was literally just holding down ctrl + y or ctrl + z and it just deleted lines of code.
weird.
anyway, i am going back to working on my project right now.
have fun 🙂
i made some junk commits while i was trying to revert changes.
and now github is ahead of my current local commits.
lol this is a pain.
how do i delete github commits?
i wonder how they do it in real jobs where they do CI/CD or devOps or whatever it is called.
actually
on the topic of that though
does anyone know any good resources to learn CI/CD?
it looks kind of complicated.
at least right now, to me though.
you might have to revert to using console
to push your changes
you have to use the --force
flag
basically that says, push my changes I don't care what you have
that worked!
thanks!
i am gonna take a break i guess
been working on this for too long.
CI is just a concept. Just means continuous integration. How that works is you essentially have a server that just continuously builds based on what ever criteria you set
the most common is setting it to build based on commit changes
Jenkins is a really easy CI server to setup
and does this if you want it to, or you can configure however you like it
Jenkins is built using Java but it doesn't have to be used for Java only projects
oh ok
As long as you configure all the appropriate tools for jenkins to access it can build other languages
i will probably try to learn that sometime soon.
appreciate the knowledge! This server teaches me so much.
CI/CD and devops are indeed workflows that are meant to ensure quick releases and stable builds. It very much relies on writing lots of unit tests which would be used during the build of a commit
Jenkins is one such tool, but github actions can do most of it too (and is completely free for open source projects. Otherwise you have 2000 build minutes per month)
how would you test a minecraft plugin though?
Well, unit testing isn't inherent to the concept, but it does help especially in places where you wouldn't want a build to continue or just early notification of potential problems
i have seen libraries like cypress for testing stuff for web stuff.
Try to seperate logic in multiple methods, so that your business logic does not or makes use as little as possible of the bukkit api, you can also mock the bukkit api
but never done any testing myself with those libraries.
unit testing plugins are easy as long as what you are testing doesn't require the plugin to be running, otherwise you have to create mock stuff for objects like player for example
but like you can test logic of stuff
maybe you are manipulating an array to sort it
you could have a test to ensure the final sorting is what you are wanting
that doesn't require the server or plugin to be running because that doesn't make use of server specific objects
I'm still kind of disappointed that there isn't an e2e testing library for bukkit. Not that I am smart enough to make one
how do you test a testing library?
same way but a bit more complex lmao
there had to have been testing library that wasn't tested.
You don't. Unit tests should never test libraries, only your own code
that was used to test other testing libraries perhaps?
You look for tests that the testing library has I guess. They will have a workflow to test the test in order to test
well you should have unit tests for libraries you create, but yes you just assume the lib is correct and you are wrong 😛
Wait what?! I don't test my libraries !?!??!!
what are you talking about
that is probably what most people do.
Then how do you ensure the lib itself doesn't contain a bug, or actually does what you expect it to
all methods are testable given you know how to construct the test for it
doesn't matter if the method or logic comes from your application or a library
testing all edge cases and identifying them is probably not very easy.
not always, but you just add to your testing as you go along
a billion dollar game like minecraft has so many bugs more often than not in their major releases.
so, like not everything needs to be tested for example
or maybe mojang developers are bad.
This might be interesting. It's the tests I have in my plugin This might be interesting,
probably the latter.
Nah, there is a point when even though tests catch 90% of errors the 10% is still a lot
they have the resources to fix the bugs
but grouping it all into releases and all takes time
A popular development method is TDD (Test driven development). Write tests, then write code
hm
Requires you to think things through before writing code
that sounds difficult.
and would probably take so much time.
does anyone have real world jobs and do this stuff irl?
i did not understand half of it.
or more than half of it.
For a spigot plugin it's probably not worth doing, but in important applications...
My company doesn't do automated tests 😢
i wonder what mojang does to test their stuff.
probably a metric ton of unit tests
maybe some integration tests. Unlikely they have end to end tests
Making software that can be used by millions and is accessible and does not crash and does not have bugs and is fun to play is very hard indeed
I never do any unit testing in regards to java
mainly because it is faster to test yourself then it is to come up with the tests to begin with lol
the tests don't write themselves you know, so not only do you have to come up with the test but you have to implement it properly
then there are the modders
not sure if bukkit could have e2e
yeah, i dont think i am doing all of that myself anytime soon probably.
Unit tests are for when you can easily have expected input -> expected output
given that you are making plugins which is like mini-applications for a larger application
but bukkit has tests though when you compile it that are ran unless you disable the testing stuff
doesn't test a whole lot but it tests a few things lol
hm
I would envision a bukkit server that is stripped down and a headless client that's able to follow instructions (kinda like mineflayer). Then assertions can be done
For plugin test flows at least
probably, but at that point might as well have someone do it lol. But spigot/bukkit is the modification of another application as well so I mean probably would be really hard to setup some kind of test that isn't overly complex to do such things lol
I know it isn't worth my effort and probably the reason no one has bothered to come up with such things
Well the point is that you can infinitely repeat them
but yeah
well that is the part that is hard though
when you have an implementation the underlying system always changing
and its not even in your control for those changes either
you'd have to freeze versions, but with the sheer amount of versions currently around that would be difficult
I use mock bukkit it is pretty nice to test open ans close quick errors with tbh wouldn't use it for.
is there anyway i can fix the auto closing menu when resoucepack is loading on join?
public class PlayerResourcepackLoad implements Listener {
Plugin plugin;
public PlayerResourcepackLoad(Plugin plugin){
this.plugin = plugin;
}
@EventHandler
public void onPlayerResourcepackLoadEvent(PlayerResourcePackStatusEvent event) {
if (new GetPluginInfo(plugin).isPluginEnabled() && new IfFirstPlayed(event.getPlayer(), plugin).Check() && event.getStatus().equals(PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED)) {
Inventory inventory = new WelcomeInventory(plugin).getInventory();
event.getPlayer().openInventory(inventory);
event.getPlayer().sendMessage("Opening Welcome Menu...");
}
}
}
you shouldnt be making a new instance of your plugin , and you can use player.hasPlayedBefore() and == for enums
Hi, i made the plugin add an effect but the effects don't combine, there's a way? this is the code i used
p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * Config.XANAX_COOLDOWN.getInt(), Config.XANAX_AMPLIFIER.getInt()));
there is no new plugin instance and i'm using player.hasPlayedBefore but its in IfFirst player with checking if it will happen only when player first joined or olways on join via checking config
whats GetPluginInfo then
if those classes are just 1 method put them in a utils class
i mean why is there a class called "IfFirstPlayed"
and make it static
I want to apply V velocity to an entity whilst keeping it's movement (such as players), however I don't really want it to stack again, I am doing something like
// In a scheduler
Entity entity = ...;
Vector toAdd = ...;
entity.setVelocity(entity.getVelocity().add(toAdd));
I know this accumulates, don't know how to not make it accumulate
fixed that but still i have an issue when resourcepack is loaded it still closes inventory even if i open inventory when resourcepack is loaded
does anybody know if MongoDatabase#getCollection is nullable? there are no annotations on the method and the docs don't help
found the solution at https://www.mongodb.com/docs/manual/reference/method/db.getCollection/
Behavior
The db.getCollection() object can access any collection methods.
The collection specified may or may not exist on the server. If the collection does not exist, MongoDB creates it implicitly as part of write operations like db.collection.insertOne().
you want to make it like
apply the biggest velocity between playerVel and toAdd?
Inventory closing when it opens on resourcepack succesfull_loading
I want to play a sound when player join
I tried to do it but it did not work
I registered Events
try to delay it by 1-2 ticks
also a good rule of thumb is to ged rid of 1-letter variables as much as possible
at least do ev, pl
how to do it?
ev is even more vague then e imo
in that case go for event
and player if you are afraid of confusing it with plugin
one-letter variables are super ambigious
the only potentially appropriate use of them i can think of is for-loops
and maybe exceptions
One letter variables can be fine
The name of a variable should be proportional to the scope its contained within
That means, the smaller the scope, the shorter the name has to be, the bigger the scope, the longer the name has to be. At least this is the convention.
And then for functions, the same rule applies but inversely
so make a really long name to show that it has the largest scope 😄
Usually public static variables
Yea you have a lot of exceptions (System.out being the first one coming to my mind)
But its a convention, and a good one
Java does not go over it because its not official, but it has been adapted in the industry
yes it does
Variable names should be short yet meaningful. The choice of a variable name should be mnemonic- that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.
That’s not the same
it still mentions single character variables lol
The proportionality rule adds more restrictions
Yes but it defines some convention for them that is a bit more vague
@lost matrix Should I create the Updater class and its subclasses to increase the correct value when the event trigger is fired?
So for an entityDamageByEntityEvent I'm trying to get the entity's current location using the following line of code
Vector v = event.getEntity().getLocation().toVector();
however for soem reason when testing this it always outputs 0,0,0 irrespective of where the entity is
anybody know what might be wrong there?
That’s not supposed to be the intended behavior
Do you have more code to display for us?
Vector v1 = p.getLocation().toVector();
Vector v2 = e.getEntity().getLocation().toVector();
Vector destination = v2.subtract(v2.subtract(v1).normalize());
i mean i dont know how much this helps with it but yeah
the player location works fine just the event entity doesnt
Is there a way I can stop the primary world from saving chunks/entities, I know you can unload a world at onDisable, but that doesn't seem to work for the primary world.
I don’t know exactly but iirc
vectors are mutable
So you might want to clone before invoking any operations on them
Ye
whats the best plugin to make nick name and tablist changes too with it?
essentials x and TAB
for pvp server that will be bad imo..
how?
if you dont want to use essentials make ur own and register papi placeholders and add that to tab
any other ideas?
Not exactly, toAdd is the velocity I want to add, but I also want to keep the player's velocity, like sort of water pushing
placeholderapi make these things?
you can register a placeholder with it in your pluign
then use it anywhere
you just have to respond to the call and ur done
ima give it a try
Try dividing your toAdd by 20
That way it's small enough to fall off before re-adding it
Alright
@remote swallow ig protocol lib is better or am i wrong?
ProtocolLib is just a packet interception library
It lets you listen and send packets
and i need to send packets to change the player head and tablist name
PlaceholderAPI is a text parser that links a %placeholder% to a Supplier<String> that routes through the expansions
like a nickname system
or a function or something
setDisplayName??
that doesn't change the name above player's head
i didn't catch that, placeholder for holograms and etc or am i wrong?
TAB does that
and gives you customizable tab
TAB what?
i tried to make scoreboard packets to change the prefix, suffix for players
but i cannot change player's names
rare moment but I wrote documentation
its going on github?!?!?!
i can
illusion do u by chance have xp with geometry in graphics?

no, I failed trig
im taking over
I can do basic particle effects and all
but that's about it
bezier curves confuse the fuck out of me
ye thing is im not that good either
ask chatgpt lol
I can render a star and all
that's about it
guy I hired probably knows, he does vfx for marvel
👀
@EventHandler
public void onClick(PlayerInteractEvent event) {
System.out.println(event.getAction());
}```
Why is this code not receiving the RIGHT_CLICK_AIR event?
Also note, that RIGHT_CLICK_BLOCK is always logged twice for some reason
in order:
- Client doesnt send empty hand air clicks
- It is once per hand: left and right
no the right click air part
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
Why is right click block sent once per hand?
it runs once for each hand
drugs
ah
if(event.getHand()== EquipmentSlot.OFF_HAND) return;
none yet, dnas being sent at the end of the month
okay so what about the first part
oh god not you again
how can i register right click air
You could give people invis items
ye that
nda
do you mean nda
fuck
alright thanks
Yes you can’t break our unrequited love 🥰
mans literally DMd every single developer I've remotely worked with
i feel way out of my league here
no
yes
