#help-development
1 messages ยท Page 477 of 1
the one thing is always a semi colon
in my case it's a .exceptionally
should
you'll need to change some stuff around
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
will be useful
Entity tnt = target.getWorld().spawnEntity(target.getLocation(), EntityType.PRIMED_TNT);
im bieng dumb
If you only have an entity type, then just cast
yea
TNTPrimed tnt = (TNTPrimed) world.spawnEntity(location, EntityType.PRIMED_TNT);
done with work for the night, world templates save and load now
got some school work to do, would be cool if I could go to bed before 5am 
That's part of the plugin.yml
what is your plugin doing
making a copy of that world, saving it to a database under a name
and then loading that world copy and pasting it on a "grid"
Add the api version into your plugin.yml
are you using world edit as a base
oh ok
It's just a matter of writing one of these
oh
My idea is to make future plugin development easier
if I want to make an arenas plugin I can just use this as a base
and do something like
They're lambdas
Basically code blocks that can be executed at any time
Here's an example:
public void doSomethingThen(Runnable runnable) {
doSomething();
runnable.run();
}
and you can call it like
doSomethingThen(() -> /* run code here */);
and that code block that you pass as a parameter
will be called after doSomething()
Yeah pretty much
and that code segment will be executed whenever the method I'm calling decides
In this case I'm using CompletableFutures, which are basically a chain of actions that will happen
They let you do stuff like
CompletableFuture<Void> operation = runAsync(() -> {
// run this code async
someExpensiveDatabaseOperation();
});
operation.thenRun(() -> {
// something else (same thread as the operation above)
...
});
You can pass such futures as parameters, or return futures so other methods can then hook into your action
here's a technical explanation
But here's a more realistic approach
public interface StorageDatabase {
CompletableFuture<StoredData> fetchPlayerData(UUID playerId);
CompletableFuture<Void> storePlayerData(UUID playerId, StoredData data);
CompletableFuture<Void> deletePlayerData(UUID playerId);
}
public class MySQLDatabase implements StorageDatabase {
@Override
public CompletableFuture<StoredData> fetchPlayerData(UUID playerId) {
return CompletableFuture.supplyAsync(() -> {
// SELECT WHATEVER FROM SOME TABLE WHERE PLAYER ID = playerId
return object;
});
}
...
}
public class FlatFileDatabase implements StorageDatabase {
private final File userFolder = ...;
@Override
public CompletableFuture<StoredData> fetchPlayerData(UUID playerId) {
return CompletableFuture.supplyAsync(() -> {
// get file from folder, read file, get object
return object;
});
}
...
}
And then to use it
StorageDatabase database = plugin.getStorageDatabase(); // whatever
database.fetchPlayerData(playerId).thenAccept(data -> {
player.sendMessage("Your data is here!");
// do something with the data
});
And this way you guarantee that your data is being fetched async, yet still associate a code block to run when the data is available
And we use an interface to standardize our storage operations, so that the process of data serialization is handled by our implementation, and not by the rest of the codebase
Using YamlConfiguration how do you get a list of all the items found in a config file?
'1':
Name: Test 1
'2':
Name: Test 2```
For example, return a list of `1, 2` from the `items` category.
for (Strng key : YamlConfiguration.getConfigurationSection("items")) {
// do stuff
}
.getKeys(false)
oh ture
i forgot abou that
would there be a better way to store a list in a sql database than making it a single string
create 1 row for each element
or make a list identifier and then a ton of rows
like
let's say you have a Map<UUID, List<String>> permissionMap
then you have a table
UUID VARCHAR(36) PRIMARY KEY UNIQUE | permission
and just a bunch of
<uuid> | permission1
<uuid> | permission2
only problem is there is no set limit to how many entries could be in said list and i think that it may very large after like 2 weeks
How do I make the playsound work only for ambient
To create multi-line holograms
With display entities
Is the approach still use a offset?
And have a display entity per line in hologram group?
p much
Alright
hey so I am looking forward to creating a couple of custom mobs and I have been able to find examples of such on various forum posts but I cannot figure out how to make these mobs spawn randomly around the world, like for example, skeletons or zombies which would automatically spawn all around your minecraft world
The most logical approach is to just look at how nms spawns mobs
it is more about math ig
if there is an event when mobs spawn then you can cancel thia event and spawn your own mobs, but I am not sure if this thing exist
yeah I want like
very natural spawning of the mobs
and be able to configure the spawn chances of certain ones
how do I execute command as nLogin countdown instead of sending it to actionbar?
I wanna make it bossbar
this might be like getting a few chunks around a player and count mobs in them and if it is not enough then you spawn more
didnt you just ask that
hmm
and no one gave an answer ;-;
the whole idea is kinda like, there are "doge"(s) which can very rarely spawn in your world (they are just renamed wolves) and if you right click them x and y happens
patience is a virtue
ok
tbh I don't understand what you need, could you please tell more?
like
instead of sending a message to actionbar for login countdown
I want it to send some command instead
the nLogin
if I logged in
it will show the timer in actionbar
is it possible to change it to execute some commands
instead of sending message to actionbar?
so you want to edit a plugin
to make it execute commands instead of sending a timer in the actionbar you would first have to have the source code of the plugin
then go in the class where its happening and change the behaviour of the timer system
how do I remove pom.xml from my plugin when compile?
You don't? It's not included in the final jar.
You could probably add an exclusion filter to the shade plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/maven/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
ok
I just spent an hour tracking down and dealing with timestamps and getting incorrect values all because I forgot to use the right config path. ๐
gamer moment
gamer moment
where does the timer system code located in in openlogin folder?
I'm saving data for groups within a yml file. Any feedback on the formatting before I move on?yaml groups: 6ae3444c-6921-42fd-baee-5a718fc2487d: // the group's unique ID Name: Test Group Acronym: TG Description: Test Description. Members: 069a79f4-44e9-4726-a5be-fca90e38aaf5: LEADER 4a3f6ed4-153d-424a-858d-5fdd2e78fc54: MEMBER Settings: - OPEN - NPC_LOOT_SHARE Members Permissions: - TELEPORT_TO_STRUCTURES Officers Permissions: - KICK_MEMBER
Roles are enums, right?
Then you probably have aMap<Role, Set<GroupPermission>>.
The permission structure should be naturally structured like this then:
Permissions:
MEMEBER:
- KICK_MEMBER
OFFICER:
- TELEPORT_TO_STRUCTURES
would it be reliable to divide an int by 10 or 100 to keep track of something being true/false relating to that number
try to think of ways i can make my life somewhat easier in the future
public void doSomething(int ticks) {
if(ticks % 10 == 0) {
// Do something
}
}
I guess this is what you want?
Exevutes every 10th tick
not really, im bored so im making suggestion plugin and i have to keep track of what suggestions a player has interacted so to say with and if they upvote or downvote it, and this is most likely gonna be stored sql so i pretty much have to keep track of a map<int,bool> in sql without knowing how big said map could get so cant do infinite collumns
Your feedback is highly appreciated. I have now updated it to your suggestion ๐
groups:
0742798b-d4c8-4122-bb69-73df9f708449:
Name: Test Group
Acronym: TG
Description: Test Description.
Members:
069a79f4-44e9-4726-a5be-fca90e38aaf5: LEADER
4a3f6ed4-153d-424a-858d-5fdd2e78fc54: MEMBER
Settings:
- OPEN
- NPC_LOOT_SHARE
Permissions:
MEMBER:
- TELEPORT_TO_STRUCTURES
OFFICER:
- KICK_MEMBER```
Ok so... the int is the ID of the suggestion and the map belongs to a player, is that right?
Then create a table
| UUID | SuggestionID | Boolean |

