#help-development
1 messages · Page 473 of 1
Yes
gross I cbf to do proper matchmaking
PluginMessageChannels should do everything you need though
is your plugin that offered the "play" a spigot or bungee plugin?
they are a bit weird to get used to at first
Don't those need a player online thouhg
They do
I will also need to be communicating to tell the proxy plugin that the server is full or if the game has started or not
You must have a player online to be pressing the Play button
you need players to play games so I see no issue
I assume they want to send a message to proxy that the server is ready and can be connected to
?pmc
So that they then can send the players there
Hold on let me explain what I am doing
So I have a pterodactyl panel, and a server template for each minigame
The proxy plugin uses the pterodactyl API to create a server
And create ServerInfo so they can connect to it
That works perfectly
I would like to have a way to let players join from a lobby, or click "play again" after it ends
then you need nothing, you are doing everything on the proxy
I can't do these things from the proxy
on the proxy you have access to all connected players
Yes but I want a GUI so they can play
You can't execute bungee commands from backend I don't think
then you need a spigot plugin and messaging channels
If that was possible then I have my solution with a /play <minigamename>
what are you calling the "backend"?
Spigot servers
thats not a backend
also bungee commands are available on each connected spigot server
I am aware
but not through codef
You cant make a player execute a bungee command from spigot api
?pmc
Would I need a custom channel for this
What if I wanted to communicate when no players are in a server
not essential but you should
Like say if the minigame is ready to be joined
Who exactly are you planning to communicate with when no players are online?
There is no one online so there was no one to click the play button
What
No players = no game
No like on that individual minigame instance
No players would be on
But there are players in the lobby waiting
you don;t send anything to the mini8game server
Yes but the minigame servers sends stuff to the proxy
you only send players
And it cant communicate if there are no players on that minigame server
it shoudl not send anythign with no players on it
How would the proxy know when server is ready then
You are very confusing with terminology
INSERT INTO ban_trial.banned_players (player_uuid) VALUES ('08341680-0904-4271-af2e-24cc49b12952')
When a player requests to play a minigame, it clones the server template and downloads the server jar in the new server instance
No players would be on the server at that time
Why would I possibly be getting a success in update
But the data doesn't actually get put in the database
How would I make the minigame instance (spigot) tell the proxy that it is done setting up and players can join now
So I was right
Yes I think I was going off what you said
What is the sendData thing
messaging channels
I'm having a issue with MySQL
I have a method to insert data into a table, the method returns the number of updated lines and works perfectly, no errors or anything, I'm looking at the SQL Connections to monitor usage and that's working correctly, no issues anywhere.
Except after all the success, the data isn't actually added to the database. No clue what is going on at all
or do I make one of my own?
create table if not exists banned_players
(
player_id int auto_increment
primary key,
player_uuid varchar(45) not null
);
INSERT INTO ban_trial.banned_players (player_uuid) VALUES ('08341680-0904-4271-af2e-24cc49b12952')
How are you executing query
No errors, success all around, no issues with sqlserver connections and returns "1" cause it updated 1
Show whole method
PreparedStatement ps = connection.prepareStatement("INSERT INTO " + this.DATABASE_NAME + ".banned_players (player_uuid) VALUES (?)");
ps.setString(1, ban.getPlayerUUID().toString());
//<---------- Right here print (ps) and that's what I sent
ps.executeUpdate();
That is not whole method
is there a event for a player taking a item from a gui
There's nothing else
Try and catch
That does not get executed
Cause I have prints everywhere
And the data is not null
InventoryClickEvent
This statement is a print from sout(ps)
Literally
I've been debugging for close to an hour now... Switched SQL Servers, remade everything, no luck
ps.executeUpdate() returns 1
Figured it out
Pterodactyl has a thing where you can see if a server is running
STARTING and ONLINE or something
ok im using InventoryClickEvent how do i get the name of the gui
event.getView().getName or smth
It's getTitle
But I wouldn't use title to check inventory for InventoryClickEvent or related
java.lang.IllegalArgumentException: Channel must contain : separator (attempted to use Minigame)
why can't I use the channel "minigame"
why do I need a :
how does this work
Well
Guess what
MySQL autocommit seems to be broke
connection.commit fixed it
after 1.5 hours
use something like bc:minigame
like literally that?
or actually like BungeeCord:minigame
makes no difference, it's just a naming requirement
and do I need that same thing on the proxy listener part
That's bad design
what would you reccomend
one sec trying to find the resource
@earnest lark ^
regardless that is bad design
use the guide I sent as a rough outline for what you need
hey guys
hi]
im new to plugin dev so I get a bit of help with smth
k
damn I cant send all the code
?paste it
?paste
oh
get sniped
I even interrupted my coding for that :/
so what now I put the code in the site
then send us the link
i want to make the kills variable seperate for each player
like they all have a seperate variable but the scoreboard only displays the kill count of the most recent player
because the scoreboard isnt local
That's because your bukkitKiller is a class variable. Instead you should make a function in the scoreboard
Something like updateScoreboardForPlayer(Player player). Then in your events you would just call that function after you updated the hashmap
alr ill see if that works
thanks
wait i dont think I follow
i created a function that returns the kill value but idk how that would help
like I get that it's because they are class variables now but idk how I would fix it
I just noticed you have to keep updating inside the scheduler due to the time being displayed.
In that case you want to loop over all players and update the scoreboard for each of them inside your scheduler.
for(Player player : Bukkit.getOnlinePlayers()) {
// update scoreboard
}
If you have a subset of players for each board you should loop the subset ofc
so excuse my dumbness cause I started plugin dev a few days ago but for looping for all online players, would I nest my already existing for loop within it?
I don't know what you are looping there. What is boards.values()?
idfk I followed a tutorial 🤣
Send me the FastBoard class pls
fast board is alib
Oh
I'd assume that boards.values() returns multiple scoreboards if there are multiple scoreboards.
I can't tell if each scoreboard is for every player or only one player
teams belong to scoreboards. Players can only be in one team at a time
Why would you loop different scoreboards then?
you can have multiple scoreboard but not all in use at teh time
Well in that case he doesn't need that loop. Unless there ain't another way of determining the correct scoreboard
Just try to put it inside your other loop and see if it works 🤷♂️
I don't know the lib so I can just guess
Is smile around
I was wondering how he did to implement paging into his GUI system
how would I make a local scoreboard without fastboard?
Nah he's probably asleep
I wanna adapt his implementation to allow multi-pages
But I'm also working based on his GUI tutorial and implemented paging by adding a page variable to my inventory.
And then my Consumer just increments/decrements the page and calls decorate again.
Decorate is therefore adjusted to deal with the page
this.addButton(48, new InventoryButton(Material.ACACIA_BUTTON, "Left", null, event -> {
page--;
this.decorate();
}));
ill take that as you can't
I just did this an hour ago so sadly I did not clean up all the mess yet. I can still send you the code as a reference if you want^^
yw :)
if you're talking to me then that would be greatly appreciated
Nah I was talking to tomis, sry
I assume you store the variable in the implementation and not the abs class
damnit
For now, yes. But the cleanup will be to have another abstract class. Something like "PageableGUI"
Oh wait you use the consumer like you said, I see what you did
Yes exactly
What I was just about to say
Sick!
The guide ain't great since there are no descriptions but it's a general direction
final Scoreboard scoreboard = (Scoreboard) manager.getNewScoreboard();
final Objective objective = scoreboard.registerNewObjective("test", "dummy");
registernewobjective doesn't exist
i think you were right the first time about it being because they were class variables
i modified it to display the player's location and it worked fine on a per-player basis
so how the heck do I update kills without using class vars
When you have the player then you don't have to use the class variable.
Just get the kills of the player from your hashmap like you got the location from the player
why didn't I think of that lmfao kills.get(board.getPlayer().getName())
im so stupid
Hi, so I am rewriting a plugin and noticed that "setLore" is deprecated, but after some searching it seems that it's a paper api thing... Should I just swap back to spigot api. (I took an extended break and can't recall any reason for the switch)
org.bukkit.inventory.meta.ItemMeta.setLore
Deprecation is just a warning
its a paper thing because the recommendation is use Adventure Components.
It’s still usable
Deprecation does not mean that it does no longer work
the string method still working for the basic thing.
I am aware, I am mostly just asking if there's any real benefit to paper over spigot in terms of development? I am very novice with plugins

