#help-development
1 messages · Page 2013 of 1
Express doesnt matter, just i want to know, what request type does maven when deploying PUT or POST?
I've done the research
I am confused on the step after settings.xml
Like, what do I do in my project
bruh
you can bruh me all you want
I've been there, I've been on every open source bukkit plugin I can think of (WorldEdit, EssentialsX, PlaceHolderAPI, ProtocolLib, etc), I've been on github docs, I've been on stack overflow, I've been googling since noon.
Wait you're trying to deploy a maven project right?
Becides, that page you sent me isn't applicable because my project is in gradle, which is partially why I am having trouble.
Yknow, I love it when shockbyte scams me.
They suspended my server after a day for late payments.
I bought the server YESTERDAY for 50% off, and its A MONTHY SERVER
How???
Sounds like something you should take up with their support
I already have, this is bullshit.
If they are going to scam me I want a refund lmfao
Considering thousands use their service
Then I don't exactly understand your issue
Take this for example.
plugins {
`maven-publish` apply false
}
// Some subprojects shouldn't be published, how does this work? How does it select modules?
subprojects {
apply(plugin = "maven-publish")
configure<PublishingExtension> {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") // It wants me to replace this with my token, but I need to publish this to github, so people will see it
}
}
}
publications {
register<MavenPublication>("gpr") {
from(components["java"])
}
}
}
}
I also can't just copy and paste this into my build.gradle.kts file, else I get this weird lock error that people used to have 4 years ago.
java.lang.IllegalArgumentException: org.gradle.api.internal.initialization.DefaultClassLoaderScope@5f1e212a must be locked before it can be used to compute a classpath!
I am confused because on maven it looks to be pretty straightforward
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
</repository>
</distributionManagement>
still need help with this, thanks
At least do you have 1 player online?
yes
found out the problem, adding public static to completablefuture fixed it, thanks for your help @sterile token
Caused by: java.lang.IndexOutOfBoundsException: Index 2 out of bounds for length 2
if (crate.getItemList().get(pos) != null) {
Any reason why this errors?
getItemList returns a list btw
It errors at pos 2 cause there is no 2 in the list
Well you have your answer
but how do i stop the error itself lol
is what i meant
ive tried checking if .size <= pos
and such like that
doesnt seem to work
It should
it doesnt for some reason
If pos is 2 and size is 2, you will get an error
oh i see a fix then
ik it says dont report but its a minecraft thread... any idea what causes this?
a lot of people here use paper so thats why i asked but ight
@young knoll Now the error is index 3 out of bounds for length 2
if (crate.getItemList().size() < pos) {
if(crate.getItemList().get(pos) != null){
first line
Simple, you just tried to get element that doesn't exists
You need <=
it errors 2 - 2 then
You cannot get element 2 in a list with size 2
any way to prevent the error?
Then you need <= size - 1
Also you need to set pos - 1 since size/ length starts from 1 while getters from 0
And that should fix it
pos starts at 0
automatically
.size starts at 1
Just do pos - 1 in the second line
It will fix it
Oh wait-
I just read the first line
The first line doesn't have sense at all
how?
Since it will only return problems if you have number above the size of the list
all it is, is an ArrayList
public ArrayList getItemList(){
return this.itemList;
}
Wait, let me get on computers
Oh that isn’t an early return
You want to use >
The list must be longer than the index you are trying to access
what
im trying to get an object from pos
how would crate.getItemList().size() > pos help
thats basically saying only if its above the size
ill try it
if (crate.getItemList().size() < pos) {
return;
}
Object object = crate.getItemList().get(pos);
if(object == null) {
return;
}
You can use this ^^
thats the same thing
Yes early return is usually better
which works with your current way
but returning
Less messy
eh ok
ill try that after
@young knoll I REFUSE TO BELIEVE YOUR METHOD WORKED
WHY???
what
that makes 0 sense why it needed to be >
Simple logic
Index must be less than the size of the list
Otherwise
It is outside the list
And throws said error
// crate.getItemList().size() is a size of a provided before by a getter array list, while pos is a integer number
// if you want to access the item from the arraylist it has to be in the bounds of it
// but since you are trying to access a list that is < (smaller) than the position
// it will always throw an exception
if (crate.getItemList().size() < pos) {
if(crate.getItemList().get(pos) != null){
example: size of the arraylist is 5 and the pos is 6, logically it won't work but in your code you will allow it to go through because 5 < 6 and later on within the code you will try to get a element from a list which object doesn't exists
ohhh
well, at least i converted my stuff
so now, it runs on OOP instead of config.yml
CrateInfo basicCrate = CrateInfo.newCrate("basicCrate", ChatColor.GREEN + "Basic Crate");
CrateItems tntBasic = CrateItems.newCrateItem("tntBasic", new ItemStack(Material.TNT, 16), 15);
basicCrate.addItemToList("tntBasic");
CrateItems diamondBasic = CrateItems.newCrateItem("diamondBasic", new ItemStack(Material.DIAMOND, 2), 2);
basicCrate.addItemToList("diamondBasic");
more efficent and less lines
pog
its not public so
only i really need to configure it
so ill just edit the script whenever
i want to add changes
and /reload plugins
shockbyte reenabled my server
Go to console, op <username>
they made an oopsie
wrong channel dude
op arachnotfound
^^^
probably a troll lmfao
that or some kid who doesnt know what they are doing

im not in the mood to argue with kids
You’ve literally asked “why plugin not work”
And now you don’t know what a plugin is
🤦
Damn
Eyyy!
Tragic
what
Trol ls
100% a troll
@young knoll should i make it so my gui gets bigger as there is more available items to obtain from a crate
ex: if it exceeds 14 it becomes 1 more bigger
and so on and so forth
this is what it looks like rn
for viewing the items a crate gives
chance based, by weight
I do like resizing GUIs
But you could also just go the simple route and always use the biggest one
simple or complex
i like overcomplicating things
so xd
Making guis is pretty simple they are scaled super easily
What I love about em
I love working with minecraft guis
Yeah it’s just simple math
@young knoll heres my final product for crates btw
If I have a GUI class (containing an inventory), how do I get access to that inventory in another class?
You mean to open it from another class?
Yeah
I have to call openInv in another class
et
*ect
if so, how do I make it so it only detects customInventories (like custom uis)
Player#openInventory(new Your inventory());
Opening
Opening since you can change your keybinds
Well then, how do I make it only detect custom inventories/guis?
Like, ones made by a plugin
How does it work?
Let me give you-
public class SpawnGUI implements Listener {
private final Inventory inv;
public SpawnGUI() {
inv = Bukkit.createInventory(null, 9, "Spawns");
initializeItems();
}
So if this is the inventory class (i j cut out the long part)
And this is my listener in the other class:
@EventHandler
public void onRightClick(PlayerInteractAtEntityEvent e) {
Player p = e.getPlayer();
if (e.getRightClicked().getType() == EntityType.ARMOR_STAND) {
p.openInventory(new );
}
}
Then i'm j supposed to do p.openinventory(new SpawnGUI()) or?
@tardy flame
And the holder itself is just an empty
Please do not abuse inventory holder this way
First you need to create a getter for your inventory so you can use it. Then you can use new SpawnGui().get inventory or whatever you call the getter
That's not abuse
Ehhh, for now ig its fine idrc
No it’s not
Joking
Use the view returned from openInventory
Using the view is even more stupid
No it’s not
That’s the recommended way to identify custom inventories
Or just use the inventory instance itself
Wait can you Access the view from the inventory events?
Yes
Oh-
InventoryEvent.getView
Alr, didn't know about that one
My events are not working, i cancelled InventoryDragEvent and tp'ed a player on a certain item click, but none of it is working. Here is my code:
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
if (!e.getInventory().equals(inv)) return;
e.setCancelled(true);
final ItemStack clickedItem = e.getCurrentItem();
if (clickedItem == null || clickedItem.getType().isAir()) return;
final Player p = (Player) e.getWhoClicked();
if (clickedItem.getType() == Material.BEACON) {
Location loc = new Location(Bukkit.getWorld("world"), 139.5, 8.0, 75.5, 180, 0);
p.teleport(loc);
new Beast().giveKit(p);
}
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e){
if (e.getInventory().equals(inv)) {
e.setCancelled(true);
}
}
(And yes i registered the class lol)
What is the inv variable you are using?
It's the inventory that i got from my inv class
From the class i showed u earlier
Inventory inv = new SpawnGUI().getInv();
Compare the inventory views as @young knoll said
Never worked with inv views before, I don't really know anything about it
I j don't get why the events r not getting triggered
Like even if i remove the if statement and just cancel the event its not getting cancelled
I can still drag everything
You got the annotation and the events registered
Yup
package me.emerald.emeraldsplugin.data;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
public class Items {
static HashMap<String, ItemStack> itemList = new HashMap<>();
public Items(String locName, ItemStack item){
itemList.put(locName, item);
}
public static HashMap<String, ItemStack> getAllItems(){
return itemList;
}
public static ItemStack getItem(String locName){
return itemList.get(locName);
}
public static Items newItem(String locName, ItemStack item){
return new Items(locName,item);
}
}
OOP my beloved
how do I make it so that InventoryOpenEvent only runs if its a custom ui
not a chest or anything
but a java generated one
Inventory inv = new SpawnGUI().getInv();
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
if (e.getInventory().equals(inv)) {
if (e.getCurrentItem().getType() == Material.BEACON) {
Location main = new Location(Bukkit.getWorld("world"), 139.5, 8.0, 75.5, 180, 0);
Player p = (Player) e.getWhoClicked();
p.teleport(main);
new Beast().giveKit(p);
return;
}
e.setCancelled(true);
}
}
As soon as I add ```java
if (e.getInventory().equals(inv)) {}
I'm trying to cancel the event in a certain inventory called inv (from the SpawnGUI class) but It doesn't seem like it's actually getting the inv
It will always run whenever any inventory is opened, just check if it's an instance of yours before doing anything with the event.
Try getClickedInventory
nope i can still drag everything
And as soon as I remove that line everything works perfectly fine
It's like it's not actually getting the inventory or smth
Hmm well the clicked inventory should be equal
I think the general inventory includes the top and bottom, which will not equal your custom inventory
Yeah
if ive got it right pdc does exactly that, store custom data into objects utilizing nms, but not modfying actual stat values?
so just classic wrapper api round vanillas nms?
hehe top bottom
yea
Dangit maow
@young knoll figured it out btw, converted all my inventory scripts to handle InventoryHolder, and turned them into OOP's and made each of them owned by said OOPS
then, compaired the holder to the instance of said OOP
to check if its the correct ui
without using its name
therefor, if somebody were to rename a chest the exact same name, to attempt to do stuff ur not suppost to
it would not work
protection
---
}```
I want to autorun command behalf of player, if he hasnt joined before. how do i do it?
I want players to auto run /st play firstjoin
player.performCommand("st play firstjoin");
}```
this will work?
Abuse of inventory holder, but I suppose it could be worse
Also what the heck is “an OOP”
object oriented programming
turned them into OOP's and made each of them owned by said OOPS
then, compaired the holder to the instance of said OOP
This makes no sense.
You can’t have “an object oriented programming”
ill rephrase it
ah
Do you mean "I turned them into objects"?
thanks
I turned each of them into its own holder, in which afterwards, made the ui itself owned by said holder.
Then, in the InvClickEvent, compaired the guis holder to an intanceof said holder (Kinda confusing ill show code if I have to)
Example:
if(holder instanceof Challenges) {
public class Challenges implements InventoryHolder {
private static Inventory gui;
public Challenges() {
gui = Bukkit.createInventory(this, 9*5, ChatColor.DARK_RED + "Challenges");
i didnt really see another way of doing it
I did try it, kinda bypassable
oh then I did it wrong lol
having a static invetory instance itself its a pretty bad idea
cause when I did it chests where not allowing items to be taken out of them
Take view from openInventory
Add view to hashset
Check if the view from an inventory event is in said hashset
please... don't compare booleans to booleans
And remove it from the hashset on inventory close
fixing
huh
Yes, I did this public class FirstJoin implements Listener { @EventHandler public void playerJoin(PlayerJoinEvent event){ Player player = (Player) event; if(!(player.hasPlayedBefore())){ player.performCommand("st play firstjoin"); }
fixed it lol
it doesnt revolve around that now
yeah, something like if(player.hasPlayedBefore() == (1 - 1 == 2)) is much better
Instead of doing this:
if (player.hasPlayedBefore() == false) {
Do this:
if (!player.hasPlayedBefore()) {
yes indeed
👀
im sorry is it just me or did i have a stroke reading this
He was joking.
ik lol
however i prefer !!!!!true
wait you can spam "!"?
yeah it just inverts the boolean
so !!true is true
i finally can use a million exclamation points in my code
Don't teach him bad things.
because not not true
pog
is not false, which is true
iirc ! in boolean algebra is just |1-x|
its a mess
You know, the thing that pisses me off more than anything else you have written there is the inconsistent use of spaces before and after your curly braces and parenthesis.
oh god i just saw that
thats starting to piss me off as well
well NOW i kinda wanna redo this entire thing now
damnit
honestly could be worse
if(block.getType() == Material.CHEST){TileState state = (TileState) block.getState();
Oh god, you typed a statement after a curly brace on the same line. I'm dead.
And this is why we have auto format
I can press 3 buttons and all my problems go away
Or just have it auto-format whenever you save the file.
auto format
does it with a ton of my code
have 0 idea how to disable that
id NEVER do that normally
cause it looks ugly in my opinion
and can be confusing
hey so im trying to make a custom crafting recipe using custom items in the recipe but so far I only managed to have 1 custom item, so does anyone know how i can add this item multiple times lets say filling the top row?
`package me.igloo4life.test123.more;
import me.igloo4life.test123.Test123;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
public class ItemManager implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
e.getPlayer().getInventory().addItem(Test123.customItem);
}
@EventHandler
public void onPlayerCraftItem(PrepareItemCraftEvent e) {
if (e.getInventory().getMatrix().length < 9) {
return;
}
checkCraft(new ItemStack(Material.NETHERITE_SWORD),e.getInventory(), new HashMap<Integer, ItemStack>(){{
put(1, Test123.customItem);
}});
}
public void checkCraft(ItemStack result, CraftingInventory inv, HashMap<Integer, ItemStack> ingredients) {
ItemStack[] matrix = inv.getMatrix();
for(int i = 0; i < 9; i++) {
if (ingredients.containsKey(i)) {
if (matrix[i] == null || !matrix[i].equals(ingredients.get(i))) {
return;
}
} else {
if(matrix[i] != null){
return;
}
}
}
inv.setResult(result);
}
}`
just use the Recipe api
You do know RecipeChoice.ExactChoice exists
ExactChoice
speaking of recipes, ive never worked with that
- does not work on shapeless recipes
Sure
yeah definitely
cool
Hell you can do that with a datapack
No, they're packs of data obviously.
that was a joke
As was mine.
yknow how many times ive heard ppl say that
I mean they are quite powerful these days
But they fall behind plugins in performance
yes but you're probably not gonna use them on a proper public server
the order in my opinion:
Mods > Plugins > Datapacks > Addons (bedrock)
ive made addons before
so many limitations
its not even funny
Mods should not be #1
I use a few
Small ones that just mess with loot tables are great
They seem powerful and preformance wise ok
Or recipes or whatnot
Im just basing it off those 2 lol
Mods are the most powerful
If we are talking like, favorites here
Plugins < Mods < I hate datapacks and addons
Data packs are fine
i just dislike the concept thats all
Don’t know why you would hate them
they are cool n all
but the whole thing around them is kinda bad
like i said: its just a singleplayer world plugin
Meh
Plugins are far more performant, and the main reason mods more powerful is because you can modify the client, but in doing so, you prevent your server from being connected to by anyone with a vanilla client, so it is as much a limitation as it is a freedom.
ehhh fair
A datapack to change recipes or loot tables is exactly as performant as a plugin
well if we are going to test preformace
why not do a lag test?
see which one crashes/gets too laggy first or whatever
and last
to see which is more powerful and preformant
In my scenario, neither
Compare a forge server with no mods to a paper server with no plugins. The difference is observable even without any players on.
Okay fair point
Cause ive done both before
i used to use aternos ok
dont judge
Mods and plugins are equally performant
try using a minimap mod
and come back
:troll:
oof
Both mods and plugins are interfacing directly with java, there is nothing to make one run better than the other
Except yknow, code quality
If I were to try and join an IRLCraft modded server, I'd have to launch a modded client first, which, on my computer, takes maybe 10 minutes, no joke. That's on top of the time it takes for the server to start up.
With plugins, the client can connect to the server immediately.
I'm taking this into consideration.
But justin, this is assuming the client is being edited by the mod.
IF the mod does NOT use any client editing whatsoever
it will connect to the server nearly instantly
Moreover, there is a significant difference in the servers themselves.
Hosting a server with 100+ players on paper is easily achievable, even with tons of plugins.
Not so for a forge server, even without any mods.
Plugins/mods are limited by the server they're interfacing with, so even if the plugins/mods themselves are very similar in performance, if the API they're interfacing with isn't, then they can't be either.
Yes but that isn’t to do with a different in performance between mods and plugins
Unless you're talking about modding by directly patching NMS, rather than using something like forge.
It’s to do with a difference between paper and forge
Its 2am where I am, I think ive coded enough today.
Im tired, gn everyone.
Have fun with your convo lol
Technically mods should perform slightly faster in some cases, as they don’t have the overhead of the Bukkit API
The reality is that 99%+ of people making a plugin will be interfacing with bukkit/spigpt/paper, and if they're making a mod, they'll be interfacing with forge.
But it’s a very small overhead
Then again, I've never actually made a mod before. So what do I know.
Just what I've heard second hand.
fabric
and fabric is even faster
since it just goes
take code from method
put it in method you are injecting into
there's also the FAPI but thats that
way more data to save now
It's just spigot being spigot
I had similar issues back in early 1.17 when it took 5 minutes or so to save
Anyone know why Spigot stopped loading/unloading chunks async?
Spigot never did that
?paste
@young knoll Chunks generate on the main thread since 1.13 iirc.
Chunk generation is multithreaded in modern minecraft
Ah, apparently that was added in 1.15
Mhm
I can never keep up with these things.
so that server thinks I'm joining for the first time
Delete your player.dat file in world/playerdata
didnt work, thats why
It does work
That’s where your player data is
Don’t do it while the server is running
nah I restarted it
if it was working then, my code would work
to autoperform command when player joins for the first time
Then just remove the entire world
tried
Then your code is faulty
public void playerJoin(PlayerJoinEvent event){
Player player = (Player) event.getPlayer();
if(!(player.hasPlayedBefore())){
player.sendMessage("working");
player.performCommand("st play firstjoin");
}
}```
I added message
lets see if it sends it
oh wait it worked now nvm
why are you casting a player
to a player
you know event.getPlayer() returns a player right?
Sorry mb, fixed it
also you don't need to wrap player.hasPlayedBefore() in ()
you can just do
!player.hasPlayedBefore()
also to run the command i suggest doing Bukkit.dispatchCommand(player, command);
or it was Bukkit.getServer().dispatchCommand
Shouldn’t really make a difference
i mean they can try
Does InventoryMoveItemEvent fire when shift clicking into an inventory?
nope
what then?
that's only for hoppers
it says for entities
uh iirc its InventoryClickEvent
ah
Well say I have an inventory opened for a player and want to prevent them from shift clicking an item into that inventory, but still be able to interact with their own items, do I check for the InventoryAction MOVE_TO_OTHER_INVENTORY and SWAP_ITEM_WITH_CURSOR?
BukkitTask runnable = new BukkitRunnable() {
@Override
public void run() {
for (Player v : Bukkit.getOnlinePlayers()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "money give" + v.getName() + " 1500");
}
}
}.runTaskTimer(Main.getInstance(), 20, 3600);
}``` how can i provide this to throw the command for per 1 second
replace 3600 with 20?
its not throwing the code somehow
^^
"throwing" code?
executing it i reckon
triggering i mean
did you actually ever create any PayMoney instance?
still not triggering
on main method?
anywhere
i did but still not triggering
show your full PayMoney class and the code where you are creating an instance
public void payTheMoney() {
BukkitTask runnable = new BukkitRunnable() {
@Override
public void run() {
for (Player v : Bukkit.getOnlinePlayers()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "money give" + v.getName() + " 1500");
}
}
}.runTaskTimer(Main.getInstance(), 20, 20);
}
}``` PayMoney
public static Plugin plugin;
@Override
public void onEnable() {
plugin = this;
getServer().getPluginManager().registerEvents(new Die(), this);
getCommand("healme").setExecutor(new HealMe());
getCommand("doktorcagir").setExecutor(new DoktorCagir());
PayMoney payMoney = new PayMoney();
}
public static Plugin getInstance() {
return plugin;
}
}``` main
cant we make run() method static?
and call it by PayMoney.run()
how to get the actual text component of the asyncchatevent?
AsyncChatEvent is a paper event
there are no text components involved in the playerchatevent
ew paper api
that is literally the .message() output form AsyncChatEvent ._.
Talk to paper
And I want that content="t" out of it
.
,...
What
?jd-bc
ty
how can i control if player quitted after doing an event
?
public void onDie(PlayerDeathEvent e) {
p = e.getEntity();
if(p.isDead()) {
p.setWalkSpeed(0);
p.setHealth(0.5F);
p.sendTitle("Oldun", "/healme komudunu kullan veya doktor bekle");
}
}``` i have this
what do you want to "control"
if(p.quit) smth like that
you cannot control whether a player quit
yeah just removed
it's not like you can prevent them from quitting or sth lol
PlayerQuitEvent
Use the quit event to detect them leaving
Hello there, i'm making a plugin with a lot of functionality but one of them made me doubting about one things : I want to make a npc who can upgrade items by trading money, what plugin can i use for manage the money ?
'kay thanks !
hmm @EventHandler public void onQuit(PlayerQuitEvent e) { p = e.getPlayer(); if(p instanceof Player) { p.setHealth(0.5F); p.sendTitle("Oldun", "/healme komudunu kullan veya doktor bekle"); p.setWalkSpeed(0); } } made it like this
p is a Player class i made, im using that p in 3 event(PlayerMoveEvent, PlayerDeathEvent, and noew PlayerQuitEvent)
before i added quitevent when player quits and rejoins he can be able to jump and run
after adding this it blocked running but not jumping
everything about that doesnt make sense
why
first of all, why are you checking if the player is a Player? second, what even is your goal? why are you setting the health, walkspeed and sending a title on quit? the player won't even notice the changes
and if i understood that right, you wanna set those values to factory once the player rejoined?
yes
so just dont fuck with the values and they will stay the same 🤔
i just copied the values on deathevent, i removed them