With a natural primary key or a composite key of the first two columns
| Generated | UUID | SuggestionID | Boolean |
i feel really dumb
Nah thats not an easy decision. There are multiple ways of handling this with relations.
The main problem here is finding out a diff when saving the data again.
i think the thought came from when i didnt realise i had to save what they chose too so was going to store an int list as 1 string, thanks for the help lol
been as this would stand the chance to have new data quite often would it be better to be saving it on shutdown + every hour instead of every datachange
Yeah dont save it on every data change
save it on every letter of the data change 
much lag
just dont have any persistence at all
what part of redis do i use to communicate between servers? is it the subscribe thingy
should* not do
is there a way to make a config file which the user is not allowed the edit?
(basically need a config file which the plugin can grab data from but I really do not want the user to be able to edit it)
topics
how would i do that with jedis
file locks most likely
Kepp it in your resources and load it from inside the jar
how would I do that?
JavaPlugin#getResource
returns an input stream, convert to input stream reader and you can YamlConfiguration.load it
I zee
Step 1) Change to Redisson
Step 2)
RTopic topic = redisson.getTopic("myTopic");
int listenerId = topic.addListener(SomeObject.class, new MessageListener<SomeObject>() {
@Override
public void onMessage(String channel, SomeObject message) {
//...
}
});
// in other thread or JVM
RTopic topic = redisson.getTopic("myTopic");
long clientsReceivedMessage = topic.publish(new SomeObject());
my solution to the item issue I mentioned is to just create a completely different file for items which are fundamental to the plugin and then grab those from there
or actually yk what I think I might just remove the ability for people to have an items.yml at all and just make it easier on me
what benefits does Redisson provide over Jedis?
Pros: Better in every way and simpler to use
Cons: Bigger
ok so how do i connect using password and host+port
figured it out all good
also what is the "SomeObject.class" meant to be
You can send objects through redisson.
You can just use String.class if you want to send a simple String
ohh
if we have primitive and non primitve for a lot of stuff in java why dont we have a primitive string
primitives are one word at max
but string is 1 word
one word from the architecture
So on most systems one word is 64 bit. And the jvm word size is always 64 bits.
"In computing, a word is the natural unit of data used by a particular processor design"
ahh
this makes reinterpret casts really fast
Wrapper are garbage in the first place.
Thats why valhalla needs to happen
valhalla 
why do i hear immigrant song

