#help-development
1 messages · Page 1952 of 1
do you even have a extension/plugin/module/mod/whatever loading system in place?
Another pretty obscure example would be https://github.com/Geolykt/Presence, where the API classes are located under de/geolykt/presence/common. It has absolutely no interfaces but was built as an API (while also serving as the implementation of the API) strictly speaking. In the end an API can be everything you want as long as you document it
obfuscate your api to make it even better 🌝
Yes 🙂
make an api to interact with your api
make an api to check the weather
if it's cold outside then more people will be playing so you need to order more servers
from mircosomft
Does IntelliJ use less RAM than eclipse?
but it's more polite to make your own 🙁
if you worry about that, you need more ram anyway
I'm in a sticky situation where I have to fear the OOMKiller but I still want to make use of an IDE
what, are you gonna tell me next that you use the interfaces in Spigot instead of the NMS classes?
I mean, I could just stop using discord
only develop with NMS and it will be compatible with everything 🧠
What do you think about this is good practice?
public interface Api {
JavaPlugin getPlugin();
}
public static class ApiImplement implements Api {
@Override
public JavaPlugin getPlugin() { return JavaPlugin.getProvidingPlugin(ApiProvider.class); }
}
public static class ApiProvider {
private final static ApiProvider instance = new ApiProvider();
private final Api api = new ApiImplement();
public static ApiProvider getInstance() { return instance; }
public Api getApi() { return api; }
}
public static class ApiConsumer {
public void enable() {
Api api = ApiProvider.getInstance().getApi();
api.getPlugin().getName();
}
always
since spigot doesn't have any anyways
Too enterprise for me
naming it api aint good imo
Just for example
singleton
Ideally you'd have two classes. In Bukkit space these two classes would be Server and Bukkit
.
bunp
All other classes are irrelevant
protocollib
Explain more
Why is it when i edit tripwire blockstates, the player sees the wrong blockstate until they relog?
Well, to continue the example of bukkit, it stores an instance of Server within the Bukkit class. (CraftMain (I think it was called that at least) sets it after it constructs the CraftServer class, which implements the Server interface)
The CraftServer class and co do not need to be exposed within the API and ideally should be in a seperate repository, but that can be difficult to maintain which is why I do not do it
However if you make an API ontop of bukkit and want other people to register implementations of it, use Bukkit's service API which more or less does the same thing just that you only need the interface class. For example the vault api only needs to provide Economy but not any holder class as that is already done by the service api
Hmn you probably no understanding me or im not explaning good
but all blocks in an event will have a nonnull world for the location right?
Yeah
declaration: package: org.bukkit, class: Location
it wont go null
if anything refers to the location, it also implies the reference to the world
but there is this ugly #setWorld method
If you obtain your location from bukkit, you will always get a non-null values
where you can null the world yourself
meh
so theoretically it should never be null
And as per javadocs, it will throw an exception if it is unloaded
if the world is unloaded but accessed, there will be an IllegalArg thrown
It’s supported if a plugin wants to make it null but if you’re getting it from spigot it won’t be null
oki thanks
not always non null world in locaton!
Hey anyone do know why this <for cycle> is not being iterated? The prints are to debug the plugin.
<System.out.println("CHUNK Charged");> is being printed on the console, but the < System.out.println("For cycle");> is being printed
Could be that entities is empty.
Yes maybe is for that, but in the chunk there are entities :(
there is a another way to get entities on recently load chunk?
the entities are not loaded when ChunkLoadEvent gets called
also you shouldnt create the mobs-list on each ChunkLoadEvent xD
ohh man, that is it! I did know it :o
thanks!
i think there was a discussion about exactly that ...
there is another option to get that chunk?
Is possible get that discussion?
I want to know the solution
1.18.1
i think 1.18.x has the EntitiesLoadEvent and the EntitiesUnloadEvent
Thank you so much!!!
How would I stop the client from predicting blockstate changes
kick the client :smart:
firmly tell it no
Distract it
If it's looking away from the block, it can't predict the state change :)
exactly
(Obviously)
Schrödinger's cat
I love helping people
Same
I dont want to upset the client and make it sad so is there a more positive way of saying no?
Update; found an article from 2018, since the 1.9 update the client reacts better to positive reinforcement and praise
How to open inventory sync?
player#openInventory 
Return inventoryOpenEvent may only be triggered synchronously.
You want to open an inventory async?
what's the difference between REL_ENTITY_MOVE, REL_ENTITY_LOOK, and POSITION with ProtocolLib packets?

ok yeah
Exactly ctrl click the PacketType
It should have the packet name in the PacketType constructor iirc
why people use base64 for encoding binary data to ascii strings instead of OutputStream#toString() method?
wouldnt use of toString() method result in smaller lengths of the string
base64 on average increase the file size by more than 25%
for example this byte array
byte[] = new byte[]{65, 66, 67};
could be decoded to
ABC string
when you're working with small objects, 25% doesn't really matter
When editing blockstates the client will try to predict what it should be and will show something it isn't, how do i go about updating this?
well base64 is used for places where ASCII could be used
and to prevent bugs with weird characters, for example newline characters
since ASCII has over 20 control characters
and its "signed" charset (127 chars), thus there's no way to fit byte values above 127 without encoding separately in ASCII (unless we use extended charsets, like UTF-8)
maybe that's why
i think i answered myself lol 😄
🥲
Its just so annoying that ASCII doesnt hold 255 values
and instead it holds half
you wouldnt need any encoding then (if you werent evading bad symbols)
?paste
am i blind or am i not seeing difference between ObjectOutputStream
and BukkitObjectOutputStream
it just extends the ObjectOuputStream class
and adds in one method
but inorder to write to the stream we use super method
of ObjectOutputStream
nvm
it overrides
@Override
protected Object replaceObject(Object obj) throws IOException {
if (!(obj instanceof Serializable) && (obj instanceof ConfigurationSerializable)) {
obj = Wrapper.newWrapper((ConfigurationSerializable) obj);
}
return super.replaceObject(obj);
}
to add in support for bukkit object deserialization
LOL
thats me in #verified
im waiting for me to roast someone for asking such dumb questions
Is there a reason why PlayerPortalEvent doesn't get called when the player enters the exit end portal inside the end, and is there a workaround to be able to cancel it?
try changing the type of byte[] to Byte[]
Hi, @Nullable has TYPE_USE target, it's applied to the array element type, not to the array type itself. To annotate the array type with the TYPE_USE annotation, use byte @Nullable [] bytes syntax.
solved
although i never seen a dude
who annotates like this
byte @Nullable []
that's weird
horrific
you're not the one, who thinks this way:
But don't you think it's weird to declare an array this way?
Can the IDE be more intelligent in recognizing primitive arrays?
that makes sense
byte @Nullable []
byte type inside of a Nullable array
but i'd like a different syntax
i dont know what that would be though
its the same type of situation like in C/C++ with pointers and references
fun something() -> Array<Byte>? {
}
the long time war of
int* pointer;
vs
int *pointer;
or
int * pointer
i like int*
because it is a reference to an int
although it can be seen another wway
yea i prefer int* too
because when you think in your head it sounds technically correct an integer pointer as a type
haha right
but
nvm
"a pointer to pointer with an int value"
⚰️
pointer hell
Is bad?
LBPlayer data = MainEngines.getPlugin().getManager().getCached(target.getUniqueId());
scheduler.runTask(MainEssentials.getPlugin(), () -> player.openInventory(getInventory(data)));
});```
When I open a menu extracting information from the database, do I do this?
should package names be uppercase or lowercase
Lower
....
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
who the fuck harassed me into doing it otherwise
months ago
"tHaTs NoT pRoPeR nAmInG CoNVeNTIoNs"
sure
your code could improve but the idea is correct
Can you help me improve this?
example.
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?main yours is eh but still not good
MainEssentials
still
still a bad name imo
Essentials or EssentialsPlugin would be better
stop stealing my words
lol
Is a private plugin
Why just not shading jar and using classes
What
try {
LBPlayer data = MainEngines.getPlugin().getMySQL().getData(target.getUniqueId());
} catch (NullPointerException exception) {
player.sendMessage("§cJogador não encontrado.");
}
});
scheduler.runTask(MainEssentials.getPlugin(), () -> player.openInventory(getInventory(target, data)));```
How do I pull data from the database async and pass it to the menu?
I can't get the menu to open in async, it returns an error.
How can i get an offline players uuid
OfflinePlayer#getUniqueID
anyone know how to get around
Bukkit.getPluginManager().addPermission(new Permission(key, description, TRUE));
Bukkit.getPluginManager().removePermission(new Permission(key));
Bukkit.getPluginManager().addPermission(new Permission(key, description, FALSE));
failing to change the permission default to false?
The actual code I call is here: https://github.com/ProjectG-Plugins/CrossplatForms/blob/main/src/main/java/dev/projectg/crossplatforms/handler/SpigotServerHandler.java#L79-L94
And an example of me calling that code is here: https://github.com/ProjectG-Plugins/CrossplatForms/blob/main/src/main/java/dev/projectg/crossplatforms/interfacing/java/JavaMenuRegistry.java#L39-L77
Using PermissionAttachments isn't ideal since I don't actually want to manage players
Use the vault API
and just to clarify - going from false to true works, but going from true to false doesn't happen
recalculatePermissionDefaults is always called when your register a permission (unfortunately already tried)
ill try that first one though, thanks
Not sure if it'll work since leaving the server and rejoining doesn't fix the issue, and I assume that would essentially recalculate perms
Why would you use essentials
this.getCommand("minecoinsclear").setExecutor(new minecoinsclear());
??
wait its the plugin.yml nvm
plugin development is fun they said
yeah its definitely fun especially when you fix one error MORE ERRORS POP UP
welcome to programming
ur literal error says it cant get a configuration value so its marking it as null.... ( From what i can see )
programming has its upsides and downsides. the downsides are how aggravated you will be when your code keeps failing and you run into more and more errors when you fix the other one
yeah i know
anyway
but when it finally does work
hm
oh is it satisfying
and then at some point it works and your code looks like shit
but when something works first time, best thing in the world
even more of a serotonin boost than the 12 cans of monster i drink to keep me awake during coding
really random and ik you're all probably gonna get mad at yell at me and probably start screaming at me saying "learn java" knowing this community,
But how do you get a player variable in a gui? I've tried a ton of things but apparently none of them wanna work, So i was wondering on what the hell im doing wrong
🤷
I tried casting player to the code but apparently that doesn't wanna work
i tried google apparently that has no info,
meh
is it a hashmapped or something variable?
For instance i wanna check if this is false or true:
"Quests." + p.getUniqueId() + ".Ore Miner Status"
But apparently its the p.getUniqueId() issue where it doesn't wanna work ig 🤷 idk it just keeps saying the player is null but yet i have this above all the code in the gui:
Player p = (Player) Bukkit.getServer().getPlayer(getName());
ye
I dont understand you
well the point of the variable is to check if the "quest" in this case was started or not,
So i wanna use a gui to change the item lore if its enabled or not
if
Player p = (Player) Bukkit.getServer().getPlayer(getName());``` is above all your code
you need to define the player in your function
Where is this being done
No no like
Event?
ill show u what i mean
public quests() {
inv = Bukkit.createInventory(null, 45, "Daily Quests");
Player p = (Player) Bukkit.getServer().getPlayer(getName());
inv.setItem(10, createGuiItem(Material.GOLDEN_PICKAXE, ChatColor.GREEN + "Ore Miner", ChatColor.GRAY + "They say only the best", ChatColor.GRAY + "miners can complete this quest!", "", ChatColor.GRAY + "Quest Type: " + ChatColor.YELLOW + "Challenging", "", ChatColor.YELLOW + "Click to start"));
}
Bukkit.getPlayer will return null if that player doesn’t exist
yeah
Yeah and im trying to fix the null issue, thats occuring apparently,
Yeah but im not using Bukkit.getPlayer im using Bukkit.getServer().getPlayer() etc,
Same thing
Alright well how can i go about fixing this?
Make sure getName matches the name of an online player
does Quests() get called from an event or command?
?paste send full code of what doing
where is Quests() getting called
private Inventory inv; <- The "inv" thing gets called through a command
which then opens the gui and stuff
hmm
Omg i cannot understand he mixed many things together
uh thanks ig??????????????
alright i cant exactly decipher how much of this works
All of it works just the only thing that doesn't work is the getting the player
bc it returns null for when i open the gui and stuff
but you could try parsing sender.getName() to the p variable in quest()
@manic crater paste full code of project in ?paste
Just check and cast sender
Where?
No need to mess with getName
your project is one class?
Dude the project isn't even that big
the project is like 2 seconds of someones life,
ig
@sterile token right here
Lol, really strange the code
but putting your stuff in separate classes will make your life a lot easier
ik
it shortens the amount of code on your screen at one time and makes it more organized
Alreayd answer
Ik then i asked if i can have an example
well i assumed i needed that, or else it wouldn't work regardless,
if i just write public quest() intellij brokes
if (e.getWhoClicked() instanceof Player player) {
// do shizz
}
Where is the inssue caused on Event or Command?
that is no where close of what im looking for an answer 2,
Player p = (Player) Bukkit.getServer().getPlayer(getName());
^ This returns null and apparently doesn't work,
so im trying to see how i can fix that null issue.
Where does your getName() came from?
I cannot find it on code
if you need a player object then use offlineplayer instead. And there is no reason to cast except between player and offlineplayer lol
Yeah but the thing is though,
its in a GUI
and i wanna use variables in the gui
ok what does that have to do with using offlineplayer?
.
ok so let me get this straight,
casting player to a string means they are an offline player
yes?
He???
you can't cast player to a string
well i dont know,
Hmn....
if the method isn't getting a name to begin with there is no player object referenced
however you can reference players by name using offlineplayer
okay but how do i get a player object referenced?
even if they don't exist
check if they are online first by using the Bukkit.getOnlinePlayers()
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/Plugin.html#getName()
this is what you're calling...
otherwise, stop ignoring me and just use offlineplayer
bro what im not even ignoring you lmao
offlineplayer has a method where you can check if they are online as well as you can cast if necessary if they are online
getPlayer will return null if they aren’t online
oh ok i c now ok ok,
Yeah but if they open a gui shouldn't it detect if they are online?
Yeah he is calling a method "getName()" that he should have an error in his IDE
getName is getting the plugin name in this case
Your likely don’t have a player with the same name as your plugin
I dont have an error in my IDE because eclipse says other wise,
hm ok
Lol no it’s not
getName is perfectly valid in this context, it’s just not what they want
if the method is valid then there shouldn't be errors even if it isn't the correct method to be using 😛
🤷
More people need to use offlineplayer though, solves all kinds of problems for a lot of stuff
Alright mr frostalf
since a lot of people forget to check if a player is even connected to begin with XD
I still not understand your code dishyt
im willing to try your offline player strategy, i just would like a bit more input on how to do so since i dont mess with offline players
its ok ig 🤷
private Inventory inv; <- from this thing
p.openInventory(inv); <- See it opens the gui and etc
Player implements OfflinePlayer.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/OfflinePlayer.html
you can cast Player to OfflinePlayer
declaration: package: org.bukkit, interface: OfflinePlayer
and vice versa if you wanted
Why are we using an OfflinePlayer
Their player is clearly online if they are opening a GUI
yeah idk colf but im willing to try frostalf's idea
cuz you never know it most likely could work
If where you i would separate all code and send paste md5 again
I don't know what exactly they are doing. From the method it was returning null, which generally means a player isn't online. I don't care if people want to do something in a certain way but what I can do is tell you what methods will help accomplish it or avoid errors 😛
if they want to show a player regardless if they are online, OfflinePlayer is the way to go on that
Yeah it returns null because they are trying to get a player from the name of their plugin
Well either way, I gave another option 😛
The code is very odd, I agree
Sometimes it isn't important to understand the code
I dont agree, you must need to undertand the code for helping if its impossible to help
Not really, you just need to understand what they are trying to do 😉
ok its either im really terrible with doing offline players or not but i kind of need help getting the player from the offline player thing
dishy, have you separe the command and the event to dif classes?
after Coll explained to me what it was that was being done wrong, probably don't want to do OfflinePlayers lmao
OfflinePlayer#getPlayer
not really, you been helping me the entire time so i wouldn't claim its "impossible"
Oh okay, so then what should i do then?
Are you looking his code? 🤔
I just saw the one method that was returning null 🙂
https://paste.md-5.net/axawaxifuq.java thats the link again if u wanna look at it
I straight recommend seeing the complete code
I would create the inventory when you need it (in the command)
Then you have a player available to use (the sender)
Seeing code he never call method dailyQuest() - Starting from there
just change this
Player p = (Player) Bukkit.getServer().getPlayer(getName()); to
player p = Bukkit.getPlayer(String Name); or
player p = Bukkit.getPlayerExact(String name);
No need for the casting
ideally from an event is better as coll is saying
or the command stuff
If I have an inventory that’s contents depend on the player I generally create it as needed
Whereas a static inventory can be cached at startup
we will probably still be here 😛
probably
but ill let u know whats up in a few seconds
no errors so far in console
sounds like progress 🙂
Honestly thank you all so much
Wooo!
This means a ton to me, thank you for all the suggestions i know im a noob at this stuff, but
fr honestly tysm <3 and i hope the best comes your way!
private void PlayerItemHeld(PlayerItemHeldEvent event) {
Player p = event.getPlayer();
p.sendMessage(String.valueOf(p.getInventory().getHeldItemSlot()));
}
``` having an issue where the variable im getting is the number of the previous slot held except i need the current slot
anyone know how to do that
ignore the send message thing
thats a debug thing
Event.getNewSlot
declaration: package: org.bukkit.event.player, class: PlayerItemHeldEvent
aha so my monkey brain was doing the wrong thing
thank you
I want to make an item that when you right click you are invulnerable for 20 seconds
Does anyone know how to do it?
How do I use setLore?
Type mismatch.
Required:
(Mutable)List<String!>!
Found:
String
im4.setLore("test")
?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.
?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.
yes, replicating the command i sent will get you the same output
declaration: package: org.bukkit, enum: Material
Nvm
Is there a way to get only the items in the hotbar section and then only the items in the non-hotbar inventory section?
I imagine it's just down to indices.
yup
[0, 9) is hotbar
oh really? would've thought 10-36 (or something like that) would've been hotbar
nope
hotbar is [0, 9) and then the rest of the numbers start from the top of the window
Btw what do you call the non-hotbar contents
i don't usually distinguish
it's all just inventory contents
Yeah but I need a method name that isn't as misleading
dang
in a game where hotbar/inventory are different things you'd have inventory contents and hotbar
but in minecraft they're one concept
it's just that the hotbar has quick access
Hey there, for the past few years I've been using this MySQL setup https://pastebin.com/RYzEbsgP
I'm curious if anyone has a more efficient method of doing this?
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.
Yeah there is
That's not configurable to begin with
And you can use a wrapper or something
Alright thats easy enough
I have a library that helps with this sort of thing
You could be like
SQLHelper sql = new SQLHelper(SQLHelper.openMySQL(db, user, pass));```
It also makes config very easy
Hmm interesting- would you mind sharing?
What do you wanna see
Yeah that's the library it's massive
There you go ^
Sweet Ill have a look thanks
Take a look at the wiki
It's probably one of the most useful Spigot libs atm ngl :p
It documents all the major features
Although I don't use it cuz I don't like I don't like having the command API in my jar when I use Lamp
You can use minimize jar
Good lib: https://github.com/Revxrsal/Lamp
Or use RedLib as a plugin depend
Nah I don't like declaring dependencies
As someone who used to play modded Minecraft
I would run into the common issue of downloading mods without checking deps
:)
Then you can use minimize jar lol
Hey so if a returned ItemMeta is null, how am I supposed to set the display name?
It shouldn’t be null
As far as I know it shouldn’t ever be null
Aight okay then
I think it is on air?
That may be the case, but it seems unlikely that they’re trying to set air’s name
I can’t remember if the item itself would just be null if it was air though
I think it would be null
Well, yeah. Methods in inventory has notnull annotations so i always though they are air all the time
However... They're not
It has not null annotations but it definitely returns null when it’s an empty slot
It’s very strange
Just another bukkit api moment
is there a way to get which tree leaves are a part of?
I mean, in minecraft trees are just a set of blocks
They are not identified anyhow
They kinda are
The game keeps track of how far from a log each leaf block is
You could just find the closest log to a leaf
And that log belongs to the tree which "owns" those leaves
Not always… if you create a large oak tree and a small tree near, it would bug out I think
Stupid question, as I'm using RedLib, I also need to add it as a dependancy and install the plugin on the server?
Apologies I haven't used libraries before, I typically make my own mess
You can use it in one of two ways
You can install it on your server and add it as a dependency in your plugin.yml
That's the recommended way
Or you can shade it into your plugin's jar via your build system
If you have further questions feel free to join my support discord, it's linked in the readme for redlib and also its plugin page on spigot
But dont forget to relocate in that case because others might do the same...
Sweet thanks!
Is there any gradle compiler plugin just like maven-compiler-plugin? I'm trying to use this https://codehaus-plexus.github.io/plexus-compiler/ on Gradle, I can't figure it out.
What would you need that for?
I have an issue with using PlayerDataInfo class, I get bad RuntimeInvisibleParameterAnnotations attribute error on compile.
I found the solution here https://www.spigotmc.org/threads/cannot-access-net-minecraft-server-v1_16_r3-packetplayoutplayerinfo-playerinfodata.497496/
Are you using eclipse?
No, IntelliJ.
I don't know what to do with that 😕
Another solution: Dont compile against that class but rather use reflections.
Or use Method handles
or use a wrench.
Ever had the idea of making a plugin but realized a billion other plugins do it and also do it far better than your skills are capable of
I usually have the issue that my Take on the issue is Not good for gameplay
well, one of these days i'll circle back and may my plugins better.
i mean, like making them "open source"
yas, that is my current thinkin
but not until i can clean up the code
my goal is to open source all my plugins.
but give me time
they are not at that level yet.
and my goal is to make them like worldedit level
and then everyone can have them and fix them
maybe we can have a open source auctionhouse
someday
but lots of changes to be done to get ther
yeh
open source AuctionHouse
Is that possible to decrease player's reach? I heard something like that did minemen for a joke in one day
its gonna happen
and you can all PR request shit and stuff
but also
gonna' open source all my plugins
yeah.
oh.
wtf.
does that mean all of monkey's plugins?
yes.
padlock
AuctionHouse
IronBank
GoldBanK
PiggyBank
all of it
gonna post it.
All that source code.
It's soon, gonna be MIT
M fucking IT
MIT
yeh, means, well if you want to PR a fix for better usabilitty well then...
just don't critique me about the state it's in.
it you think you can improve it, just DO IT.
Hmm, you could certainly edit your messages btw 😅
I’m sorry to hear that
Yeah, trying not to be cruel, but well to some extent I still have to moderate
I hope you the best regardless, stay strong
👀
i have 380 cats to adopt
for realsies
just gonna let others decide what is best for that plugin
Wait, wait don'lt tell me......
oh, hey just got back from hawaii
is my new console here?
Steam Deck.
lemme check if it arrived.
still waiting for my steam Deck
Provided to YouTube by Epic
The Sweetest Taboo · Sade
The Best of Sade
℗ 1994 Sony Music Entertainment UK Limited
Released on: 1994-10-31
Vocal, Composer, Lyricist: Helen Adu
Guitar, Saxophone: Stuart Matthewman
Drums, Percussion: David Early
Percussion: Martin Ditchman
Composer, Lyricist: Ditcham
Drums: Paul Cooke
Keyboards: Andrew Hale
Tr...
yes fourteen def talking

should i make my command /vanish toggle FourteenDoggo instead of /vanish FourteenDoggo?
tabcompletion kinda sucks
Are there any references? I never actually used reflection to create a class object.
Class.class.getDeclaredConstructor(ParamameterType.class).newInstance(actualParameterValue); iirc
Guys how do I access config in another class?
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.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
I know there is an easier way. like go to Code > Generate
but cant remeber how its done
you just cant let intellij make code
o.O
well some parts, but not all
nvm I got it
do you guys have an idea to stop Tnt run from lagging
prevent tnt from igniting other TNTs
it doesnt
then how does it lag?
do you know whats tnt run?
I guess
well the tnt falls into the void
but it probably explodes before that
so I think cancelling the exploding event and replacing the block with air would do the thing
no need to replace any blocks, the tnt is an entity once it was primed
o
you can just remove() it
oh ok
edit the world file directly 
.. And get concurrency issues
then you are doing something wrong
wait is this actually good
or is it sarcasm
./fill ez
you can wipe chunks as an optimization
the best
but if you edit the world file directly youll need to reload it
true
how to do that
FileOutputStream fos = new FileOutputStream(...);
fos.write((byte)0x0);
fos.close();
``` the best method
ah yes
you unload and make a copy of that region, go async, modify, merge back, load, update
that seems way too complicated
@grim ice what kind of world resetting you need to do?
im not the one needing that
pretty effective with 300m bps
i just wanna know how is the best method done
If lets say you need to reset a skywars map, you could just keep the locations of all the blocks the players broke and placed
Then replace them after the game
or just never save the world and crash the server at the end
just keep a copy of the map somewhere and load it when it will restart
or never save it
but you will have to disable all autosaving shit
Server oftenly reads and writs region files. If you'll read or write the file used by server you'll definetly get problems
god I just can't stop writing the wrong syntax in foreach for c#
it just feels wrong
someone call microsoft and tell them to fix their language so it meshes with java
why was c# even created
because microsoft looked at java and thought "that's cool but what if we make it spicier"
i searched it and it was appereantly because sun didnt allow microsoft to make changes to java or something
Hi i'm sorry i have a mind blow problem, how the f*ck is possible to have my first loop in the for x = 1 and not 0 ?
for (int x = 0; x < interfaceOrder.length; x++) {
Material glass;
int glassLevel = levelSpace * (x + 1);
System.out.println("x:" + x + " countLevel: " + (x + 1));
if (job.getLevel() >= levelSpace * (x + 2))
glass = Material.LIME_STAINED_GLASS_PANE;
else if (job.getLevel() >= glassLevel)
glass = Material.ORANGE_STAINED_GLASS_PANE;
else glass = Material.RED_STAINED_GLASS_PANE;
content[interfaceOrder[x]] = new VisualItemStack(glass,
"§6Level §e" + glassLevel,
false,
"§6Reward(s):").getItem();
// Adding rewards line to lore
ItemMeta meta = content[interfaceOrder[x]].getItemMeta();
List<String> lore = meta.getLore();
for (String line : job.getReward(glassLevel))
lore.add("§e- " + line);
meta.setLore(lore);
content[interfaceOrder[x]].setItemMeta(meta);
}
here the output
what the hell
out of bound of interfaceOrder table
so it does include -1 then
yeah
-1
try this:
for (int i = 0; i < 20; i++)
System.out.println(i);
and see if it starts at 0
yep it work
normal
but what the hell am i doing in my loop to do this
it's just skipping the first loop but how ?
Could you please paste the code?
here
.
could you comment everything passed the sysout?
No, like in https://paste.md-5.net/
they're not doing anything meaningful before the sysout 🤷♂️
@tribal holly
x -= 1; <- ?
remove the x-=1
it was for testing sry
https://paste.md-5.net/dayiwijaci.cs here the good code with this output
So if one entry of interfaceOrder is not within bounds of content then content[interfaceOrder[x]] will throw an array index out of bounds
Originally Microsoft was going to register their own JVM implementation for licensing but then Sun Microsystem denied them such things for their implementation because Microsoft didn't follow the rules on something. Instead of Microsoft just scrapping what they created they decided to create C# with it.
ah
yep but here any error
my interface have a good display (but the x is one higher as expected)
it starts counting at 1 appereantly
can you count how many loops it does
int c = 0;
for (int x = 0; x < ...; x++) {
c++;
// ...
}
System.out.println(c);
It's the same as x
for (int x = 0; x < interfaceOrder.length; x++) { // Declares x and initializes with 0
Material glass;
int glassLevel = levelSpace * (x + 1);
System.out.println("x:" + x + " countLevel: " + (x + 1)); // Through some magic x is now 1
I do not believe that your console output corresponds to this code
what
??
i test without the loop count to see if i still have the prob
i change nothing and now it work
how
th
u sure you compiled it before?
https://paste.md-5.net/wukumevequ.cs the "new code"
yep everytime
yep
you are not using some weird JVM are you?
don't think
nah to run it
what jvm is the server running on
but i dont think thats the problem
You should really really consider using bodies wherever possible.
Because what you are doing is so incredibly error prone and hard to maintain.
what do you mean by this ?
i suggest looking into the problem because if this keeps happening when you release your plugin wont be good
use { }
ah
if (!condition) {
return;
}
if (condition) {
} else if (condition) {
} else {
}
well i saw some stackoverflow talking about this and there is two team with this
i dont use bodies for if (...) return;
One team is wrong
i see more calrity in the code when there is one line of execution
that's fine but it gets nasty if you add else or else if statements to bodyless ifs
You will never, ever see this in proper enterprise code.
Read the google java code style or read "Clean Code" by Robert C. Martin.
okay thanks i will
oops
are you still confused in how it skips?

lmao
yep still, the only difference is a restart server between these two executions
also i think that if (...) throw is fine
https://paste.md-5.net/geyukobeto.java this has to be the ugliest code ive ever written
i hate writing swing code so much
Swing is pretty glonky
well 7smile7 pretty much answered why it is happening lol
the bodies ?
don't think that came from here, i don't change the code and with a restart server it work fine
just what the hell java is doing
it is the way you are doing math using x
Take a step back. Try to present a clean reproduceable case. Then send both stack trace and code.
Dont pass null into the translateAlternateColorCodes() method
i don't arrive to reproduce the error, as i said when i restart the server with the exact same code it work fine
maybe the relaod function messed up my code i don't know
i see it now
hi how can i set {EntityTag:{Invisible:1b}} to item
I don't think you can. Invisibility is just living entities, no?
Yeah. Just living entities. Items don't support that tag, even in vanilla
Does the item entity have that option?
Yes
Unless they're referring to spawn egg items (because of the EntityTag there), in which case I don't think the Bukkit API allows for that because there's really no great way to go about it yet. We don't really have a way to modify the entity spawned in an item stack
nms.ItemEntity at least has the method setInvisible(boolean)
Not sure if it does anything.
This was 2 years before i started programming... I rly dont like readin my old code. Makes me cringe. And with old i mean everything older than 3 Months XD
classic
I have been using Java since nearly its beginning 😦
Poor frostalf... had to write code without arrows.
XDD
lol, I never minded doing all that stuff 😛
it was more fun though in those times to be using VB
Do you mean visual basic by VB?
Isnt that only used in excel? Never really looked into that language.
It is basically the predecessor to Visual Studio. VB allowed you to create applications in a visual way. Quite nice and handy
volatile barbarian
volumptous butt
XD
i should go sleep...
Whenever I hear of VB I think of the vb-style collections that I do Not understand
lol
VB scripts are quite handy on windows even today
they basically can do anything you want with great ease XD
on windows that is
Really, who the hell thought a string-indexed list was good idea
Isnt that just a dictionary?
Or a Map<String, Object>
(same)
You can also access it by index
hello does anyone know how to spawn a stack of an entity, each riding the one under it
So a Bit Like a linkedmap, but allows for random access
Sure. Just use a loop and mount the next spawned entity on the previous one
At least that is what I think it is
How to mount, thats the main thing, i tried the passenger method but its deprecated it seems
Why is it deprecated?
talking about VB Collections?
Yes
idk tbh
?jd Well, only one way to know
Sorry my bad its not depracted
Well I don't really know what they were back then, but VB is essentially .NET
currently look at the .net 6 api, it would seem the collections are pretty reasonable lol
my dad made a erp in vb6, then made it in vb.net and now making a web erp using angular + C#, man is in love with dotnet 😂
public <T extends LivingEntity> void spawnMobTower(Class<T> mobClass, Location location, int size) {
T tempEntity = null;
World world = location.getWorld();
for (int i = 0; i < size; i++) {
final T lastEntity = tempEntity;
tempEntity = world.spawn(location, mobClass, spawned -> Optional.ofNullable(lastEntity).ifPresent(last -> last.addPassenger(spawned)));
}
}
Something like this. (didnt test)
Lol, some people love dotnet
especially old peeps, i never had enough guts to show my dad java or other langs all he likes is windows
what I like about it is just if you want to make a simple window application dotnet makes it super easy to do so
yea
i made my first login screen in dotnet
which just checked if 2 textboxes had admin in them (not even case sensitive 😂 ) and then if it did it would close tthe app, (it was supposed to show Access Granted in the bottom but the app closes so fast)
Does ItemStack#serialize() miss anything? Like PDC or custom nbt tags?
Always used BukkitObjectOutputStreams but they throw a npe at the moment
Cannot invoke "net.minecraft.nbt.NBTBase.a()" because "element" is null
idk what that a() method is
I just want to serialize ItemStacks with gson. Usually i just serialize it to base64 but i want to be more resilient so
i thought about serializing the Map<String, Object> provided by ItemStack#serialize()
ItemStack#serialize() method isn't the same kind that Java provides
I know paper has a Method for this, but eh, that is paper
It uses DFU instead of Java serialisation however
Ill just update my spigot version and hope that its fixed
maybe you can open a report in JIRA for this (?
Oh wanted to say ItemStack#serializeAsBytes but thats spigot
But yeah spigot serialization is trash
How do I make an item unstackable?
Add a random pdc entry
?pdc
thanks
public static void makeUnStackable(ItemStack itemStack) {
ItemMeta meta = itemStack.getItemMeta();
meta.getPersistentDataContainer().set(NamespacedKey.fromString("custom:unstackable"), PersistentDataType.STRING, UUID.randomUUID().toString());
itemStack.setItemMeta(meta);
}
didnt test
not sure about the fromString part, I'd rather use a proper NamespacedKey using the plugin. But other than that it will definitely work fine
yes
sick
cool
Can you spawn structures using plugins, I want to spawn a pillager tower near the player
declaration: package: org.bukkit.structure, interface: Structure
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/Plugin.html#getResource(java.lang.String)
declaration: package: org.bukkit.plugin, interface: Plugin
oh just getResource?
There's a few different methods of doing it
To read them into a list<string> i always do this:
/**
* Reads a file from the resources directory and returns it as List of Strings
*
* @param plugin Plugin
* @param fileName File name
* @return A list of Strings of the file's contents
*/
@SneakyThrows
public static List<String> readFileFromResources(final Plugin plugin, final String fileName) {
try(InputStream input = plugin.getResource(fileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
return reader.lines().collect(Collectors.toList());
}
}
not always
pfff
its weird that the fastest and most optimized code always turns out to be longer than the simple slower code
not weird but like ironic or something idk
idk
You cant
No one likes spigot itemstack serialization!
i mean, a code can be both long and slow at the same time
If a code is simple and fast it requires no optimisation. If LoC is reduced in optimisation, it then becomes the default way to write the code, giving the illusion that efficiency has an association with longer code if that's what you call optimisation.
and how do i copy the resource
from getResource
basically
i want to put that file in plugin folder
saveResource
YESSSSSSSSSS
is it faster to read out of an enum or out of config?
I HAVE THE 100k RESOURCE ID
No real difference
