#help-development
1 messages · Page 1815 of 1
the event method will never be manually invoked anywhere
so it says that its never used
You probably don’t have it registered.
nvm I fixed it
doesnt matter, its the method, not the class.
cipher
i always get this note
if (event.getTo().getBlockY() < 10) {
player.teleport(new Location(player.getWorld(), 1, 73, 0));
}```
Also, this returns: `Method invocation 'getBlockY' may produce 'NullPointerException'` Can I also just ignore it? It works fine while thats there
this is because getTo() can be null...
based in memory
@hybrid spoke only when you have @EventHandler its meant as an event
you probably know that but anyways
try making 2 methods
one with @EventHandler and one without
So I can just ignore it?
and look at the warnings
nope... better add a check for if getTo is != null and then make this
just use
if (event.getTo() != null && event.getTo().getBlockY() < 10) {
player.teleport(new Location(player.getWorld(), 1, 73, 0));
}```
this
thats not for me
settings dependent
im using default settings
could I also use requireNonNull?
no
oh
public static <T> T requireNonNull(T obj) {
if (obj == null)
throw new NullPointerException();
return obj;
}
it will just throw a npe
yes
i personally would uppercase item
ok
if (event.getPlayer().hasPermission("ringItem.excludeGameMode")) return;
wont give that typo thing
but im not sure if the conventions are correct
Doesnt matter
oh its a perm, then not
it works perfectly fine as is
thought of an identifier
ok then solved
why not make a mark as solved thing in this channel
so a bot says when the default #help-development thread is open for use
and if its not it says so
more organized tho
yes
#help-development is a thread
just the main one
#help-development is a channel 🤔
well we use this channel for help too
we only use threads if this channel is occupied dont we
why send people through the bother if its not occupied
it would be more organized imo
you could suggest it, but it will be declined for sure
what do you imagine? like a queue?
thanks but these don't really help me, so my question still remains:
does anyone know how to make simple world gen? all i want is simple perlin noise for the generation and the painting & craters on the ground
rough example of what i want (without craters)
Not getting any issues in the Project itself, however it still doesnt put the player into adventure.
Just survival
Only manually doing /minecraft:gamemode @a Adventure Seems to be able to put players into adventure
Here is my ENTIRE code btw
@slim cairn Maybe a permissions issue>
?
Other event is cancelling due to insufficient permissions perhaps?
I dont know
I can add the permission to players
So that part works
just the SetGamemode(GameMode.ADVENTURE) doesnt seem to work
Doesnt work here, doesnt work in server.properties
Survival & Creative & Spec do work
but as soon as I put it tto Adventure, it just forces the player into survival
So only manual changing works
trying to kick player on PlayerSpawnLocationEvent but it doesn't seem work. remote debugging showed it has entered the method. can someone help?
@EventHandler
public void onPlayerSpawnLocation(PlayerSpawnLocationEvent event) {
event.getPlayer().kickPlayer("Test");
}
Spawn as in joining the server?
or respawn
did you register the listener?
joining the world.
i've used a breakpoint to confirm that.
I think this should sort issues out
should I also like ping some OP users about it when they join because people don't look at their console?
or is it harassment
@grim ice Sorry for the ping
ye thats what I did
This is my whole code
make it
if (event.getPlayer().hasPermission("ringitem.excludegamemode")) return;
also does the player have OP or that permission?
k lemme try that
...?
nvm
okay...
try what i sent you then
what
Do you want to disable the plugin?
delay it by a tick and/or cancel the event before
As I assume many don't look at the console on why I want to leave it enabled and warn some operator about it I think
so loop through all online players
if they are op
send them a message
yes I know how to write this stuff
I have already done so
I was asking whether or not I should do it
i would, but adding an option to disable it
the plugin is completely disabled if on CB. If they want to surpress the message they shall uninstall it
otherwise you will lose inpatient server owners as user since they get annoyed by the "spam"
ah
then i would just broadcast it
Just log to console
At which time though? At server start there's nobody on the server. I'm thinking of PlayerJoinEvent with a check to isOp?
each tick lol, what did you thought?
The last person to use CB and my plugin just told me "it doesn't work". Probably didn't even check the console because it got spammed with exceptions.
Ah yeah, that sounds perfect!
i would just disable it at server start and log it once into console
if they wonder why the plugin is disabled, they will look up the console first
just mark it in big fat red
Does Logger.severe() not do that?
well apparently I can't if I still get CB users complaining eventho I put it on the resource page
that just forwards it
just puts it on stdcerr it seems
just install them spgiot then
let the plugin overtake the server for a second
I wonder if that's actually possible
it probably is
by putting some batch/shell script there
then close the server
and execute the script
which is?
public static boolean hasSent = false;
@EventHandler
public void onJoin(@NotNull PlayerJoinEvent event) {
if (event.getPlayer().isOp() && !hasSent) {
event.getPlayer().sendMessage("§c This plugin does not work on CraftBukkit servers, "
+ "as they are only meant for development purposes. Please use a Spigot server instead.");
hasSent = true;
}
}
I think this should be fine tho 👍
for what the hasSent? do you just want to sent it to the first op?
yeah
don't want to harass them too much I think
if they choose to ignore that too then what can I do
force op everyone and kick them as long as nobody reacts
How could I make blaze's fireballs explode?
likely you can listen to projectilehitevent
check if its a blazes projectile then make explosion at that location
It would be something like this?
@EventHandler
public void ExplosionPower(ProjectileLaunchEvent e) {
if (e.getEntity().getShooter() instanceof org.bukkit.entity.Blaze && e.getEntity() instanceof Fireball) {
Fireball fireball = (Fireball)e.getEntity();
fireball.setYield(5.0F);
}
}
}
yes that could work
however im not sure about the explosion part for the fireball you should try it and see
no
thats a Launch event
not a hit event
thats when he throws it, not when the projectile hits something
also @ivory sleet it was some bungee bs in my maven cache that was causing my issue
What would be the most efficient way, RAM wise, to get the coords of certain blocks so in the future if a block's location is in those coords, then cancel the event
the Y wouldn't matter in this case just x and y
what would be the most efficient way to save this?
Also don't want to keep the unused regions in memory if no one is near them to save memory too
Oh the world is really small so you can’t even get out of loading chunks, and I have no idea cuz I’m not a dev
how to put item on gui in selected place
what do you mean?
LIKE the item will be in middle of the gui
Hey !
Do you know how to change biome to another in 1.9+ ?
get the inventory you are managing and get the itemStack you want to put in it. If it is a size is 54, you can set it in slot 22
You could do inventory.setItem(22, yourItemStack);
ItemStack stack = new ItemStack(Material.BARRIER);
That would just create a barrier item but you can the itemMeta by getting the ItemMeta theh applying it back once you have finished manipulating it.
If I want to unconditionally execute a command as sender of a parent command (simplified, if /x y attempt execution of /y as original sender) what is the "most correct"/most elegant way of doing that?
I've seen similar stuff to this before so I know it's possible, I just feel like there's a better solution than checking for each type of sender and calling the corresponding function
Does anybody know where I can find com.mojang.authlib in spigot 1.18?
Not in the api or in the original spigot
Also:
com.mojang.datafixers.util.Pair
How can i make an Ü bold?
protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
final ItemStack item = new ItemStack(material, 1);
final ItemMeta meta = item.getItemMeta();
// Set the name of the item
meta.setDisplayName(name);
// Set the lore of the item
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);
return item;```
where to put it??
inv = Bukkit.createInventory(null, 9, "Example");```and what does here null
Hey, how can I send connected fences to client
I know this is more of a maven question, but
mvn package
Emits two Files:
<artifactId>-<version>.jar
and
original-<artifactId>-<version>.jar
with atifactid and versioon obviously with my values.
Which one should I use? As the Plugin for the Server
The only depenendcy is the spigot-api
can you help??
Use <artifactId>-<version>.jar. The difference between the two is that the original doesn't contain anything shaded while the non-original does
If the only dependecy is spigot-api then there shouldn't be a difference between the two with a proper setup
Well, there seems to be one, they differ in size
Looks like you didn't set thing up right. You're shading the spigot api
Add scope provided to the spigot api dependency
?
Scope is provided, the jar size differs by only anfew bytes and the spigot api is included in neither...
Maybe maven tries to package one as executable? (Which doesnt work bc no main class) so they are almost the same?
what
do u wanna do
add the item in specify place
inv.setItem(slot, item);
check out me code
yes but like i should split this item.setItemMeta(meta);
wat
protected ItemStack createGuiItem(final Material material, final String name, final String... lore) {
final ItemStack item = new ItemStack(material, 1);
final ItemMeta meta = item.getItemMeta();
// Set the name of the item
meta.setDisplayName(name);
// Set the lore of the item
meta.setLore(Arrays.asList(lore));
inv.setItem(4, item);
return item;
}```
i should do like this
can u access inv tho
private static Inventory inv;
public SprawdzGui() {
inv = Bukkit.createInventory(null, 9, "Example");
initializeItems();
}```
public void initializeItems() {
inv.addItem(createGuiItem(Material.DIAMOND_SWORD, "Example Sword", "§aFirst line of the lore", "§bSecond line of the lore"));
inv.addItem(createGuiItem(Material.IRON_HELMET, "§bExample Helmet", "§aFirst line of the lore", "§bSecond line of the lore"));
}
ok good
so this is good?
Well, you need the jar/ the maven repo in your classpath
yes i think
this is force needed on 1.18?
on 1.17 is working fine
Okay either works then. Probably just meta inf taking up space
so how tu put item in "place"```java
protected ItemStack createGuiItem(final Integer place,final Material material, final String name,
final String... lore) {
final ItemStack item = new ItemStack(material, 1);
final ItemMeta meta = item.getItemMeta();
// Set the name of the item
meta.setDisplayName(name);
// Set the lore of the item
meta.setLore(Arrays.asList(lore));
inv.setItem(place, item);
return item;
}```
ok ok
so what can i do now
ok ok
so how to put the guid in "place"
inv.setItem(place, item);
inv.setItem(integer, item);
e.g inv.setItem(5, new ItemStack(Material.DIAMOND_SWORD));
that would put diamond sword in slot 6
yes but look on my code
this
but my code looks diffrent
like you see how it looks
final ItemStack item = new ItemStack(material, 1);
final ItemMeta meta = item.getItemMeta();
// Set the name of the item
meta.setDisplayName(name);
// Set the lore of the item
meta.setLore(Arrays.asList(lore));
item.setItemMeta(meta);```
and you're wondering how to place that in gui?
im thinking how to do the item will be in the chosen place
because if i do this item.setItemMeta(4,meta); i got error
so you dont whant to help me?
I would if I knew how to
I'm not sure I coudl sovle this
Ye you do item.setItemMeta(meta)
and then Inventory.setItem(place, item)
Aaa uhh thx
Yo wth?
API Version 1.16.5-R0.1-SNAPSHOT
What are the numbers called beside the scoreboard?
The scores?
Should be R0 not RO
ye
It's grammatic mistake
You guys recon i'd be easy to make a plugin that delays the respawn after death?
So you'd have to wait until you respawn.
Anyone here know how to do the gradles?
NOOOOOO
YOU SHOULD NOT BE USING THE GRADLES
THE MAVENS IS BETTER
YOU FUCKING RETARD
AAAAA
/s
im using maven too but i have to say, maven is not better than gradle lol
finally
True
But I do not need 2 copies of a dependency shaded to different places
How would you make a folder in plugins/%plugin%/
new File(Plugin#getDataFolder, foldername).mkDirs
That will make a folder at plugins/%plugin%/foldername
is the current spigot 1.18 a production release or is it still experimental? Im having some serious chunkloading issues
It's marked as release as of today
Chunk loading is a vanilla issue that is addressed in 1.18.1rc2
How could I rotate an arraylist elements
wdym rotate
like, reverse?
one
two
three
``` rotate ```
two
three
one``` etc...
why not just use Collections.rotate?
Is that a thing?
yes
I was going to suggest remove(0) and then adding it back
there's also Collections.reverse
im pretty sure thats what that method would do anyway, so why not implement it yourself?
private static void rotate2(List<?> list, int distance) {
int size = list.size();
if (size == 0)
return;
int mid = -distance % size;
if (mid < 0)
mid += size;
if (mid == 0)
return;
reverse(list.subList(0, mid));
reverse(list.subList(mid, size));
reverse(list);
}
why bother using anything other than List tho?
rather not using list also
that's the faster choice for add/remove ops iirc
Set is preferable for contains
so
just use List or convert to it when you need to rotate
That's like, 95% of what I use
Can't use lists
why?
and I don't wanna hard code it
what do you mean?
you need to explain both of these things
- Why can't you use lists?
- What do you mean by "hard coding the rotation"?
so use the superclass Collection and invoke Collections#rotate on it. wheres the problem?
Collections.rotate only targets List
I assume bc List is the only interface with subList
Doesn't really work with a set anyway
the slowness doesn't matter
You have yet to explain why the fuck you can't use lists.
Why does the list is empty if I use TWDPlayer.getOnlinePlayers().add(twdPlayer);?
So that is the only thing I am going off of.
Anyway, get over it, find some way to use lists, good luck.
Because my professor doesn't want me too
Ok then
You're on your own
bc
Collection/Setdoesn't supportgetor other index-based operations, and is therefore harder to use.
- That is your assignment.
private static void rotate2(List<?> list, int distance) {
int size = list.size();
if (size == 0)
return;
int mid = -distance % size;
if (mid < 0)
mid += size;
if (mid == 0)
return;
reverse(list.subList(0, mid));
reverse(list.subList(mid, size));
reverse(list);
}
it seems pretty clear what happens here. shouldn't be too hard to implement for any Collection
i guess im hard coding git
Add the first member to the end of the ArrayList,
Delete the first member of the ArrayList,
Refresh the List Box.
Hi, how can I block a bundle from being filled?
I already tried with InventoryClickEvent, but failed
how anyone know how to sort a list with values in format: "Player Integer" highest to lowest
Guys, I'm using ProtocolLib on my plugin and I'm trying to open a sign editor gui with some text already. The gui is open, but the problem is, the initial text is not showing on the gui
What version
anyone how I can use ProxyPing.setDescriptionComponent(BaseComponent) with more than one BaseComponent?
I want to use more than one color in my motd ^^
is it a list of strings?
You can add BaseComponents to BaseComponents
Use addExtra
yes but that throws an exception
but already found the solution, im stupid
I can just a TEXTComponent instead lol
oh nvm
that also doesn't work
when using addExtra on the basecomponent, it throws some exception stating "Component loop"
Show the code
@EventHandler
public void onPing(ProxyPingEvent event) {
if(!config.getBoolean("enabled")) return;
ServerPing ping = event.getResponse();
ping.setPlayers(new ServerPing.Players(config.getInt("max-players"), ProxyServer.getInstance().getOnlineCount(),ping.getPlayers().getSample()));
String motd = config.getString("motd");
if(motd == null || motd.length()==0) return;
BaseComponent[] components = TextComponent.fromLegacyText(TinyTextUtils.format(motd));
BaseComponent component = components[0];
for(int i = 1; i < components.length; i++) {
component.addExtra(component);
}
ping.setDescriptionComponent(component);
event.setResponse(ping);
}
You can't add the component to itself ;/
lul
ofc that would cause a loop
I'm not
component.addExtra(component);
You are
You are
1.12.2
yaay :3 ugly but works
I can't seem to figure why it saying my ping is 1 when it shouldn't show that this.mc.getNetHandler().getPlayerInfo(this.mc.thePlayer.getUniqueID()).getResponseTime()
yeah but they look like I randomly scrambled those colors together _D
What should it show
I mean tbf
My actual ping
Are you on localhost
so
the colors aren't high enough contrast from each other
plus they're quite pastel
yeah I'm not very good in choosing colors
hmm I might just change the order of the colors, maybe I'm happy then 😄
scrambled, maybe, but not impossible to connect
got it from this sample thing
that's a nice palette
Has anyone an Idea?
finally I'm liking it myself 🙂
how do you shift a location towards another one?
Help with 1.18 spigot dependencies
Loaded class kotlin.internal.jdk8.JDK8PlatformImplementations from AnotherKotlinPlugin
What website or whatever?
im sorry what
[19:11:19] [main/INFO]: Loading tweak class name --tweakClass
[19:11:19] [main/ERROR]: Unable to launch
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1955) ~[?:1.8.0_51]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:121) [launchwrapper-of-2.2.jar:2.2]
at net.minecraft.launchwrapper.Launch.main(Launch.java:30) [launchwrapper-of-2.2.jar:2.2]
You are trying to find a character at an index that doesn't exist
it straight up ignored by entire path
I'm basically looking for a method that takes in a command and executing agent as parameters, a way to "forward" commands
dont remember, I just googled color gradients
is it possible to get an Advancement's description?
Isn’t that client sided
well at least datapack advancements should have some kind of string on the server
are minecraft textures usually jpg or png?
lossy with a voxel game lmao
where is 1.17.1 version
hm?
what about them?
saw u asking for help on ur project
im not in fabric discord?
u were
he couldve been a little nicer abt it imo
Well, it's probably just his personality
dealing with mod community for awhile probably did some damage to how he responds
also the Fabric server has had some h i s t o r y
yeaaahhhh
Altrithe I got what I wanted to make
pog
but now its the jar itself being an ass 🙄
but obviously I can't ask in the other cord because it has nothing do with mixins so
Version?
1.8.9+ 🙂
I've only worked with mixins a bit on 1.16
Should I just send the error?
You know im gonna make a thread of mixins for people that use it
sure
How can I get this image as a BufferedImage ?
ImageIO.read(Objects.requireNonNull(this.getClass().getResourceAsStream("resources/images/DefaultButton.png"))) throws a NullPointerException. Same when leaving away the "resources/".
Shouldn't it just be /images after building?
Since gradle and maven move stuff from src/main/resources to the root folder
Well gradle does, I assume maven does too
still java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:208)
when using ImageIO.read(Objects.requireNonNull(this.getClass().getResourceAsStream("/images/DefaultButton.png")))
do i need to somehow include it in the jar?
doesnt seem to be
do i need to change something about this?
include *.*?
or can i just completely remove it and that will do the same?
That will only affect what is packaged in your final jar file.
If you want everything in your resources folder to be included in the final jar, remove the filtering and includes tags.
Otherwise, you have to specify.
i see, thanks
why does this not show an error?
doesnt even show a line or anything
ah figured it out, after about 100 errors the command line just is too lazy to write the errormessage
Yeah
Are you trying to retrieve something from the jar at runtime?
I assume it’s to limit log size? Idk
yeah, why?
Cause I just ran into this issue.
works fine now for mee
maybe, or its just a feature to avoid unnecessary cpu stress
idk either xD
true yeah
When you export with gradle does it add the dependencies to it?
Only if you shade them
Heyooo, im a little new to the shading side of maven, and I'm really not confident with maven in general
ahh damn haha
Trying to shade in this external library, and I've been trying to track down old posts on spigot on how to shade but eh.. it's not very resourceful and not much content about shading here except recommendations or disapproval of shading (like maven bad or something)
There should be plenty of non spigot tutorials
to you use buildDependents to shade them?
No you just use the normal build
Make sure you are using the shade plugin and have the dependencies marked as implementation
the shade plugin?
oh nvm
I'm somewhat nub, how do I change jdk version on Gradle?
Cause error on server is saying that my plugin is 60 and that it has to be 55 for it to be loaded.
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_16
Although it might be different for 8, hold on
VERSION_1_8
Quick question, do plugins automatically get disabled if a runtime exception is thrown in the onEnable?
Or do I need to disable it manually
Okay thanks
how can i get player object of someone who isnt online in the server or has never logged in before either, i want to get the object from mojang api
oh ok thank u
@young knoll Bukkit.getOfflinePlayer(String) is depraceted, and it needs UUID now, how am i supposed to get the offline player (who hasnt played in the server before) uuid like that?
for some reason
it still doesnt work
like
it loads the players object who has before joined the server
but not the ones who hasnt joined the server before
Bukkit.getofflineplayzr should never return null
oh ok so i short
am doing this
OfflinePlayer sp = Bukkit.getOfflinePlayer(someones name);
skullMeta.setOwningPlayer(sp);
it works for players who are online or was online in the server
but not for other players sadly
I think that may be a requirement? No idea
thats sad f
Does it...?
Pretty sure it does not
It's deprecated since UUIDs are saved persistently while names are not
Or, names can be changed and therefore can become invalid
for offlineplayers as such players who hasnt logged in server before
“This method may involve a blocking web request to get the UUID for the given name.”
It says "may", and looking at the decompiled method, I don't see any calls to make a web request.
what is the method name, can i know it pls
If you need to get a player that has never joined, you'll probably have to use Mojang's API
You have to verify
The source in craftbukkit also mentions it may be blocking
I could be blind, I just don't see where it makes the request lol
You’d have to look inside NMS
?
Wait
Can anyone write me some code that creates a config file in a folder when the plugin is first launched. (In your free time please)
Plugin.saveDefaultConfig();
There are a lot of plugin repo's where you can find this.
Will create config yml and the datafolder
That’s just cb
can i which method is it tho?
getOfflinePlayer(string)
Yeah...? OfflinePlayer is a CraftBukkit implementation, why would NMS have anything related to it?
Because it calls NMS methods?
@sullen marlin
in the stash the only change for the security issue is only at craftbukkit right?
i am thinking of making a custom web request to mojang api to get uuid of the player using username lol
Yes, and that's the CraftBukkit method for getOfflinePlayer. It's not calling any NMS method that makes a request as far as I can tell.
Oop, wait I found it
Assumed something was a map and it is definitely not
is it possible to get the 1st entry in a hashmap/map?
Kind of
Only linked hash maps are ordered
You can still get the “first” entry
i have Map<Player, Integer> sortedMap = values.entrySet().stream() .sorted(Map.Entry.<Player, Integer>comparingByValue().reversed()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); which organizes a map
Okay so you do have a linkedhashmap
Yep
but thats just going over the map?
oh, but thats only the 1st entry?
That’s what you wanted, is it not
yeah i used 1st as an example i thought it had some sort of method like an arraylist but im making a leaderboard type thing
Nope
Make a class to store the name and value and have it implement comparable
Then you can sort a list of them
Actually you can probably already convert entrySet to a list and sort that with a comparator
is spigot release new exploit fix for 1.8.8?
can you give me download link?
[07:05:02 WARN]: at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
[07:05:02 WARN]: at java.base/java.io.File.createNewFile(File.java:1034)``` is there a reason why my file isnt creating?
``` if (!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}```
its saying it doesnt have permission and yes the directory is correct
i never used build tool
?bt
i downloaded build tool from jenkins run with this cmd "C:\Program Files\Java\jdk1.8.0_301\bin\java.exe" -jar BuildTools.jar --rev 1.8.8 pause
is this ok?
yes
thank you
not ok, 1.8.8 is old 🙄
would it be possible to detect when an entity plays a sound?
What causes this error? https://pastebin.com/8g5w0uZJ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
It tells you
public void initializeItems() {
inv.addItem(createGuiItem(22,Material.DIAMOND_SWORD, "§6Sprawdz", "Sprawdz uztkownika",
"§bSecond " +
"line of the lore"));
inv.addItem(createGuiItem(24,Material.IRON_HELMET, "§aCzysty", "Uznaj uzytkownika za czystego"));
inv.addItem(createGuiItem(26,Material.IRON_HELMET, "§4Zbanuj", "Zbanuj uzytkownika za cheaty"));
inv.addItem(createGuiItem(35,Material.BARRIER, "§4Wyjdz", "Wyjdz z gui"));
}
protected ItemStack createGuiItem(final Integer place,final Material material, final String name,
final String... lore) {
final ItemStack item = new ItemStack(material, 1);
final ItemMeta meta = item.getItemMeta();
// Set the name of the item
meta.setDisplayName(name);
meta.setLore(Arrays.asList(lore));
inv.setItem(place,item);
return item;
}```
why im geting the items twice
and the item name is not the item name
you do inv.setItem and inv.addItem
you also don't set the itemmeta after updating it
so what i should change ?
Remove addItem
<Inventory>.clear()
thxx
declaration: package: org.bukkit.inventory, class: ItemStack
i will check it
👍
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (e.getInventory() != inv) return;
e.setCancelled(true);
final ItemStack clickedItem = e.getCurrentItem();
// verify current item is not null
if (clickedItem == null) return;
Player p = (Player) e.getWhoClicked();
p.sendMessage(e.getView().getTitle() + "" + clickedItem.getItemMeta().getDisplayName());
switch (e.getView().getTitle()) {
case "Sprawdz":
if(clickedItem.getItemMeta().getDisplayName() == "§4Wyjdz"){
p.closeInventory();
p.sendMessage("§l[§k§cModMessage§f§l]§f pomyslnie opusicles gui");
}
break;
default:
break;
}
}
}``` Why it not react when i clicked the "Wyjdz" button
it dont close menu no error
Was just wondering as I am currently studying, if I wanted to make a way to store the current difficulty level for something, in java I would use an enum right ?
Is there a "proper" way to find out if your server crashed/hangs from the outside? The Idea being that should the Server get itself in a Deadlock, I could just SIGKILL it from the outside and restart it.
how to put the red glass in gui?
The question wasn't meant as "should I use sigkill?" but how do I detect, that I NEED to kill the process in the first place
try to stop it regularly, if its not dead within $time then kill it
Are you aware of the log4j exploit?
my bad
OHH.... I want to detect if it is hanging in the First place, so that I can sigterm/sigkill whatever. I dont want to sigterm the Server to detect if its hanging, bc if it is not, that would stop the server. I want to detect the server not working in the first place, so that I can deal with it
spigot has hang detection functionality built in, its called the watchdog
Oh ok
it will try to stop the server if it detects this
What does the watchdog do if the server hangs? stops it? Try to restart it like /restart does?
Yeah... I think it doesnt even attach the new Server to the Parent Process of the original Server, which means its unusable for me...
yup, better to just let it /stop and have your script run server in a loop
/ auto restart
attaching to the parent isn't really possible with java
How to do the empty name and lore
But I thought I had no control over what the watchdog did when the server hangs? Do I just supply an empty ./start.sh and let my script restart the server? Bc afaikt the wachdog tries t use the ./start.sh to restart the server
and how to do protected ItemStack createGuiItem(final Integer place,Material material, String name,String... lore) argument optional
the default is effectively to stop, because start.sh doesnt exist
it only tries a restart if the named script exists
sooo. Since my loop uses a ./start.sh ill just rename that?
lore will be optional as varargs. everything else you would pass in null
rename that or change the restart-script option to something else (eg empty)
i dont have something like this
md you seen the zero day on Log4j?
not works
elgar not you too
I only just saw this morning
wtf is this shit happening with 'log4j
i just woke up and servers already exploding with pings
can someone explain??
fixed, run buildtools
yeah but what is it about
remote code execution exploit
oh an RCE?
I have gson linkedtreemap. How to deal with it
is this valid syntax for java 17?
List<int> ints;
Nope
then why intellij don't mark it as error
does it compile even?
honestly i didn't try but intellij don't mark it as error, i though maybe in java 17 it is like new feauture?
Jep 218 isn’t released in 17, at least not as an official release, might be a preview release
Eclipse marks it as an error
Anyone see anything wrong w/ this jdbc connection string? jdbc:mysql//localhost:3306/development?user=root&password=REDACTED
And yes, I am doing Class.forName("com.mysql.cj.jdbc.Driver"); before attempting the connection
what your error?
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/development?user=root&password=REDACTED
thats not a problem with teh command, thats no driver
I'm not sure what you mean
add a : between mysql and your //
true+
intellij marks it as error, but pretty sure every warning/error in intellij can have its severity changed
Can someone make me a script that creates a config file
Just do saveDefaultConfig() in your onEnable.
and create a config.yml in your project.
It didn't work?
report it to intellij when?
Hey there! I am trying to make a plugin that notifies me via email if something happens.
I have searched and searched and the only real API available...
You have 3 fairly straightforward options. I've used all 3 options in practice so while they all work they have their own advantages and disadvantages.
...
Good way: Modify the class path to include your jar. Probably the best way for a plugin is to as you say use a Manifest file and add Class-Path e.g Class-Path: plugins/YourPlugin/lib/name.jar
...
How to do this via gradle? Does anyone have any idea?
Quick Question. Is new method that in spigot 1.18 (example: sendEquipmentChange, openSign, hide/show Entity) will be in version below it?
No
Ah I see, thanks
do these jars have maven repos for them?
Yes they do
then use teh library feature of the plugin.yml
Oh, where can I read about that?
1.17 release post
hi guys. i need to kick player out on PlayerSpawnLocationEvent. but kickPlayer doesn't seems to work cuz the player instance doesn't have a connection yet.
how do i solve this?
isn't that only for jars from maven central
Yes
Why that event
eg adding this to your plugin.yml will make spigot download and add to the classpath the h2 database driveryaml libraries: - com.h2database:h2:1.3.159
because i need it
i want to do something to the spawn location of new players. if fail i'm gonna kick them. will making a delay breaks this?
Shouldn’t
Haha, amazing, it works! thank you very much again!
this event is after PlayerLoginEvent and before PlayerJoinEvent. player can be kicked during those events without a problem.
there's no reason we can't do that on PlayerSpawnLocationEvent.
So I'm working on a plugin and when I put it on a test server the entire test server just freezes when it says enabling ... v1.0 (freezes = can't even stop the server, I have to kill it)
Tested it on local server as well to make sure it's not smth of the server
Searched on google but couldn't find anything about it
you probably have an infinite loop while(true)
I just restarted my pc, exported the same thing again and it works
my pc or ide might have had a derp moment or smth
How do i get every possible container inventory except the player's inventory?
event.getInventory().getHolder() instanceof Container doesn't include double chests and storage minecarts
You could negate an instanceof PlayerInventory
public void onInvClose(InventoryCloseEvent event) {
if (event.getPlayer() instanceof Player) {
if (!(event.getInventory().getHolder() instanceof PlayerInventory)) {
if (event.getInventory().getHolder() instanceof InventoryHolder) {```?
I don't need InventoryHolder check?
okay
public void onInvClose(InventoryCloseEvent event) {
if (event.getPlayer() instanceof Player) {
if (!(event.getInventory().getHolder() instanceof PlayerInventory)) {
InventoryHolder container = event.getInventory().getHolder();
StringBuilder inventoryString = new StringBuilder();
for (ItemStack item : container.getInventory().getContents()) {
if (isLargeItem(item) || isCrashItem(item)) {
item.setItemMeta(null);
}
inventoryString.append(itemToString(item));
}
if (inventoryString.length() >= 120000) {
container.getInventory().clear();
}
}
}
}```
that should work then
I might also replace container.getInventory() with event.getInventory() ig
can i change the icon of custom item how to do it?
resource pack
so i cant split the itme icon using plugin?
Learn about custom model data, basically It can change item model with resource pack.
can i get current server ticks?
What? You meant tps?
use spark for tick monitoring
no. the current ticks. something similar to epoch time.
code pls
how would i give u something i don't know?
yes
Can Kotlin be used for spigot?
yes
system.currenttimemillis()
/ 50
it stands for the ticks elapsed after server start.
??
if u have mcp u would know what i said.
you asked how to see current server ticks
how does that work?
Well you just code plugin in kotlin, and then it got compiled into jvm bytecode
How can I fix this?
if (Ticks == 1) { Double x = Double.valueOf(data[1]); } // I want to use double x here but it is not possible
Double x = 0;
// do ur if else there {
x = ur thing;
}
// use x right here
how do i make a tab header and footer in 1.8
Thx
player.setPlayerListHeaderFooter
it doesnt work on 1.8
yes it does
Do not use 1.8
ok
?kick @bold hare
Done. That felt good.
sorry
i already use paper spigot
you could always go NMS
no no, you can create a custom pathfinder with NMS
you should not set velocity, it will come out weird
wait, are we talking about Citizen NPC?
Hello hopefully friendly developers
Damn I pressed enter too fast, wanted to see if I can ask a question about java development here not related to spigot
sharpens stick
just adding/removing teams will nto cause you to be kicked
Invalid player data indicates you are messing directly with the player somehow
nms?
packets?
I saw
nothign I saw in there shoudl be corrupting player data
So Paper seems to say that updating log4j is insanely hard and would require a team of paid developers to do, but in Python for example I'd just put in the updated module, change the import and badabing badaboom, wouldn't this be done the same way in java?
disable it bit by bit untill you can login
then suffer for nothing
if yoru code is kicking you, disable a bit of yoru code at a time untill it doesn't
narrow down where its killing it
can someone help, i need method which will replace all "%COLOR_NAME%" in strings with corresponding chatcolor, like "%RED%" with red color from bungeecord's chat api, and all "%#xxxxxx%" with corresponding rgb color
try delaying yoru creation of the team and adding teh player by 1 tick. make it run after teh player has actually joined
Regex is your friend
detailed? how i make regex like that?
I'm guessing you are asking why they didn;t back port to earlier versions
I'm asking how would I update log4j myself in the java project, haven't touched java in my entire life, I understand why they didn't back port it
Paper 1.8.8, or any java project for that matter, I assume importing jars isn't done in 10 different ways
you could just runTask as it runs on teh next tick
Basically they are telling you to update. They are not supporting old versions.
That has absolutely nothing to do with what I asked
Yeah it does. Its the exact thing I asked in the first place. You asked them why they didn;t do it for 1.8.8 and eventually asked how to do it yourself
Do not use 1.8 😀
Here we do Spigot. Spigot was updated for all version from 1.8
No, I asked here how would I do it in general in a java project so I can do it myself for that specific purpose, I did not ask what or why the -Paper team- is telling me. I am fully aware why they are not updating and I do not care about their reasons
Updateing a dependency can be simple, but it all depends on what API changes have happened
if methods are all still teh same its simple as updating the version
however this update is not as simple, it seems
I'm guessing some methods have been replaced
I just have never used Java so I'm not aware how updating a dependency is generally done here
In other languages I literally just pop in the new version and change to the new name in the import line to modify any code that needs changed if any breaking changes were made or etc
1.8 XD
Java it all depends on your build system
Maven, you update teh pom.xml
then fix anything thats broken in your implementation
I couldn't and wouldn't tell you how to do it on the application you are wanting to do it on, as its not Spigot.
whats a simple way to iterate over a HashMap?
ok nice
map.forEach
but why don't people use kotlin for their servers?
a new class?
correct
its the only valid forEach on a HashMap
or at least my ide says that it is
map.forEach((key, value) -> { //code });
ah right were not in j8 anymore
hey guys, I wanted to OP myself in my server. But I can't acess my screen, where the server is running.
So my question is: Is there any software to acess my server as an OP?
I don't know if I made myself clear
it depends on yrou server and host, this is a question for #help-server
you need either access to the console or access to a OP minecraft account on that server
if i do HashMap a = b; with b a HashMap and change a, does b change?
Wdym?
Hey ElgarL, I've seen you mention something about hooking into Vault a few months ago. Does it not apply for retrieving other plugin's economy data through vault?
Reference: #help-development message
If you are changing teh contents of a, then yes. If you reassign a then no.
yes
Hrmmm strange. How would I go with that then? To hook and retrieve economy data from other plugins (I'd presume Essentials is handling the eco)
if your eco provider is Essentials, then just access vault as you would for any eco
Economy.java
if doesn;t matter who the eco provider is
if you access via vault
does a function returning a variable still link to that variable, all code in the same class?
HashMap get_map(){return map;}
...{
map2 = get_map();
map2.put(key, value);
//does map still get changed?
}
yes
you return the instance of the map, nto the map
because clone gives an empty map
You want a copy of the map? new HashMap<>(oldMap)
Ah i see, I'll go through the vault route, cheers!
do a non lambda for each java for (Entry pair: map) {
you can use
for (Map.Entry<...> entry : map.entrySet()) {
// code
}
ah thanks
Which is faster assuming all values are present in the map items?
count = items.get(value.getKey()) - value.getValue();
if(count < 0) continue;
//
count = items.getOrDefault(value.getKey(),0);
if(count == 0) continue;
count -= value.getValue();
you are trying to add up all teh values?
subtract but return false if less than 0
i jsut realized that if should contain return false not continue but same question
boolen function
subtract all values from?
the map items
but its supposed to return false if that would result in a negative value
Yeah, I have no idea what you are trying to do
basically the HashMap Inventory.remove(HashMap remove) function but inverted
you are subtracting the value from the key?
ah no
i am setting a temporary map and copying that onto the real map afterwards if all subtractions resulted in no negative numbers. It's a item cost function and hence i need the 'return false if negative' part
As clear as mud
Does someone know how i can drop tps on purpose so i can test my plugin?
google lag machine
add in a while loop
oh thats a good idea
a count down
do a command that just does while(true) then call it a few times
thx
add something to compute tho
like a math expressoin based on current time
Elgar do u know if commands are handled async or sync?
Eh, i made this:
package me.branchyz.lostkingdom.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class LagCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if(command.getName().equalsIgnoreCase("lag")) {
commandSender.sendMessage("Nieuwe lag machine staat aan!");
while(true) {
}
}
return true;
}
}
It works, but other commands will not work anymore. And after like 30 seconds, it will time out
don;t run it forever
set a countdown value
something like java int count = 1000000; while (count-= 1) {}
thx
you don;t want it running constnaly
while its running your server will be locked up
you just want to lock it up enough to eat up some ticks
Okay, i did this but the tps stayed the same. The server is running local, does that matter?
increase the value until you see some effect
are you looking just for a lag spike, or constant lag?
constant lag
then do a repeating task
Ah okay, but i did this:
int count = 999999999;
while (count > 1) {
count--;
}
But it still didnt lag, and that is the max int size
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
int count = Integer.MAX_VALUE;
while (count > 1) {
count--;
} }, 0, 5);```
i'm getting this error: org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map.
my config.yml is just this
itemname = &l&nClick &rto get the closest &a&lslime &rchunk!
learn yaml syntax
okay ty
itemname: "&l&nClick &rto get the closest &a&lslime &rchunk!"
Anyone know a good way to save custom server resource pack from loading every time a players join the server? For example, he downloads it only once he joins first time but then just loads it
Client side i guess
How can I make a custom item, that behaves the same even when its name is changed?
You identify a custom item by data in its PDC not by name
so uhm while getting something from a persistent data container, do i need to use %pluginname%:%thing%
or just %thing%
Not possible with a plugin?
This still doesn't affect the tps :/
calculate teh square root of the number inside the while loop
What would be the best way to store 2 coordinates together in one variable?
I tried using pair but i don't have javafx
Math.sqrt(count)
and its a task so use teh command more than once to add more load
Map.Entry<K,V>?
maybe just a record
i dunno what a record is
Just a record ^^
Im trying to mess with the PrepareAnvilEvent so that some items cannot be repaired. I do this by setting the result to null. now if I put in a different name for the item it reappears in the result slot, but I cannot take it out. it takes my levels but gives them back as soon as I relog. is there a way to fix this or do I have to live with levels being glitchy when people try to take the item out of the result slot
Yeah the PrepareAnvilEvent is pure hell
there should be a PrepareAnvilRenameEvent aswell or some option inside the PrepareAnvilEvent
just my opinion. would make it easier to work with and easier to prevent bugs
why does inventoryclickevent return an HumanEntity as the clicker? Isn't Player the only interface extending HumanEntity?
Because NPCs or some random bullshit idk. Some plugins might extend it so beware
ah ok so it's not a safe cast i guess
i cant import JavaPlugin in my Main class. i have imported the spigot file already into the referenced libraries and idk what else to do regarding it
what IDE?
How would I check if a player has left, I have an event where if the player is tagged then I want it to check if they have logged off ?
Listen to teh PlayerQuitEvent
how would would I do that?
Alright thanks :D
?paste the stacktrace from your latest.log
or better learn to read the stacktrace. look for the caused by line
I can't read the screenshot but I can make out a cast error
classcastexception error
do you know what a cast is?
not
Its when you try to change the type of a class to another, like Player player = (Player) event.getEntity();
thats casting the entity to a Player
You can only perform a cast when the two types inherit or implement the other
if i have 4 optional parameters, do i actually have to make 16 different methods, or is there any better way?
or are similar in some way
eg, you can;t cast a String to a Player.
Read yoru stacktrace. The causedby line will say a line number in your code
wdym
eclipse (sorry for replying so late)
You know what optional parameters are, right?
In java you make them by creating a new method for each different parameter.
public RectangleBuilder setText(String text, String alignment, int textPadding, byte textColor) {
this.text = text;
this.textAlignment = alignment;
this.textPadding = textPadding;
this.textColor = textColor;
return this;
}
public RectangleBuilder setText(String text, String alignment, int textPadding) {
this.text = text;
this.textAlignment = alignment;
this.textPadding = textPadding;
return this;
}
public RectangleBuilder setText(String text, byte textColor) {
this.text = text;
this.textColor = textColor;
return this;
}
public RectangleBuilder setText(String text) {
this.text = text;
return this;
}
I have this, and i plan on adding two more optional parameters. that would give me 16 different methods.
How can i get the ingame-time?
you have to overload it if you want to call any specific combination of those, but can't you just call a method with all parameters with null
if you dont initialize it its null
would be 0 iirc
no its not
int, boolean, byte etc. are not Objects
or maybe wont compile
Yes you need seperate methods, but their identities must all be unique
but thats just ugly
but is there any easier way to do it than making 16 different methods?
the only alternative i can think of is using a builder pattern
each method doesn;t need its own code
true, just need to call the one above
one method that handles al variables adn the lesser methods all call it
just template code
like what if i want to make another optional parameter, then i gotta make 32 methods