true, some processors do support other word sizes like 32-bit, 128-bit etc
but 64 but is by far the most common nowadays
btw
the word size directly impacts the maximum memory address space a program can access
a 64-bit jvm can access up to 264 bytes of memory
@misty current what you need to remember is
references are 64-bit
long and double primitives are 64 bit
objects headers contain 64-bit values
if the jvm word sizes changes
the jvm implementation and all compiled bytecodes would need to change to accommodate that
so the word size is static for a given JVM or CPU architecture
i wasnt the one who asked the question, but i appreciate the clarification anyways
oh, who was the person
that'd be me
oh than
*Specifically for the jvm yes
thats what i said
Ah ok, wasnt clear to me
Generally MMUs can use multiple words to map into a much bigger physical memory iirc
But that was like 1st semester so cloudy on that front
yeah
for example
a typical modern system may have 4TB to exabytes of physical memory
but map that into a 64 bit user address space
the MMU performs address translation between the virtual addresses
used by programs and the physical addressed mapped to RAM chips
btw
MMU can expand the addressable memory space beyond the natural limits of the word size
so for example
a 64-bit CPU with 4-level page tables can support up to 256 petabytes
thats 252 bytes
of mapped memory using 4KB page sizes
like
does spigot (or any forks) have an API for nms.Brain?
@lost matrix imagine some systems uses larger pages like 2MB, 1GB... to support even bigger virtual memory spaces
into the exatbyte and zetabyte ranges
hey i need help
package me.auxillated.fun;
import org.bukkit.plugin.java.JavaPlugin;
public final class Fun extends JavaPlugin {
public static void main(String[] args) {
onEnable();
}
@Override
public void onEnable() {
PrintStartup("The plugin has started up!");
}
public String PrintStartup(String Message) {
System.out.println("The plugin has started up!");
return Message;
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
Why is IntelliJ saying "Non-static method 'onEnable()' cannot be referenced from a static context" on line 8
You don't need the main method. Remove it.
No I need it
No, you don't
You never need to add it with Plugin Dev
Ok let me try that
people these days
?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.
I aint reading all that
If you don't know how to do the basics like create a list. We won't be helping. You need to know basic java before making a plugin
I know Java please help me
@hushed thunder that was very ๐ ๐ฎ ๐ฎ of you
If you know java, then you should now how to declare a new list
๐คช
@jagged monolith is right
Wait i know
it's this right
Creating a list, is very low level basic stuff
idk you tell us
Nope, that wouldn't work. Plus, StringList is not really used. There's better ways to making a list.
nooo you're not supposed to tell him
congratulations, you can come back when you have an actual issue which is not spoonfeed related
5sec later
Nevermind chatgpt told me
god save you
It's List<String> stringList = new ArrayList<String>();
im atheist but I pray to god every day for programmers who rely solely on chatGPT
it makes a lot of sense considering the fact that we refuse to spoonfeed but it doesnt
now please, you can come back any time that you have a different issue but for other stuff use #general
Also, relying on ChatGPT to make a plugin = disaster waiting to happen.
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class FireworkPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Register the event listener
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
// Create a firework entity at the player's location
Firework firework = (Firework) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.FIREWORK);
// Create a random firework effect
FireworkEffect.Type[] types = FireworkEffect.Type.values();
FireworkEffect.Type type = types[new Random().nextInt(types.length)];
FireworkEffect effect = FireworkEffect.builder()
.withColor(Color.RED)
.withFade(Color.YELLOW)
.with(type)
.trail(true)
.build();
// Set the firework's metadata to the random effect
FireworkMeta meta = firework.getFireworkMeta();
meta.addEffect(effect);
meta.setPower(1);
firework.setFireworkMeta(meta);
}
}```
Will that work
ChatGPT told me
I wanted to make firework plugin
I know what public void means
bro
It means when the firework explodes it gets sent to the void
Right?
why?
๐
Why can't you just lean java just a normal person and not rely on ai
๐
rolling your eyes is not going to force us into spoonfeeding you
AI is the future of everything
it CAN however make the mods mute you if you refuse to follow the rules enough
*WILL
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.
Ok fine anything to mute players
My friend keeps spamming the n word I want to mute him
have you considered not being friends anymore?
I know
I am going to learn it
Why Gif not work
because you are not verified
How verify
@ancient plank sorry for the ping but could I get some "assistance"
Whatever I'll go learn Java
good for you
this guy is even worse than the ones who came before
he really really wants to be spoonfed
didnt read
?img
Not verified? Upload screenshots here: https://prnt.sc/
Yeah, not quite what i wanted
Does spigot have mappings for methods and stuff?
Thats all the mappings we have
!verify
Usage: !verify <forums username>
This one
ive been trying to make a custom item plugin, that when used, gives potion effects
ive been looking for how to do it but what i got doesnt work, how can i make it work?
"Dont ask to ask just ask."
im entirely new to this
You should always identify custom items by a tag, set inside the PersistentDataContainer of the ItemStack.
Then its just a matter of checking interaction by using the PlayerInteractEvent and applying an effect to them.
All of this should be separated into multiple methods.
?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.
alr ty
thats kind of what i have, its probably just a smiple misplaced } i just cant find
clearly a chatGPT incoming
Why not send your code
it contains a drug name and im not too sure if thats allowed
thats.... true (im dumb)
Wait, since when does anybody care about a written drug word?
Since people became afraid of words.
^
Nice. But implementing the crafting logic is the actual hard part
should i just send it then?
?paste it if you would
Out of all the drugs, why this? XD
you gotta create a fake crafting table tile entity
Breaking bad i suppose
to trigger the craft events so you can have full plugin compat
Not really breaking bad, just fun with friends
Eh, the only thing it can't really do well is recipes that require items with an amount greater than 1. It handles everything else pretty well.
How about you add cocaine that makes you run faster instead of meth that just fks you up for no reason.
PrepareItemCraftEvent
copying hypixel anyone? lol
Giving speed effect is just an example, i have various kinds planned such as one that launches yo up, and one that gives every effect
hypixel has that for its skyblock gamemode
Can't say I've had this problem. If I had the item, the recipe book would act accordingly, even with custom items.
exact design
is there a way to give a Sheep the noAI tag
it was only joke bro why you have to be mad ;-;
Alright the code looks ok at first glance. Can you describe what you expect
to happen and what is actually happening?
Also check the console for errors when starting and while interacting.
isnt it like, ultra painful to program all the recipes into it tho?
just craft an item, right click it and gain the effects after a few seconds
Entity#setAI()
Write a translater from vanilla recipes to yours
Alright and what is happening?
What ends up happening is that the item isnt craftable at all after i added the onPlayerInteract
i was looking on the spigot summary and it wassnt on there
either that or it wont let me get the .jar file from intellj
nvm it was in inherited section
What does that even mean?
It wont let me build the plugin
Then send the build log
Your IDE should tell you exactly whats wrong
cant right now, but i will when i can
Where do they say it's intentional? That bug isn't marked as Won't Fix.
i tried doing what it said, and when i implemented the plugin the item wasnt craftable
How would you know if the plugin doesnt even compile?

when i added this it let me compile it, as well as a few missing }
how do i make it so that my commands have the values you need to input auto input?
do you mean that they just have default values if someone doesnt enter args?
like
yes
well you can either use acf and bang your head against the wall or make use of โจ if statements โจ and set arg values if none is entered
Just write your own crafting logic then
yea i thinkl
it took 2252 lines of code to make MineMemer (in its current state)
good for you
ok fine
its basically DankMemer but in mc (and with more stuff because mc has less limitations than discord in that matter)
Probably a redundant question, but if I already have per player configuration files, wouldn't it be smarter to put cooldown information inside of their file instead of a separate file that would keep track of everyone's cooldowns?
Already do, but I'm talking about persistent cooldowns. That data has to be stored somewhere.
Hmm, guess I'll redo my implementation then. :p
I am thinking of having something like that for MineMemer just so we could have some textures for the custom items but it will require ever user to download the resource pack seperately and all
*and ofc add a config option to disable that
what are you trying to do
?doesntwork
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Hello, what is the instant heal potion ItemStack ?
PotionMeta
okay thanks
All potions are Material.POTION
I want a specific potion
Yep
hello, when I want to drop the plugin on the server there is an error message that appears can you help ?
13:12:13] [Server thread/ERROR]: Could not load 'plugins/Questplugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:170) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.loadPlugins(CraftServer.java:422) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3736-Spigot-e4265cc-10f8667]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:219) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3736-Spigot-e4265cc-10f8667]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:975) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3736-Spigot-e4265cc-10f8667]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3736-Spigot-e4265cc-10f8667]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more```
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
Idk gradle, but I'd check your compiler settings.
Make sure you are actually building with gradle
everyone using IntelliJ should have the MinecraftPlugin extension can we just make a PSA of that or something?
when i create project i said this but i dont know how change the gradle
Idk, there's a lot of people here who advise against it for whatever reason.
Only if you have oodles of memory.
only use plugins to save time when you already know how to do it all yourself.
Just wanted to share this bc i thought it looked satisfying ๐
Workdistro?
Yeah it uses the concepts of it ^^
Ive created a compressed schematic format. Thats why the different block types
are pasted in succession
I was wondering about that. It looks pretty cool though.
Have you considered looking at the litematica format? I think it can do subregions and that would be a really cool feature to have.
No i havent looked into that... I should give it a read.
But i need the format to copy quite a few extra things like quest triggers
and custom spawn locations etc
Spigot api to write to NBT files when
PR it ๐ฅฒ (plox)
The answer to every spigot feature request.
Non blocking world loading when?
Would enable servers to load worlds on demand and therefore improve performance. Would be lovely
I mean PDC is an NBT wrapper so ig I could just add a saveToFile method to that
Yea, but it doesn't grab or modify any vanilla NBT data.
Is md against possibly modifying vanilla data?
Likely
Directly yes
Thatโs what the api is for
But this would be targeted at custom NBT files
Would also need a reader
NBT is a pretty cool format tbh
Not the most compact but easier to work with than raw binary files
can someone tell me what's wrong with this
Well it's roots are in JSON, sooo.
hold on
it's from quality armory
i was doing some config and when i did /qa reload in game an external error came up
I doubt MD would go for it though
im having some problem for calculating the maxPage and getPaginableItems
https://sourceb.in/LMvuDpipQZ
the item don't appear because the getPaginableItems is made wrong and maxPage is the same even changing items or size
If anything that would just encourage people to avoid the api
Which is kind of counterproductive
probably even i calculated wrong the page and items im sure about that
while compiling, what takes the most load, ram or cpu?
CPU
If you didn't know, CPU benchmarks include both chrome and firefox compile times as a marketing factor now.
Let me share some from my impl
protected boolean hasNextPage() {
int lastPageIndex = (int) Math.ceil(contentList.size() / (double) elementsPerPage) - 1;
return pageIndex < lastPageIndex;
}
protected boolean hasPreviousPage() {
return pageIndex > 0;
}
int startIndex = pageIndex * elementsPerPage;
int endIndex = Math.min((pageIndex + 1) * elementsPerPage, contentList.size());
List<GuiButton> currentPageButtons = contentList.subList(startIndex, endIndex);
for (int i = 0; i < currentPageButtons.size(); i++) {
GuiButton button = currentPageButtons.get(i);
setButton(i, button);
}
protected void nextPage(Player viewer) {
if (hasNextPage()) {
pageIndex++;
this.decorate();
this.renameFor(viewer, getCurrentTitle());
}
}
In theory what i need is the start index and endIndex with the math.max i have the items for the page
You just put all possible items in one big list.
Then you create a pageIndex which stores your current page index.
Then to calculate which sub-list of your content list you need:
int startIndex = pageIndex * elementsPerPage;
int endIndex = Math.min((pageIndex + 1) * elementsPerPage, contentList.size());
This defines a part inside your whole content list.
Afterwards you want to break out a part of the content list
List<GuiButton> currentPageButtons = contentList.subList(startIndex, endIndex);
Those are the items on the current page
Ok thanks, for calculating the max page how should i do it, if you watch the code i made i have a big list with all stored and i divide for the pages
Should be what i need to do for calculsating them
Your max page will be dependent on how many things you are showing in your GUI.
Yes so itemslist \ size
You may need to round up, but that's how you get your total pages.
for some reason i had obs on
after turning it off my compile time got 20 seconds faster
inspirational
Jeez what are you compiling
a medium-sized project
though it's in kotlin so compile time is bound to be exhausting
but 1 minute is painful
without obs it's 40 seconds
I donโt even think it takes me that long to compile spigot
This ram is 1333 ECC
hm?
So while I have 197GB of it, it's slow as hell
Yes
why though
Why not?
fair enough
DDR2 or DDR3?
I didn't know DDR3 could go that low. :p
btw did you deliberately pick slow ram or did it just happen somehow
ECC is typically slower due to the correction code, but for servers slower ram can be better than extremely fast ram.
how come?
I checked it's actually 2133
give or take
It's pretty bad regardless. I got it for free
o
The guy I bought it from sells used servers he said I could either have 64GB or for no charge 197
this looks like pain
I think the biggest factor is power consumption. Servers need to be efficient to run at scale. Otherwise your wallet will burn quickly.
is your name Tantalus by chance
oh
makes sense yeah
Wtf
It's pretty dope to have. Running an MC server with 150GB of ram
Does it actally do anything perf wise
probably just allows for more players?
Besides causing the GC to have an aneurism when it needs to collect?
lmao
Bets on when it'll be done?
bro are you compiling minecraft the game
I bet 2hrs
Allocated 50G. We'll see if that fixes my issue
You could just use Inventory#contains()
also i dont get the point of the item stack array just to make it a list
stream it directly
Or call Inventory#all(ItemStack) to even find where those items are
...
Arrays.stream(content).anyMatch(someItem)
Anyways none of those make sense for you Scallop
while loop like that looks dangerous
Woah, while loop?
dead server
Sewer side the server in 1 easy check
i just though of the most cursed if check
Just call
inventory.contains(item)
is there any way to hide chat with code? Ive been looking but can only find a way to "mute" players
Depends on what you mean by hide.
You need to listen for outgoing packets
And stop them from being sent
while(string.equals("amongus")) {
System.out.println("funny");
break;
}
Sounds like a job for packet events
so no way to stop only one player from recueving them?
Top 10 stupid ways to replicate an if statement
Sure, there is a way. But you need to listen for packets.
You could cancel the AsyncPlayerChatEvent and distribute the messages to the players you want, but it's quite the setup and it breaks every other chat plugin.
why do you check if it equals it just to check if it contains an item
shouldnt that be an event#getInv
just need to remove that specific player from the recipients list in async chat
Ayo, when did that become a thing?
Since async ๐
String name = "harald";
for (int i = 0; i == 0 && name.equals("harald"); i++) {
System.out.println("funny");
}
Really? I'm just blind then? I don't remember it being a thing. At least not back in the 1.12-1.14 days.
should this hurt my brain
oh god its also infinite
for (;name.equals("harald");) {
System.out.println("funny");
break;
}
This works as well
No it just runs once
It was in 1.8 and I believe 1.7
Oh my god it really was there from the start. I can't read after all. :3
while loops are only if the amount of iterations are unknown
I can only think of one time I've actually had to use one.
Example, you're receiving data from a stream.
Or if you have to check if an inventory is equal to your GUI inventory