they are not
does the player take damage while being offline?
no
public static void sendPartlyClickableCmd(Player player, String message, String clickableMessage, String command, String hoverText) {
TextComponent component = new TextComponent(TextComponent.fromLegacyText(clickableMessage));
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + command));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create()));
player.spigot().sendMessage(ChatMessageType.valueOf(message + component));
}
Bug is in line 7 but no idea how to fix it
which line is line 7
???
probably the 7th one lol. player.spigot()
evidently
?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.
cbf counting the lines
cant paste it
?paste
might as well just send which line is 7 lmao
btw
this wont work
setHealth
????
ur setting a 0 hp player to 0.5?
that wont revive them
as they alr died
theyre on the death screen atm
respawning on another event
Use the damage event to stop death
is your class balancecommand?
bunch of situations, its not working
do you have any idea what enums are and what Enum#valueOf does?
you basically do ChatMessageType.valueOf(SomeTextComponent)
that makes no sense at all
It does work
so?
so you get an error
Yeah valueOf needs an exact match
thats the reason why im here right?
tried much
yeah
just do spigot().sendMessage(message + component)
heres the solution:
So material.valueOf(“DIAMOND”) is valid
?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.
error?
you cant Stringadd and String with an component
You can’t combine components with +
^
yes
What event gets called when you use a shield
ComponentBuilder allows you to append them
Interact
enums are constantss
then why are you using Enum#valueOf(TextComponent.toString)
so when you create the component, add the message there?
Ah thanks
because it was the quick fix and i have no idea how to fix it in fact there is not solution in the web
there is no ChatMessageType with the name "Das ist nicht clickablleTextComponent{text=, BaseComponent(color=ºf, font=null, bold=null, italic=null, underlined=null, strikethrough=null, obfuscated=null, insertion=null, extra=[TextComponent{text=ABER DAS, BaseComponent(color=º6, font=null, bold=true, italic=null, underlined=null, strikethrough=null, obfuscated=null, insertion=null, extra=null, clickEvent=null, hoverEvent=null)}], clickEvent=ClickEvent(action=RUN_COMMAND, value=/jesus), hoverEvent=HoverEvent(action=SHOW_TEXT, contents=[Text(value=[Lnet.md_5.bungee.api.chat.BaseComponent;@5e223e19)], legacy=true))"
what do u wanna do @dapper ether
partly clickable text message
ah
player.spigot().sendMessage(TextComponent) ?
then its clickable
And append them
use the ComponentBuilder
ye
didnt find any example for it
2 components, one clickable one not, then use component builder to append
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
this is my udpatechecker, somewhere in there you'll find some code that sends a message with several different clickable links https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker
Thanks for that it work perfectly c:
Did you move your update checker away from legacy yet :p
I haven't found ANY documentation about the spigot web API
so no but it supports spiget and other API sources too
I sent you the GitHub link for it
where?
ah thx, I'll add it sometime
I wonder how did you find that lol
I don’t remember
I remember trying very hard to google “spigot new update API” and stuff
But your update checker just kept popping up
Do Shields also have a persistent data container? I have an Issue where it just doesn't get carried over? Just making sure I'm not overlooking something
Okay just making sure I'm sane
How do i close my ticket?
ok this is some serious bullshit right here
I am listening for InventoryClickEvent
If the inventory is in a specific list and the action performed is MOVE_TO_OTHER_INVENTORY then it prints 3 in chat and cancels the event
Some other code much further down the line closes the inventory
If it now prints 3 in chat, why the hell does it not cancel the event and the item i shift clicked lands in my inventory?!?
send code?
public static void inventoryClick(InventoryClickEvent e) {
Inventory inv = e.getClickedInventory();
Inventory top = e.getWhoClicked().getOpenInventory().getTopInventory();
Bukkit.getServer().broadcastMessage("1");
if (e.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) || e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)) {
Bukkit.getServer().broadcastMessage("2");
if (shops.containsKey(top) || owners.containsKey(top) || admins.containsKey(top) || ownersItems.containsKey(top)) {
Bukkit.getServer().broadcastMessage("3");
e.setCancelled(true);
}
}
Further down:
e.setCancelled(true);
owners.remove(inv);
e.getWhoClicked().closeInventory();
its printing 3?
broadcasting "3", as debug msg
i hate dependencies
yes
sec
yup
printed 4
also it is not a ghost item, I reconnected and it persisted
does it make a difference?
alright, thanks anyways
cant help u sorry mate
Don't make your events static
u got any idea why thats happening?
yeah changed that
mightve misremembered
but i dont get why it doesnt cancel properly
yes, everything works fine except that specific cancelling
the gui is perfectly interactable and it cancels when I normally click or shift click, but not if it also closes the GUI in the same code execution
and yes, it does cancel before it closes the gui
some forum post says creative mode has a bug with the event'
well in survival it only produces ghost items now
but works
wtffff
thats so stupid
yeah
i just googled "spigot inventory click event not cancelling" ahaha
;-;
why you do me like that
i thought there would be common sense in spigot ;-;
xD
lib ideas
right so I'm having this issue with placeholderapi where after /papi reload is ran my placeholders dont work but stay registered and im not sure how to fix that
quick thing, what's minecraft specific world generation algorithm
That's not really a quick thing.
i hoped it was xD
is this the proper way of reloading a config?
you don't need to set new instance
otherwise yes
well it dont work
the value is not updating if i read it from the config after editing and saving it externally and executing that code then reading
Minecraft uses various seeds and algorithms for generating various layers of their world generation, such as the world height, caves, resources, topography, structures, etc.
it only works with the getConfig() after reloadConfig()
oh yeah
but doesnt that make sense too?
you're storing it...
yea
why exactly?
because i dont want to constantly read it?
should still have a mild performance difference shouldnt it?
no
Definitely not
alr but i am too lazy now soooo
you might loose 1ns of speed
I doubt even that much
There's nothing wrong with using a getter.
You don't have to create an additional field for storing every object you use.
You'll just create unnecessary clutter.
dumb basic java question incoming: if i pass a class as function parameter, do i pass an object or a reference pointer?
given the abstraction a getter provides over a mere field, the negligible difference is even more negligible if anything
like on the technical level
well in Java objects are considered values, and variables are references, Java doesn't have much about pointers in and out, you will always be passing values to function paarameters
no
a class is not an object
but for instance
Object o = new Object();
void a(Object a) {
}
a(o)
here you pass the variable as an actual parameter to the function
Player p = ...;
p.setHealth(0.00);
// now can i use p? or do i have to update the variable, or is it automatically update?
but only the object from o will get passed down
p is invalidated on logout
as opposed to some languages which allows you to pass a reference as a whole, java does not have that
hm+
so whilst a player is online, you can use p
so if i pass a local instance to a function, the function works with the same instance?
but sure, objects in a deeper context are just references, but in Java we rarely treat objects as references, instead just values
local instance?
yes
?paste
void foo(Object obj)
{
obj.doSomething();
}
int main()
{
Object o = new Object();
foo(o);
}
then the function foo works with the same instance as in the main scope?
yep
kk
When is BlockExplodeEvent fired
Because it's not returning the actual list of blocks that were broken
Is it possible that (in paper.yml), optimize-explosions effects the block list
Hey, how can I get the name in a way like minecraft:sponge from a bukkit Material?
its very possible that could affect the block list, but it sounds like a bug, and if it concerns paper you better ask them than us
Material::getKey