Paper 💀
Depends if you want the plugin to run on spigot
Paper has some things that spigot does not have. Like a PlayerJumpEvent. Besides that, no.
Oh and by using parts of the API that are not part of spigot your plugin will only work on paper servers ofc
Do you have any expanded thoughts on why I shouldn't use paper? I'm looking for the best possible experience both for development and players
Do you have any reason for using paper is the better question
I've used it for so long I can't recall why I started and don't see why I should stop? Honestly, if there's a better server I should be running for the best player experience then feel free to inform me
That's not what I meant. I was asking from a developer perspective. Are you using any special features of the paper api?
Honestly not atm but just the fact that "PlayerJumpEvent" is a thing in paper and not spigot does make it more interesting to stay considering features I've planned
You can stick with paper. Just keep in mind that if you ever plan on publishing your plugin on spigotmc that not every server is running paper
You are not allowed to publish plugins that require paper on spigotmc
~~Does it impact my ability to post plugins to spigotmc if it's built on paper api? ~~ nvm coll answered already
I use the API for whichever platform the server I am working with uses, so it's been paper for a while.
Pretty neat though
is there a jira request for PlayerJumpEvent
I wonder where'd you inject that at in NMS though
? wdym by that
ohhh
yeah actually now that I think about that
That’s what is generally used on spigot to detect jumps
Granted idk their exact implementation but I imagine it’s similar
Fabsi
Yes?
So I put some page logic on the abstract
But now I'm wondering, how exactly did you call decorate only when the prev and next buttons are clicked
Did you do it from the consumer inside the button?
Or did you override the click method in the implementation
I did it from the consumer, yes
Oh cool
I wonder tho
If I added the prev/next button in the abs class
And I call decorate from the abs class
Does it still use the implementation?
I don't think it does
I think the consumer logic needs to be in the implementation
No you would call decorate in your implementation which then calls super.decorate(). That would be your pageable class. And the pageable class also calls super.decorate()
I just started creating the abstract class but I can get back to you when I'm done so we can compare
For sure, I'll have mine ready in a few mins
I implemented a very handy
InventoryItem
For stuff that doesn't require events, which is really nice
CompleteableFuture
Doesn't exist
Completeable isn't a word
It's not a word lol
Go on google
Completeable
I really wanna dive deeper and improve a lot of things based on smiles implementation.
But I have to keep a balance between making progress and doing cleanup so I don't get bored
That makes complete sense of course, but adding a InventoryItem takes you about a min at most
And you'll use it every single time, guarantee
I don't have any items without functionality (yet). I might do the same in order to make the GUIs prettier tho
Fair enough
Always nice to be able to display a item to just show info
Of course you can do it with a InventoryButton
But why
When you call decorate do you need to reopen the inventory?
No it will override the content in the inventory. If you adjust it a little bit
Oh yeah just saw
Cool
public class InventoryItem {
private Function<Player, ItemStack> iconCreator;
public InventoryItem creator(Function<Player, ItemStack> iconCreator) {
this.iconCreator = iconCreator;
return this;
}
public Function<Player, ItemStack> getIconCreator() {
return this.iconCreator;
}
}
xd
It's just same without the consumer
Why do you need the creator tho?
Customize the item still
All it is it a InventoryButton with event
So for example
For background items
InventoryItem backgroundItem =
new InventoryItem().creator((p) -> createBackgroundItem());
for (int i = 0; i < getInventory().getSize(); i++) {
this.addItem(i, backgroundItem);
}
And that fills up all empty spaces
The way it works too is order, if you first set it to glass, and then set a specific slot to something else, the latest will be the one that actually shows
I see. I did not add the iconCreator thing since my Buttons do not depend on the player viewing it
So always just fill it with a single object to not need to make hundreds of itemstacks
Again, this is always for functionality especially if you're making a API having it is nice
Have both alternatives
Yeah that makes sense. Will do that as one of my last cleanups probably.
Still got a lot of more important things to do. Probably one of my largest projects so far
Glad to hear
I just got mine accepted on spigot
So I'm extremely happy
Like, hours ago
Accepted by who? The premium resource team?
Yup
Would anyone here know of any type of articles or anything? A couple simple projects to learn the API kinda like a unit test but to learn this lib?
(I know java)
I see. The biggest part of my project will be free and open source though, That would be the engine and some utility stuff. More complex or specific stuff might then be released as a "premium addon"
Always a good idea
Other developers can then create addons themselves if they want to. It'll be a very powerful tool. I already spent over a month working on it. Average is probably 4 hours/day
I'd say I'm 65-70% done (for version 1.0 that is)
After that there's a lot of room for more features.
And I will have to set up some servers and documentation to test and learn about it
Glad to hear! Keep at it
Of course! Alright, back to the abstract class :)
anyone got a good anti cheat i can borrow
Question, what would be the best option for storing whether a players pvp is on or off?
i've used PDCs but ive run into issues sometimes
Also a decent alternative
A simple Map?
would that be better than assigning it to the player?
If you have issues with the PDC than that's your next best alternative.
Although idk why pdc would not work
idk what it is, my pdcs break in certain places
could i use meta data on the player?
You could use ScoreboardTags
ok, thanks for the suggestions
still waiting for that response
wrong channel, go to #help-server
nah not what i need
i need to know
idc about the server side
i just need info
Im in the right place quiet frankly
SOOOOOOO anyone got something or...
"Serious Spigot and BungeeCord programming/development help | Ask development-related questions here"
Relax kid ik what im doing
ok, have fun waiting for an answer
well the way you asked sure doesnt make that clear
just keep playing btd6 u seem to be doing just fine with that
lmao
i hv to make a stupid fucking anticheat for my friend cuz they hate every anticheat out there soooo
thats why im asking
Vulcan hate it
grim HATE IT
Negativity hate it
HAC hate it
damn, thats not gonna be fun. Anti-cheats are the worst to make
lmfao
tbh though, ive never found one i truley liked
fair
what you should do is just get an open source one and modify the branding and tell them you made it. see what they think lmao
do i compile that to a jar file tho
i there are some you can jsut edit it through the config file
i did just rip one off the internet and handed it to them said "here ya go shut the fuck up and accept it"
i know, the other owner of my server did that but idk what the AC was that he used
lmao
good
Anybody have an idea why I'm getting a "player moved too quickly" warnings when they're teleported on-command?
Pretty sure that's just an unfortunate side effect I'm not sure if you can do anything about that
This behavior can be replicated by /tp in game
It should not. You probably forgot to reassign the string
do you reassign the translated string?
:)
Genius
damn, you're right. didn't think to try that
just a minor annoyance
Well you can probably guess why that's the first thing I ask, lol
You know what's interesting about smile implementation
The gui title cannot be player-specific
Maybe if you make the abstract Inventory inventory not final, and call createInventory in the implementation constructor instead of in abstract
Yeah I had problems with that, too. I added the title and the inventory size to the constructor now. I don't have a createInventory method anymore
public InventoryGUI(int size, String title) {
this.inventory = Bukkit.createInventory(null, size, title);
}
Well
I just did
Abstract
private Inventory inventory;
Remove createInventory from constructor
public HistoryMenu(ArrayList<History> history) {
super(history.size());
this.history = history;
super.setInventory(createInventory());
}
Inside the menu implementation call setInventory so then the Data you're using to populate the GUI "Or even just the player name"
Is available
That would also work, yes
Is there a way to NOT call the overwritten method from the parent class? Probably not
Impossible
That's what abs classes are
I mean
maybe you can override
And not super()
Yeah I want to not call the final implementation but just the function in the abstract class
nah I'll show you the problem
?paste
Tag me btw
Basically the this.decorate in the Left and Right buttons calls the overwritten version of the extending class. This then sets the buttons again.
I would just need it to reload the page.
Don't you have a second screen? But here you go @regal scaffold
I see
and I just noticed I don't need a getter and setter on the page
Is set a bool
And define if you do need to super or not
Now, let me show you something
the super is not the problem.
I personally don't like some things
InventoryButton previousPage = new InventoryButton().creator(player1 -> {
ItemStack item = new ItemStack(Material.ARROW);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Previous Page");
meta.setLore(List.of("Click to go to the previous page"));
item.setItemMeta(meta);
return item;
}).consumer(event -> {
this.decrementPage();
decorate(player);
});
Then what are you referring to
if (page != 0) {
super.addButton(pageSize + 3, new InventoryButton(Material.ACACIA_BUTTON, "§aLeft", null, event -> {
page--;
this.decorate();
}));
}
This calls the implementation in the child class
I would need it to call the implementation in the same class only
I can still do the boolean and ignore the added buttons tho
Is make a protected function to make the button
In the abs class
And in the implementation is where you add the button
Yeah you are using a builder
You can probably make a InventoryPageButton class too
And then you can make the button in the abs
And assign the consumer in the implementation
Be careful with page-- and page++
I was showing I did this.decrementPage();
Because you probably check to not go negative, right?
Yup
I fixed that by not displaying the button to go "left" (or page--) on page 0
Either loop around
Or just not decrease
Oh
Yeah also a good idea
But looping around is fancy
that's why there's the if
we follow 2 different designs and I don't get how your solution would fix that on my side. I implemented a lock now.
https://paste.md-5.net/yukuhidero.java
Well like I said, you have to call the method directly from the implementation
Or
Override the clickevent
In the implementation
But it doesn't matter where I call decorate, it will always call the "highest" overwritten version
make a boolean in the implementation
I could fix it by not overriding decorate on the child class at all. Then I would have to override the onOpen
If the buttons are pressed set the boolean to false
Check the boolean in the parent
If it's false, skip and go to the super.parent
default back to true
Isn't that the same thing I do now with extra steps?
Is it possible to load a world by its UUID?
Didn't you say right now it doesn't work?
or is the uuid tied to the actual loaded instance itself
It does work with the lock I introduced
all good
I can't create a worldcreator with a uuid param
If it ain't broke...
I said load
not loading chunks but the actual world itself
Uuid ... can't I'd what don't exist
Id
like
I get a world, keep track of its UID but I unload the world
I'd like to load the same world
instead I'll have to fucking keep track of its name or something
Name the world the same as it's uid
Lombok 
Any ideas as to how to make my plugin load on the server? java Caused by: java.lang.IllegalArgumentException: File 'plugins\Realms.jar' is not a valid plugin file, cannot load a plugin from it! at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:54) ~[paper-1.19.4.jar:git-Paper-507]
send class
it says its not a valid plugin file, therefore theres some issues with your code
Message when compiling jar:
[INFO] --- maven-jar-plugin:2.4:jar (default-cli) @ Realms ---
[WARNING] JAR will be empty - no content was marked for inclusion!
?paste your pom
pom.xml
Do I add this in the plugin.yml?
If so what would the format be?
send plugin.yml
name: Realms
version: '${project.version}'
main: me.combatborn.realms.Realms
prefix: Realms
authors: [ CombatBorn ]
description: The plugin used for Realm Servers.
api-version: 1.19
commands:
gm:
permission: admin
description: Changes a player's gamemode.
gi:
permission: admin
description: Give a custom Item to a player.```
hm
no version on the jar plugin
add <version>3.3.0</version> below the artifact id
Thank you! I'll try that now.
Surprised it didn't fail the build because of that.
reload maven
Reload the pom
top right
reloaded, same issue
reloading should fix that, check it isnt still indexing
try reloading it again, the non popup button is in this
Yeah after doing that a few times it's still red
just checked online, it appears the version isnt needed there but thats what the error is talking about
@tender shard may know more
After reloading intellij and recompiling, it seems I have a new error! Progress!
Means the path in your plugin.yml is wrong.
I have recently changed some file names around, but it does seem that it was the correct path already in the plugin.yml: me.combatborn.realms.Realms
No it doesn't
It's not in the player directory
He has the right path, can't think of why it can't find it though.
By any chance would it have anything to do with this file?
Is there a different error thrown if the class doesn't extend JavaPlugin?
I recently changed the project name from Realm Plugin to Realms
I'll try.
It might have been updated with the project rename.
Might want to check your variables in the pom
the error says by himself "Cannot find main class me.combatborn.realms.Realms'"
I'm not sure what I did wrong though. It seems to be the correct pathc name: Realms version: '${project.version}' main: me.combatborn.realms.Realms prefix: Realms authors: [ CombatBorn ] description: The plugin used for Realm Servers. api-version: 1.19
its extended to JavaPlugin?
Yes sir.
?paste your Realms class - Make sure you paste it. Easier to read and formats it better.
Why is
Bukkit.getOfflinePlayer(String) saying not found
When I just left the server
Even though it's deprecated it should still work correctly
What String are you passing in? Username or UUID
Username
Use UUId
I can't
If you can get the username, you can get the uuid
Show code
Player target = Bukkit.getOfflinePlayer(strings[0]).getPlayer();
This shouldn't be null
If I just left the server 10 seconds ago
But it is, it says not found
And secure profile is disabled
Open your compiled jar and check the path
Hi im making an Api for my plugins, i need to call the getCommand() but i can't find it by using the plugin instance, any solution?
This is null as soon as you leave the server
My other solution is to querry all banned players by UUID, Convert to offlinePlayer
And find a match
Ok, why use OfflinePlayer when you're object is a normal Player? Just use Bukkit#getPlayer() and it will be null if they are offline.
yikes. there's nothing in there 😬
I need to get the UUID
So I can run the command
It's a /unban <offlinePlayer> by name
This will be null because Player is reference to an online Player, not an OfflinePlayer.
So either I querry all banned UUIDS ( Which is stored ) and check the name of each offline player object
Or idk
So just use OfflinePlayer#getUniqueId()
https://paste.md-5.net/udesipezix.cs
Here's the compile log
Yeah, something is wrong with the compiling
Why dont you query the banned property by name?
It's stored as UUID
But I did it...
OfflinePlayer target = Bukkit.getOfflinePlayer(strings[0]);
This returns the uuid
Then create a second table
UUID | LastSeenName
Solved without needing more sql
Can you paste your full build file
Works correctly now
Ok but for bigger servers you should not run this command on the main thread.
There is an offline player cache and if your queried name is not in it then you are
doing a ton of IO which could lead to some lag if used too often.
Yeah I am aware
But does Getting a single offline player really take that many resources?>
I'm not looping through anything
Just 1
How do you compile?
I double click this
It'll do some querying in the background to get the player if they aren't already in the usercache.
So you jar without compiling the classes.
Go to Lifecycle -> install
Use the Lifecycle tab
Or package
I'd use package since install will copy that code to your local maven repo. No need for that unless used by other projects.
yikes. It's saying my api doesn't exist?
package will
- compile the classes
- run unit tests
- jar the classes and resources
install will
- package
- put jar into local maven repo to be used as dependency
You should also add the version number to maven-jar-plugin to stop the compile warning
You need to install the api so that it gets put into your local maven repo.
Otherwise maven wont be able to find it.
done
at the moment when I make changes to my API I click the "install" button
I currently have the API added as a library in the project
That's the only way I know how to implement APIs. Is there a better way?
Only if you create a multi module project
Otherwise you need to install the api every time you make changes to it.
Yeah that's what I'm doing at the moment and I'm perfectly fine with it for sure
My plan is to have a few different plugins using this same API
Then you are on the right track. APIs should contain code that can be useful to
any kind of plugin. Like GUIs, Holograms, maybe NPCs, Persistent block data,
formatting utilities, util classes in general etc
Yes. I have a custom item system in particular that I'm very interested in distributing amoungst a few types of server. That way when I transfer the custom item data from Server A to Server B, both servers will know what a custom item is without needing to use the exact same plugin.
I have a few other systems I also intend to add to the API
You can also shade other libs into yours to make it a bit easier.
For example:
-
Custom block data:
https://github.com/JEFF-Media-GbR/CustomBlockData -
Anvil GUI text input:
https://github.com/WesJD/AnvilGUI -
Decent holograms:
https://www.spigotmc.org/resources/decentholograms-1-8-1-19-4-papi-support-no-dependencies.96927/ -
Triumph inventory GUIs:
https://mf.mattstudios.me/triumph-gui/introduction
Or you create your own:
https://www.spigotmc.org/threads/create-a-hologram-library-nms-or-protocollib.590999/
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/#post-4553427
I will be yoinking that inventory gui library. Would you say it's well built?
its possible to get getCommand() from a plugin instance for an api?
As long as the class extends JavaPlugin, then yes.
Triumph is decent. But building your own is not too hard either.
You can look at the guide on the bottom. If you dont like that then Triumph
is a good alternative (Examples are in Kotlin tho)
im making an api for my plugin by using extends it gets called with my plugin class or not and they get registred to my plugin
You should not extend your JavaPlugin class
I wrote a built-in gui system for another project in the past. It wasn't very well done but that was over a year ago
Yeah it's just not making sense though
As long as you have an instance of your main class that extends JavaPlugin, you'll be able to access #getCommand()
smile have you played around with DisplayEntities already?
so how can i call the getCommand?
Did you add it to your pom?
Get the JavaPlugin instance and call getCommand() from it
in the registerCommands method i have a constructor for the plugin and thats
Mmmm, very smooth.
Oh I'm very unfamaliar with maven and this is actually the first API I've ever worked on 😅 I'm not sure how to do that
i can't find it, code https://sourceb.in/Gm8vZshu0v
That is super cool
public void updatePhase() {
double time = System.currentTimeMillis() / 3000.0;
double value = Math.sin(time * 2 * Math.PI) * 0.5 + 0.5;
double reversedValue = 1 - value;
double output = value > 0.5 ? reversedValue : value;
phase = (output - 0.5) * 2;
}
probably can be optimized a lot
But the effect is pretty nice
What's nice is, I adapted the entities to be able to support Components
Cause that's never getting added...
So I can use stuff like MiniMessages too
Your API defines its maven ID on the top of its pom.xml
Use this as a dependency in your other projects
Ohhhh! I'll check that out rn
You need to call getCommand() on an instance of JavaPlugin
cool!
Plugin is already an instance of JavaPlugin
Linear Interpolation math might be beneficial here, although what you have now is pretty simple. The only thing that looks intensive is Math#sin()
Then use it??
oh im stupid plugin is different from javaPlugin thanks
And another thing:
Never add jars as artifacts on a maven project
Because im suspecting you doing that right now
At the moment I'm not building jars with Artifacts, I did that in the past though for sure haha
Yeah but you are adding the jars to your project.
Otherwise your IDE would be completely red, even before building anything.
So remove them
Remove the spigot jar and remove your API jar
Yes I removed the jar from my libraries as soon as you taught me the maven pom.xml trick
Alright 👍
Because in maven all the jars are located in your local maven repository.
Everything is configured through the pom.xml
Server loaded with no errors!!! so happy thank you a million
Nice
I haven't had this much fun programming in a while. I am really enjoying the project I'm working on right now
It depends, what kind of info do you need stored?
You can store it in a database or with .yml files
Databases are the recommended approach, but yml files are the easiest to get something up and running quickly.
Honestly either way will work, it's just that databases are scalable. Flat files are not.
Yep but from plugin side
But at least create one yml file per player
playerdata/<UUID>.yml
Efficiency
Because you can load and unload the ones you need instead of everything at once.
Why in the hologram section not use reflection to make it without using nms library?
System memory isn't unlimited.
Because reflections are utter garbage
It still uses nms but its much slower and you need a fk ton of extra code.
As well as a rewrite for every other version as well.
they are helpful for newer version, if you want to make them work for 1.13 to 1.19.4 without problem and rewrite for newer
I dont want to bother looking up every obfuscated name of every field and method i use.
IMO, if you are dealing with NMS, Abstraction > Reflection.
if for example, i wanted to use this code is I need to rewrite for every version as I understood?
Now that we have mojang mappings i would just create a multi module project
and use the latest implementation for unknown versions.
Has a decent chance of working for upcoming versions. Same chance as reflections.
Even better than reflections actually because you dont get fked if the obfuscation seed changes for no reason
*As long as you dont use CraftBukkit
That is
Because then the package names are fked
Doesn't statistics holds first join. Not sure tho
if i want to use the code then for me who wants use it for multi versinon like 1.16 and 1.19.4 i can use protocollib
Do they even need to change it anymore? They give us the mappings anyways.
Probably not
so for what I understood its better-using packets in case you want to support the vast majority of versions, if I make a plugin in 1.16 it will be the same as 1.19 without chainging
If you want to support more versions then use plib
But even then you need multiple modules
These are the kind of plugins I'd throw out of my server without thinking twice
Bukkit 1.0.0 o.O
Need some advice. I have a relative time class that I want to modify to support multiple languages. Class is here: https://paste.md-5.net/xecagupevo.java
I want to have the map keys pull from the language files I already have. The problem is that this is a util class. I don't have a static instance of my main class anywhere. In fact, I've purposely avoided it due to claims of it being bad practice. That being said, it would be nice if I wouldn't have to supply an instance every time I want to use a method.
Should I just cave and create a static instance or is there a better way to handle this?
Firstly, Id recommend not using the bukkit api. Use the Spigot API - Then you'd probably need to make use of ProtocolLib to support multiple versions. Depending what versions you're wanting to support and what you are wanting the plugin to do.
Mojang released their official source code mappings?
They have ever since 1.14
pretty sure yeah
Wow I'm totally out of it. That's really nice
I hate staring at obfuscated code
Hey guys, if you cancel a RunTaskLater bukkit task, then it just wont execute right?
Yes
Depends on when you cancel it but essentially yes.
I just realised something
once we get 1.20
i could use display entities to display the memes in the map thingy kinda thingy wingy like i thought
Display entities came 1.19.4
oh wait what
wat da hec
are you telling me that I have been tricked, fooled and possibly even bamboozled?
For the brewery plugin, is there anyway to make yourself explode after drinking a potion?
like is there a code for that?
Correct
theres probably an event for drinking potions
just check for your potion
then boom
does anyone know how to check if the item which was clicked (InventoryClickEvent) was in the top inventory exclusively?
there is a method to get the top and bottom inventories but I cant find one to check the position of the item
getClickedInventory ?
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
how do I get the armor value of an entity and how does minecraft calculate damage?
can someone help me with dust particle spawning? is there any like template i can use?
with dust particle spawning you just grab a default particle, change its color and stuff and make it spawn
nothing too interesting going on with it
@misty ingot
either BLOCK_DUST or FALLING_DUST iirc
so i did particle and location, how what?
now you can change size and color using DustOptions class
ah yes the particle api
the worst thing to ever exist
you always have 0 clue what data particles take
tnt duping isnt disabled on spigot
block dust is the particle that shows when a block is broken, and falling dust is the sand and gravel particles falling i believe
how do you enable it
one of the files in config/
Is it possible to make protocollib stuff but just with nms (intercepting packets and changing them/packet events)
I don't wanna add a whole dependency just for one packet event tbh
how do I found out how many armor points a entity has? Like the health bar but the armor bar
nvm i found out
anyone knows how to spawn a particle line on all six sides of a block?
cuz i really couldnt find out
basically here everywhere
and ofc on the hidden sides too
math in a for loop
a bunch of maths i suppose
get the block coords...
calculate every point you want a particle, like x, y + (0 to 16), z
that would do the vertical line at one corner
maybe +/- I forget if the block position is top or bottom corner
you do that for each of the corners for x, y and z
simplest would be add them to a Set (no duplicates), then spawen your particles
how to get the center location of a block?
Isn't it all .5 ?
you don;t get the center, you get a corner
if you are still talking about particles
and how do i get a corner
but what corner?
try it and see ig
always the same
getting the block at 0,0,0 will be a corner
I believe bottom left
yes but wheres the corner?
oh
What particles are those btw ? (To support many many colours)
And thin (like a pixel )
redstone / dust
Nice, you can give colour to redstone dust particles ?
yes u can
That's amazing thank you
Wow.
Really maybe it's something commonly known but in all these years I didn't know.
It's one step closer to making 3d object holograms I guess.
PotionEffectType.HARM in minecraft is instant damage?
Although block displays (with player heads) will probably be even more interesting for that purpose of holograms
Thx
btw is this place also for other things besides logic?
I only regret the fact that Armor trims are data driven rather than nbt driven.
Would have loved to customize at least stuff like trim colour rgb from nbt rather than needing a datapack. I was expecting something like leather armour RGB customisation
Sure, you can ask design questions and about anything programming related really
leather armour has a colour tag already
and supports rgb
Precisely what I said yes: I regret that trims aren't as easily customizable
ah
For trims we can only play with a limited amount of colours (unless using a dp)
i thought the colour was resource pack
its more of a dependency question, here it goes..
ive added the repo and dependency thingy in my pom file (maven) for protocollib and runned it. do i need to do anything else? the spigot page of protocollib said i just needed to run it, but i can't seem to get it to work
hello world
i do get warnings about overlapping classes and resources
It's complicated but basically the trim thinggie inherit from data files which reference palette colours.
However there are a lot of paletted colours in the default palettes, otherwise adding a new palette would be texture pack I think yes
Make sure you add the <scope>provided</scope> tag to your
dependency so that is doesnt get shaded in. Then simply compile
using one of the maven lifecycles (pacage or install)
?paste
scope tag go outside <dependency> tag of what i want to add?
<dependencies>
...
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.25</version>
<scope>provided</scope>
</dependency>
...
</dependencies>
You should know this because Spigot needs this tag as well.
And one more thing:
When using maven - never add any jars to your project.
Not the spigot jar and not any other dependency.
If you have added artifacts then remove them right now.
i don't know if this matters but i have a plugin/extention/tool thingy in intellij that does the spigot things for me
is there a way to store just a string of data in an item in a menu without having to use nms for custom nbtTags?
You dont need to use nms for nbt tags for years now. There is a spigot api for this.
?pdc
how come no one ever talks about it then
do you have any idea how much time I have wasted
now I have even more sympathy for the poor hypixel devs who have to do shit in 1.8 💀
i think you can find that with a quick search, thats how i found it
we do
a lot
most people just know about it though
I need some brainstorming. What do you guys think is an elegant way of creating glowing boxes when
using the new display entities? I thought about simply using a block entity and applying a scaled transformation
on it. But the BARRIER block is not visible when rendered (the glow is hidden as well).
Let me know if you have an idea.
i would guess glass is your best bet with display entities, otherwise you would need math
Is there any way to break a loop using Bukkit.getScheduler.runTaskLater
Are you certain the glow doesn't show? I know it breaks when using shaders
so you want like a lightsource?
rip 1.13 support with PersistentDataHolder
I dont care about math
Ive tried using BARRIER blockstates instead. The glow didnt show up.
Otherwise ill probably add a custom ItemStack which has the same dimensions as a block when worn on the head.
Wait... that sparks an idea
I could use an Item display with a barrier item and render it as if it was on a players head
Let me try that
ist player.spigot().sendMessage(); deprecated?
not in Spigot it's not
i want to send the player a message in the action bar
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.RED.toString() + "#############################")); is this correct?
Yeah thats not what i expected...
just use like 6 item displays per thing
pretty sure it will get really laggy after a while
Yeah, no. Ill use one display and apply a transformation on it. Just need to find the right approach.
they only start to lag my pc whent heres around 1000 of them
less laggy than armourstands
are you telling me that Mojang is optimizing their game?
I havent even opened 1.19.4 so i didnt know that
no item displays for you
is this cancel(); going to cancel the public void run() ? (I want that)
- Use a for loop
is it going to cancel the bukkit runnable or not is my question
It is going to cancel the outer class
So the BukkitRunnable of which run method you are in currently
wouldnt you need to task.cancel to cancel the task
bruh
Yeah. Just dont use lambdas for this.
There is way too much logic happening for a lambda to be viable
And please: Use a for loop that increments in 5er steps.
If you have to copy/paste any code, then you should stop right
away and think about how to prevent this
and how do u like draw a particle line?
there is no line particle
you draw individual particles
at whatever step you want
You create a vector and add small steps in a for loop.
On each step you spawn a particle.
alr
i wonder if its just worth shading jda
so weird again
it can find Material.RAW_FISH fine when i type it in, when i compile. nope
any1 know what could be causing this
invalidate caches and restart
i did
for some reason it also puts 1.13.1 in my libraries when its not even in my pom
wrong dependency order
Put your spigot dependency first
Some other dependency is providing an old version of spigot
Vault being vault again
its probably because the fsh has no eyes
what was the issue?
what is the name of the spigot thread where it teaches you how to fill blocks very efficiently?
Its possible to make a plugin communicate with another plugin in the same server?
sure
you just add it to your classpath, e.g. by adding the other plugin to your pom.xml
I mean like you send a message to it
Dynamically
?xy
Asking about your attempted solution rather than your actual problem
You are not understanding plugins
I now realized how much stupid i am
?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 see where the confusion might come from.
In spigot every plugin has a common classpath.
This means you can simply call methods of other plugins
as long as they exist on runtime.
Communication is usually done through apis. One common
component are events. You can simply fire custom events in your
own plugin and others can listen to them.
Other than that you just call methods of other plugins
Item#getItemStack return clone of itemstack?
idk why it would
Because generally stuff in spigot with setters means the getter returns a clone
can you cancel a block breaking sound somehow?
Someone had a forum about handling hard threads does anyone have spigot link
What is a "hard thread" even supposed to be?
You have it i remembered
// lore
List<String> loreList = plugin.items.getStringList(ymlPath + ".item_lore");
ArrayList<String> lore = new ArrayList<>();
for (String line : loreList) {
lore.add(line.replace("&", "§"));
}
lore.add(" ");
List<String> sellLore = plugin.lang.getStringList("item-sell-lore");
for (String line: sellLore) {
lore.add(line
.replace("&", "§")
.replace("{amount}", String.valueOf(plugin.items.getInt(ymlPath + ".sell_price")))
.replace("{currency}", plugin.currencyName)
.replace("{amount}", String.valueOf(getPlayerItemAmount(player, itemForSale)))
);
}
itemMeta.setLore(lore);
the upper foreach works and adds the lore (it appears on the item)
but all the lore added from the lower foreach loop just does not want to be shown on the item
I got this one
And this for async workloads
Ah thanks
whats in sellLore anyways?
heres sellLore and loreList
one works, other doesnt
both are the same
neither makes sense
?
and you can confirm that is does enter the for loop?
that's client side
rip
Cancel break event. Set block to air, drop the droplist.
Pretty sure the client will still play it
only 1 way to know
but I think the sound will still be played, I don't think the servers sends a packet telling the client if they broke or not the block
some weird idea but hear me out:
every item can have a custom skin with a custom model data value right? every item can be a 3D object of technically any size and have 1 stateless animation, for example wynncrafts weapons are usually 3D animated. now if i wanna make a custom mob i can put such an item skin on its head right and have this be the model of my mob which i make permanently invisible. now based on the state of the mob i can change the head items custom model data to represent a different animation right? as such use the custom model data mechanic to have custom mob skins?
that's partially how mythic mobs works iirc
iirc it works with an armorstand per limb which can cause distored modells
on high lag
thats a new mechanic right?
to allow players to summon a dummy entity without native behavior?,
as such nothing has to be overriden?
why does the entity not shoot the fireballs towards the player?
https://paste.md-5.net/uhinixebul.cpp
that doesnt answear my question
It's redundant
It would help if you add some debugging
Souts to check ifs or whatever
?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.
for 79 tyicks you are looping over all players in a 30x30x30 area around yoru entity and adding them to a List. Lists allow duplicates but you only ever use the first one added.
bro i literally described what is not working
bro stop with the attitude, you do it daily
and you send ?learnjava to every person
is it possible to convert .schem files into .nbt files?
they compress data in a different way afaik
gzip for both
unless they've changed it when they've renamed them to .schem from .schematic
- don't call me bro, I'm not your pal, buddy
- I didn't see you explaining what is not working except that you said it doesn't work
and I only send ?learnjava to people who I think would benefit from reading those tutorials
that was a message to ElgarL
sorry
ah ok
I very rarely send learnjava to anyone
I haven't worked with fireballs but I remember them being very picky about their internal yaw and pitch
you can set their velocity to something but they'll trail back
and I dont know how "doesnt work" is similar to "entity doesnt shoot fireballs to the player"
yeah anyway, what's wrong with your current code? what happens to the arrows, if not launched at players?
are they going in the wrong direction?
do they not spawn at all?
etc etc
found that vid
just saying "it doesnt work" is useless. you have to tell us what is actually happening