is there any "easy" so to say way to tell when the server is crashing
too many variables
if a servers crashing tps would die right, so i could just do something if tps is below like 5
if i can always get it while it is running, when i cant get do stuff
you can only tell if it HAS crashed, not if it's crashing
im guesing there is no way to run code once it has crashed
if(crash) dont();
try {
server.tick();
} catch (Exception e) {}
Thatโs essentially how it should tick to be fair
Well there's still the 50ms delay
That's part of the loop
Sure is but it's probably not part of the tick() method
real representation of folia
while(true) {
new Thread() {
chunk.tick();
}
}
i wonder if paper would ban me for that
Lol
Hello, how can I get the max health of a player ?
Specifically it's
while (this.running) {
It's an attribute
I tried to get it but this killed me x)
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
okayyy thanks (I used .ordinal() lol)
how many terminals do you need
at least 3 it seems ๐ค
300 you mean
how do I place a block at a certain location?
location.getBlock().setType(material)
thank you!
yep figured it out, but thx anyways
instead of setType?
mhm
You don't make your language with pure machine code?
naw i use electrical currents
anyone know if itโs possible to set the playerโs attack indicator
You can still use nms and reflection to set it
Oh it's about the client. I thought he just wanted no cooldown
yeah was hopping to set it to display a current attack cooldown for some custom attacks iโm making
You can set an item cooldown if those attacks require a specific weapon/staff (any item)
Yeah, the same cooldown that ender pearls use
It's per material
how do I set per se, the X coordinate of a Location data type variable?
Location#setX?
Keep in mind that setting the cooldown won't prevent the usage. It's just the visual so you have to implement that yourself.
why use the hash?
To indicate it's an instance method
Ahh, I see what i'm doing wrong
currently doing a skill system which uses custom model data on a singular item so wouldnโt be useful for that
but the cooldown on the main weapon for cast time sounds like it would work well,
thanks again guys
jesus thats stupid, instead of doing
location.setX(expression)
I was doing:
location.setX() = expression
lol
Well you still have the actionbar that you can utilize to display multiple cooldowns
currently using that to display buffs with negative space ๐ could definitely work though if i put in the time
yeah or multiple (shorter) bars like this (maybe using the | character instead)
Stole that image from some spigotmc thread
neat idea thanks ๐
progress bars are surprisingly easier to do than 10 year old me thought they were
or well actually everything is easier with a bunch of maths
Maffs
Harder than setting a material cooldown but yes it's not much of a challenge.
NoClassDefFoundError: org.bukkit.Translatable
any ideas why?
Hi, the List is empty and so no items even if i add the items but seems like its not called even if it is
Paginable: https://sourceb.in/cvFx9xbYiC
Gui: https://sourceb.in/sTlQaeafk9
setIconsPage(iconsMaker()); seems to not be called and so it can't calculate nothing an everything is 0 (not the size) and arrays empty
It's not really an easy list to maintain. We have a feature flag/datapack API in the works I think which should cover that
thank you for reminding me to actually create command cooldowns for MineMemer
sad acf doesnt have anything for that
I have to actually use my brain for this one
It's just a Map<UUID, Long> with the last use time. You could also remove the players UUID onQuit
I might be overthinking this, but I currently have a per player configuration setup and I've come across the need to store cooldown information so that they will persist across restarts. The way I'm currently managing the files is through an interface so that I can switch between my storage solutions, but the interface is massive. There's methods for everything that can be stored in the file and some QOL methods as well.
The potential issue I am seeing is that in order to add the cooldowns to their player file, I need to not only write the data to the file, but also apply the cooldown immediately after. Now, I have a CooldownManager class that can assign cooldowns to people and it stores that info in a List<Cooldown>, but if I want this class to actually be the manager, I have to call upon it through the interface implementation.
This seems weird to me because up until this point, I haven't needed to call upon another class in the interface implementation up until now. I'm worried that I'm creating coupling between these classes when there probably shouldn't be. However, I don't currently see a better way to keep both the player files and the cooldown list in sync.
I know but that still does require usage of le brain
I forgot to mention that this also changes how I will end up using the CooldownManager class. Instead of calling it directly to assign cooldowns to players, I would now have to call the interface method instead. It feels like the manager class is kinda redundant at this point since it's only ever used in one class.
If I'm understand this right, you have
- An interface with an implementation to manage user files
- A cooldown class
- A cooldown manager class to set cooldowns (and maybe keep track of them)
- Whatever classes that use the cooldown
Basically what you want to do is to let your manager have an instance of your Interface to interact with and the necessary functions you need inside your other classes that utilize the cooldown.
So for example a command with a cooldown would require the manager in it's constructor (or any other DI way)
Then when the command runs it would call something like cdManager.hasCooldown(Player, command). Therefore the manager would do return interfaceImpl.getCooldown(Player, command).isStillValid() or however your cooldown class is built
can someone explain why any code under the green line doesn't get executed?
it should get executed. Maybe you exported your .jar wrong or forgot to restart/reload the server
So if I'm following correctly, the manager class is kinda like a middle man? To where in your example the command class could still call cdManager.addCooldown/removeCooldown and the manager then basically passes that along to the interfaceImpl?
you're setting z to y location + 1
i assume that's a mistake
ah yes it is
Not to mention the fact that you're setting and modifying the same variable to itself
Can anybody help me with set home plugin??
huh?
The IDE even highlights it
yeah i see what you mean, but think of it as I'm resetting it to an original block position
blocklocation and blocktobreak are referencing the same thing. you probably want to be doing blockToBreak = blockLocation.clone() to stop blockLocation being affected
I'm not sure it's doing that
Hello, how can I remove 1 durability of an ItemStack ?
how is block location effected?
What you're saying makes sense, thats my issue, it's like it keeps building itself on what it was told before,but i thought anything after the equals operator doesn't get effected
both blockToBreak and blockLocation reference the same object. if you change the value of one, the value of the other will also be affected. you're not creating a new location object by just equalling them
clone() creates a new location object, which means the original location object will not be modified
huh. is this in normal java too?
Yes the manager will be used to keep track of active cooldowns and will be your only way of setting/updating them.
Think of it as a helperClass aswell.
So basically if your interface just has setCooldown(player, command, time) which sets the cooldown to the given time, then your manager could have helper methods like setCooldownRightNow(player, command) that would simply call interface.setCooldown(player, command, System.currentTimeInMillis()); or getRemainingCooldown(player, command) that would then return storedTimestamp - currentTimestamp. Obviously those are super simple examples (and not the best method names either) but that way you can make it as complex as you want without ever touching the interface that should only be used to store/read the data and does not do any processing.
Therefore you are also following the single responsibility principle of SOLID. Interface does the file handling, manager does the delegation+translation and command talks to your manager.
so,
int v = x;
makes x also equal to v?
not for ints no
uh i wouln't say that
u want me to delete it?
Ok cool, so I just needed to adapt my manager class then. Ty.
I think I'll be running into another problem shortly, but we'll see.
iirc most objects are passed by reference in java, meaning it'll be the same instance whichever reference you use. primitive data types (int, float, etc) don't do that though. it's not just a bukkit thing. ignore that im dumb
but that's besides the point tbh, just whenever you're modifying location it's a good idea to clone the original one if you want to keep the original location for the future.
there are limitations to custom mobs, you can really only change mob behaviour without use of mods
It's a common concept. You want to build your class hierarchy in a way that you can replace each part. Technically you could even make an interface for your manager (although you'll only have one so it doesn't make sense). Following this concept you can implement your interface for flatfiles and databases since both just read/write data. You manager could be used for cooldowns in ticks or cooldowns in seconds - or you could even create a completely different manager that handles other things, like storing and receiving player inventories while offline. That depends on how deep you abstracted your interface.
you can start off by looking for samples of code on forums or stackoverflow if you are that desperate
in that case you could listen for when said mob is spawned and just give them the items and effects
thanks a lot:)
private void loadItemsResource() {
InputStream is = getResource("items.yml");
InputStreamReader isr = new InputStreamReader(is);
items = YamlConfiguration.loadConfiguration(isr);
}
why the hell does this still generate an items.yml in the folder
basically yeah
ok nvm im dumb I used an old build of the jar ๐
mem leak
you need to actually close it
(with try with resources if possible)
that produces a memory leak also
technically
practically
not for every part of the brain
depends on whose brain, but for the jvm's brain it does
no
java is only pass by value
well in theory ur argument isnt wrong
Its odd to get your head around until you realize it's almost all pointers
but semantically java is strictly pass by value
i just fully got mixed up about what those two were lmao. my bad
ye all good
It's easy to mix it up. Pass by value basically means that you are handing over the value of a variable instead of a pointer to that variable.
If you store an object in a variable (in java) your variable holds a reference to that object. By passing the variable that holds a reference, you are still passing the value of the variable (which in this case is a reference).
?nms
yes, but by definition java will pass the value from semantic variables, you can compare this to javascript which allows you to destruct an object by a semantic means as the semantic variables are passed
or well in js iirc its called call by sharing so not exactly the same but roughly
probably that another handle is open to the file
or it can just not access it i guess
it is my fault or host fault?
host fault
Probably yours since SQLite is local.
i will ask him to delete .db file. it is does not get fixed i will attempt to fix
well its the fault of whoever set it up
not the developer
no dont delete the db file
I was under the assumption that he is the programmer.
anyways tell him to check if any other programs are connecting to the database, if thats intentional tell him to use mysql because sqlite doesnt support multiple connections
It also doesn't hurt to double check that you are actually closing connections after your queries.
How do I make net.minecraft defined in intellij? Would anyone happen to know?
Your main path looks wrong.
Gonna have to be a little more specific? Are you wanting to use NMS or?
?nms @quaint mantle
Yeah I wanna use nms however net.minecraft isn't defined
It's cause you need to run BuildTools, The link above will help get you setup.
Ah alright thank you, also is there any possible way to add enchantment glows to items without actually enchanting them without the use of NMS swear I saw a function for it but am not quite sure
I am creating a plugin that I am going to sell, in your opinion, should I also add the ability to change the lore/displayname of the gui items through configuration?
Yes
If I were you Iโd use a library to parse that also
So u dont have to reinvent the wheel
I'm using MiniMessage actually
Good
Thank you so much for your answer
You'd probably need to use NMS if you wanted to avoid setting an enchantment, but I'm not even sure if there is an NMS method to do so.
The common approach is to just put an incompatible enchantment on the item and hide the enchant item flags.
Well I always think the taste of the consumer is right @green prism
like โthe consumer is always right when it comes to tasteโ and providing customizability is a good way of extending/addressing various tastes consumers may have
Well its like nether stars don't have an enchantment yet they have that glow
can anyone help me i want to change the block break animation for a block using nms?
what do you want to change?
the stage of the animation
then you don;t need nms
what i'm trying to do is make blocks decay over time, which requires the plugin to show the block break animation event when a player is not mining that block, is that more helpful?
there is an api method to set the block damage but I forget it's name
Also last question I use this code:
package com.kunosyn.synmc;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.attribute.AttributeModifier.Operation;
import java.util.ArrayList;
import java.util.List;
public class NetherStarSword {
public static ItemStack sword;
public static void init() {
createSword();
}
public static void createSword() {
sword = new ItemStack(Material.WOODEN_SWORD, 1);
ItemMeta meta = sword.getItemMeta();
meta.setDisplayName("Nether Star Sword");
List<String> lore = new ArrayList<>();
lore.add("You can hear the Wither\'s whispers...");
meta.setLore(lore);
AttributeModifier modifier = new AttributeModifier("generic.attackDamage", 50, Operation.ADD_NUMBER);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, modifier);
meta.setUnbreakable(true);
meta.setCustomModelData(125879);
sword.setItemMeta(meta);
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft("nether_star_sword"), sword);
recipe.shape(" S ", " S ", " N ");
recipe.setIngredient('S', Material.NETHER_STAR);
recipe.setIngredient('N', Material.NETHERITE_SWORD);
Bukkit.getServer().addRecipe(recipe);
}
}
The issue with this is that the "+50 attack damage" shows up as like while on head, torso, etc instead of only when on main hand. Is there any way to specify in the item meta that I only want it applied to the when on main hand?
Hi , why my plugin is not found in the console ?
with not errors
yes
name: firstplugin
version: 1.0
description: This plugin does so much stuff it can't be contained!
api-version: 1.12
author: MRDXO```
Attribute.GENERIC_ATTACK_DAMAGE
i put my class because my name of my class is firstplugin , Lol
I tried using the bat file script to automate the process for getting the build file and the directory it created is empty after it said done
Did I do something wrong?
you need to add this to the attribute modifiers for slot HAND
this will make the damage bonus only apply to the main hand slot
(replyed to the wrong message mb)
Would you be able to provide an example of implementing and registering an enchantment?
declaration: package: org.bukkit.inventory, interface: EntityEquipment
There's methods for each slot ^^
so I have to upgrade the spigot?
no
or the whole project?
let me check
hmmm
nice
lol
im using maven btw
Found this in pom.xml
maybe the <version> has something to do with it?
No
idk if it is the same thing tho
The problem is in the plugin.yml
interesting
How can I parse Strings using MiniMessage and get back a Parsed String object (not a component)?
ive been trying to make a custom command (/live) that adds a red colored [LIVE] tag to a player and makes them not see the chat, however when implemented onto the server theres no "/live" command, not even the console
could anyone help solve the issue? heres all the code (2 class files and one .yml)
https://paste.md-5.net/hekubugoro.java
https://paste.md-5.net/igoniyelup.java
https://paste.md-5.net/yumecereha.makefile
I mean, I'm actually doing like this but I'm hoping for a better way
public static Component translate(String string) {
return MiniMessage.miniMessage().deserialize(string).decoration(TextDecoration.ITALIC, false);
}
public static String translate(Component component) {
return LegacyComponentSerializer.legacySection().serialize(component);
}
public static String legacyTranslate(String string) {
return translate(translate(string));
}
plugin.yml says 1.19. what do I do?
anyone know how I can find the direction/side of the block which was being destroyed in a block break event
if it helps to make sense, i'm trying to make a type of drill plugin
commands not command in plugin.yml
thats all? im so stupid if it works now
I'm haven't made my own plugin yet so idk if this is possible. But maybe try getting the direction from the player that broke the block
you can only turn your face fast enough so it shouldn't be possible to get it wrong
as in up down, left right, front back
coords from the event and then direction from the player
the direction doesn't matter though,
you can still hit 3 possible sides
from a certain angle
still doesnt work
A player could be hitting any one of 3 BlockFaces to break a block. No way of telling which
There is a way.
ray cast
Still no
I do that with datapacks
- it works like garvage so I only use it for projectiles tho *
you sure theres no way?
You can only trace to teh block, you can;t tell which face they hit
Idk, I'm still trying to open my first plugin but something's wrong and you guys aren't reading my thing
add this to the api
could be any one of three
so I'm just waiting
show
?paste your latest.log from your server
where can i find that (im new to all this)
yes, replace the version to 1.19 alone
with nothing else, try that
in the logs folder on your server
how much is required, is since i joined the game enough or since i started it
It didn't let me even try
from the start
You shoul be changing it in your plugin.yml not your pom
u sure u know what you're saying?
changing what
its already in 1.19
it's already 1.19 though
The error you posted clearly says you are trying 1.19.4 in your plugin.yml
yeah i'm sure, thats how it is
the error says otherwise
You either didn;t save the changes or didn;t update the jar on your server
it doesn't get more saved than this
from the artifacts
stacktrace never lies
so I just make the whole project from scratch? it only had a println either way
why is this code not blocking me from getting the empty() nor is preventing me from clicking my own inventory to dupe the items?
https://paste.md-5.net/newiyiyicu.php
You didn;t update the plugin on your server java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.methsmp.liveplugin.LivePlugin.getCommand(String)" is null
how do i do that
fix your plugin.yml to say "commands:" instead of "command:" then rebuild and update the plugin on your server
@eternal oxide
?
what?
Huh?
what is "empty()"? in the code its expecting a method but I'm assuming you are expecting it as some comparison result
an itemstack
you said rebuild it
not to you
show your empty() method
looks fine, but you need to compare with java if (!empty().isSimilar(e.getCurrentItem())
no clue if your logic is correct though
do you actually want to run that code if it's not your empty ItemStack?
Your next line will also fail
if the item is not empty() or bottom inventory then yes
if(e.getView() == e.getView().getBottomInventory()) { wqill never pass
you are comparing an Inventory to a View. Two completely different objects
so e.getView.getBottom == player.getInventroy?
done that, the command works but i can still see chat
you need to listen to the https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/AsyncPlayerChatEvent.html
then loop over all recipients and remove any you don't want to see chat
SORRY IF I'M BEING ANNOYING (repost)
last time in case someone hasn't seen it 'cuz I really don't know what to do anymore.
plugin.yml says 1.19
And Spigot-API 1.19.4-R0.1-SNAPSHOT API is the newest bukkit version
last time I'm asking for this one btw, like at this point why would I even
you are using maven, what IDE?
IntelliJ IDEA
are you using artifacts to build or the correct way in the maven window for lifecycles?
Hi Sorry , how to fix the trouble ?
shush
wdym
Try restarting the server and make sure you have the new jar
I do
And I've done it
Then restart