i love the new key system though
no more remembering magic numbers or whatever it's called
Ok It does not effect it
in the end
BlockType cornerType = BlockType.REGISTRY.get(cornerMaterial.getKey().getKey());
did it but you saying about the key did help
hit em with da java getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { public void run() { String tmpText = "%marriage_isRegistered%"; tmpText = PlaceholderAPI.setPlaceholders(null, tmpText); if(!tmpText.equals("true")) { // random placeholder that always returns "true" getLogger().info("Re-registering..."); new myExpansion(plugin, core).register(); } } }, 0L, 20L); as a fix
oof lol
hey i made a thing like if a player dies, he cant run or jump. But when player quits and rejoins he can jump and run again how can i prevent this.
send code
store their uuid in a list and check it?
is your code player object?
They are an entirely new player object so you must use ur uuid
Then check on join if they are that player using the uuid
And do whatever you want to stop them
because when a player leaves and rejoins the Player object is changed
im making it by 1 player
PlayerList plist = new PlayerList();
Player p = plist.p;
```?
specified player
yes this is a specified player
but you do know that all your code is executed for every player?
you are changing the player walk speed and jump
but when they leave
the player object is null
And when they join back
it's an entirely new object
so what you could do is store a hashmap of <UUID, boolean>
And when they die, set the player's UUID to true
so when the player joins back
check if they are in the hashmap and if it is true set their walk speed and jump power
https://paste.md-5.net/yuzuhujavu.java d i make it right
ah
accidentally
how can i get player's uuid
player#getUniqueId
public class PlayerList {
HashMap<UUID, Boolean> diedPlayers = new HashMap<>();
Player p;
public void playerDie() {
diedPlayers.put(p.getUniqueId(), true);
}
public HashMap<UUID, Boolean> getDiedPlayer() {
return diedPlayers;
}
public void setDiedPlayers(HashMap<UUID, Boolean> diedPlayer) {
this.diedPlayers = diedPlayer;
}
}```
this makes zero sense
why
why do you have a player object
the way this currently looks, it only works for a single player per PlayerList instance?
Yes that's good
On player join event, check if the hashmap contains a key that is player uuid
If yes, check if that is true
And if it is set the player walk speed
instead of setting p at start
set p in every event
And then when the player joins
Hi! I make a BungeeCord plugin, and I get the version protocol number. Under 1.8, I got 738, but my version is 1.7.
set the p object in PlayerList to the new one
do 1.18 plugins still require jdk 8, not 17?
hey can someone help me fix this
WorldBorderCenterChangeEvent may only be triggered synchronously.
that is error from my plugin
Cannot pass event
bro it isnt setDied
setDead
why
u can make a Set
i fixed nvm I am just an idiot lol
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if(plist.getDiedPlayer().containsKey(0)) {
p.setHealth(0.5F);
p.setWalkSpeed(0);
}```
@earnest forum what u telling the guy bro
made hashset to check if a guy who joins is that guy
i dont know if i did right
u prob r using hashmap
Is this how to use schedulers properly or i have to type that code inside scheduler class?
import me.karlo292.testplugin.TestPlugin;
import me.karlo292.testplugin.schedulers.PlayerMoveScheduler;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scheduler.BukkitScheduler;
public class PlayerMoveListener implements Listener {
PlayerMoveScheduler scheduler = new PlayerMoveScheduler();
TestPlugin plugin;
@EventHandler
public void onMovement(PlayerMoveEvent e) {
Player player = e.getPlayer();
World world = player.getWorld();
Block block = player.getLocation().subtract(0, 1, 0).getBlock();
Material type = block.getType();
if(type != Material.GLOWSTONE && type != Material.AIR) {
block.setType(Material.GLOWSTONE);
scheduler.runTaskTimerAsynchronously(plugin, 4, 0);
block.setType(type);
}
}
}```
?paste
dont do that
for this usage, WAY better
no need for a hashmap just for a boolean value
Set<UUID> deadPlayers = new HashSet<>();
in your main class
making a class to store one variable is pointless
public class PlayerList {
HashSet<UUID> diedPlayers = new HashSet<>();
Player p;
public void playerDie() {
diedPlayers.add(p.getUniqueId());
}
public HashSet<UUID> getDiedPlayers() {
return diedPlayers;
}
public void setDiedPlayers(HashSet<UUID> diedPlayers) {
this.diedPlayers = diedPlayers;
}
public Player getP() {
return p;
}
public void setP(Player p) {
this.p = p;
}
}```
tbf yeah u r
Yes use hashset
ic
what is the point of p
ah forgot removing it
also do not obfuscate your code, each variable should describe what it does
PlayerList doesnt give any meaning to what that is
and p doesnt either
diedPlayers do though
however its deadPlayers not died lol
not a native speaker I'm pretty sure
im not either kek
if ur not comfortable with english then use google translator, or dont use english
although you will 100% need english for coding
especially spigot
everything
HashSet<UUID> deadPlayers = new HashSet<>();
public HashSet<UUID> getDiedPlayers() {
return deadPlayers;
}
public void setDeadPlayers(HashSet<UUID> diedPlayers) {
this.deadPlayers = diedPlayers;
}
}```
delete that class
have
HashSet<UUID> deadPlayers = new HashSet<>();
in your main class
a class for one variable is nonsense imo
ik this is probably rlly simple and im just dumb, but what do all these colors mean
they just suddenly appeared ¯_(ツ)_/¯
if i make it static on main i can access it with "Main.deadPlayers" right?
yea
i cant
any idea why when pushing multiple blocks or retracting one block it creates an invisible falling block https://paste.md-5.net/huhusutire.cs
why cant u
this seems to work when pushing straight up, just not sideways
no, never new Main()
public class Die implements Listener {
Main main = new Main();
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if(main.getDeadPlayers().contains(p)) {
p.setHealth(0.5F);
p.setWalkSpeed(0);
}
}``` is this right
no
why
never try to create a new instance of Main
Does spigot have a separate scheduler method for scheduling for a specific date and time or do I use ScheduledExecutorService ?
there is one instance and thats created by spigot
also slime blocks make invisible falling blocks of the blocks connected
then how can i access a hashmap
i tried Main.deadPlayers
SES
when you call new Die() you add a constructor so you can do new Die(plugin)
but I mean
a restart kills it, i know
any better ways?
isnt that ScheduledExecutorService ?
yep
ok ty
and if you wanna run on server thread, just callback it using BukkitScheduler
public class Die implements Listener {
HashSet<UUID> deadPlayers = new HashSet<>();
public HashSet<UUID> getDeadPlayers() {
return deadPlayers;
}
public void setDeadPlayers(HashSet<UUID> deadPlayers) {
this.deadPlayers = deadPlayers;
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if(deadPlayers.contains(p)) {
p.setHealth(0.5F);
p.setWalkSpeed(0);
}
}```
@grim ice
how do i check which part of an inventory is clicked in a InventoryClickEvent in a gui?
Or perhaps if it needs to run every day at midnight, whats the best thing there?
as in the opened gui and the player's inventory
persistent through restarts
real life days, of course
Challenger pretty much ScheduledExecutorService still
tho ofc you have to calculate the delay and stuff
hmmm ok
since it has a really sophisticated low level implementation for how it deals with tasks that are gonna run in the future as opposed to BukkitScheduler which just ticks in principle
and is not comparable to SES whatsoever regarding this implementation
ofc SES is an abstraction, but I assume you use the implementations Executors.java provides
not cursed at all
ProtocolLib, 1.18.x So i have destroyed player with
PacketContainer container = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
container.getIntLists().write(0, Collections.singletonList(target.getEntityId()));
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, container);
How I can show it back?
ProtocolLibrary.getProtocolManager().updateEntity(target, Collections.singletonList(observer));
``` This code is not working
Hello everyone
I have a question
How to make plugin create a config file I made in my project in advanced?
Example
- A project has a.yml with content
- If plugin loaded, there will be a.yml file in
plugins/Awith content
why is this always false? (InventoryClickEvent)
if (event.getClickedInventory().equals(null)) {
return;
}```
It will be null if you click outside the inventory window
but will throw a NPE
that's why i did it, but intelllij is saying that it will always be false* and when i click outside the gui, it sends an error
you shoudl also compare null with ==
it will always be false. if its null, it will throw a NPE since .equals cant be called on null
therefor we use == to compare null
thanks, it works now
You can check for slot, if you clicks outside of inventory it would be -999
is this for config.yml or for multiple ones
ah ok, thanks
Java spec demands that object.equals(null) always returns null iirc. Of course some implementations will throw an NPE instead
* <li>For any non-null reference value {@code x},
* {@code x.equals(null)} should return {@code false}.
whats the difference between material.snow and material.snow_block
snow is snow layer