#help-development
1 messages Β· Page 1848 of 1
Im not too familier with cooldowns, Can someone explain why this isnt working? java cooldown.put(event.getPlayer(), (System.currentTimeMillis() / 1000)); if((cooldown.get(event.getPlayer()) + 1) >= (System.currentTimeMillis() / 1000)){ if (!isUsed(belowLoc.getBlock())) { event.getPlayer().sendMessage("hasnt been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setMetadata("UsedOnce", new org.bukkit.metadata.FixedMetadataValue(Trampotdi.getInstance(), true)); // event.getPlayer().sendMessage(event.getFrom().toString()); // event.getPlayer().sendMessage(event.getTo().toString()); } else { event.getPlayer().sendMessage("has been used"); event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(1.2)); belowLoc.getBlock().setType(Material.AIR); } }
the hashmap is defined at the top of the code
Nevermind! I might have some brain damage.
Heres both methods I tried π
here you are not checking if the entity is a player, you just cast blind. also what is PlayerChatProperties and what returns getGeneralChat? and you are adding player everytime what is unnecessary
also unnecessary to first add, and then remove if X is false. just add if X is true
and what is distanceFromPlayer?
I did actually check if the entities was an instance of a player this is just a past screenshot, PlayerChatProperties just holds the information of which chat a player is currently in, distance from player is the method that reads the defined int from config, which is suppose to be how far should the player be to see the actual message
also
The set returned is not guaranteed to be mutable and may auto-populate on access. Any listener accessing the returned set should be aware that it may reduce performance for a lazy set implementation. Listeners should be aware that modifying the list may throw UnsupportedOperationException if the event caller provides an unmodifiable set.
from docs
and Its a bit messy right now I kinda just butchered everything to try and get this working
did you check what distanceFromPlayer actually is? maybe its 0 π€
Anyone know how to Obtain the following?
block#getID();
block#getData();```
These are currently deprecated ;/
blockstate iirc
Version 1.8.9
In config it's defined as 20 and I did some debugging and it does get read as 20 in the code. Also here's the updated entities method. The one I was actually using.
blockState#getTypeID() is deprecated too
for what do you need the type id? just getType
and what was the result of your debuggings?
public static void setBlockInNativeWorld(World world, int x, int y, int z, int blockId, byte data, boolean applyPhysics) {
net.minecraft.server.v1_8_R3.World nmsWorld = ((CraftWorld) world).getHandle();
BlockPosition bp = new BlockPosition(x, y, z);
IBlockData ibd = net.minecraft.server.v1_8_R3.Block.getByCombinedId(blockId + (data << 12));
nmsWorld.setTypeAndData(bp, ibd, applyPhysics ? 3 : 2);
}```
needs a blockID
lemme guess, you just copied the method from somewhere and now you are trying to use it
Yeah.. it was on Spigot Free to use lol
First the distance Player method does get read from config so the number can't be 0 or null, second the method gets every player despite the distance, which is why im wondering if I maybe did it wrong..
i bet he wont
He taught me to code darling.. He will
but anyways, using the type id is fine. its deprecated because its a hardcoded value
so where does it fail
he's a close mate.. miss the man tbh
I don't know that's why im asking for help, I tried both methods multiple ways and did a fair bit of debugging but I still can't get it to work π
so what if its your #getGeneralChat method? what if you can't modify the recipients?
That isn't possible though because the playerChatProperties class is working just fine and I have modified the recipients before. The plugin works fine it's just im trying to add this proximity feature and I can't seem to get it working.
how can i transform a static var to non-static. or use a non-static var in a static context. or something like that
You can't access a non-static variable without creating an instance
As for transforming a static var to non-static just remove the static modifier if possible if not make your own variable and use that
for version 1.18 api do i have to install the craftbukkit and spigot, bukkit separately? I run buildtools as latest and the compiler imports only from spigot api, not from bukkit like Player etc.
using maven?
in 1.18, the spigot .jar only contains bootstrap stuff
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>```yeah
that is indeed strange
please show your dependency section on the right side
does it show the bukkit classes there?
open the spigotmc thing at the bottom pls
then send screenshot again
oh also - did you reload your maven config after adding the spigot dependency?
yeah
you mean that?
i cant open it
but on the left side
i have
but the craftbukkit
i downloaded using java -jar BuildTools.jar --rev latest --compile craftbukkit
there is no reason to compile craftbukkit
I haven't had it before, but I thought it shouldn't be like that, that I install everything separately.
there is ONE valid reason
when filing bug reports on spigot's jira
it asks you to also try craftbukkit π
so any ideas?
hm did you try File -> Invalidate Caches?
Hmm, still
what's considered a non-static context
Is it possible to create a hidden save file, so like a save file that isn't visible to the server owner?
everything that references fields / methods of the INSTANCE and not the class itself
no
Oof.
the server owner can always see anything if they want to
but
why would you even need that
why would you want to hide files from the owner?
are you up to something suspicous? lol
Ofc not lol.
thats what i was thinking lol
@tender shard with <artifactId>spigot-api</artifactId> works, but i need <artifactId>spigot</artifactId> for nms
Just want to make an alt checker that works with offline players, but don't want the server owner to be able to see the saved ips for privacy?
then your spigot artifactr in your local maven repo is probably the wrong one
try to run buildtools again
seems like you got the bootstrapped jar in your repo instead of the "actual" server .jar
and why would that file need to be hidden?
So the server owner cannot see people's ips in case they are evil owner?
But now that I think about it, if they know java they could just make their own plugin. .-.
in addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks); is the String name the actual permission?
the server owner can always see player's IPs
IPs are nothing special anyway
use my discount code on nordvpn to transcend this mortal realm of ips
internet wouldn't work without knowing each other's IPs
see? no problem in letting others know your IP
it would work just fine if you spoofed it
also just saying you can absolutely fuck with people by targetting their ip
I highly doubt that
only thing anyone could do is start a random DDoS attack
but, back to topic:
the server owner will always know player's IPs
and a general idea of the geo location
it's in th elogs anyway
my address is on my website anyway, so no problem for me lol
not everyone walks around wanted to get doxxed
and not everyone will start random DDoS attacks
@quasi patrol EVERY website you visit, EVERY gameserver you join, etc - they ALL know your IP
sure, but if you become even a z-list personality online you will get people who will actively seek out to mess with you in any way you give them
I mean hell I'm no one and even I already got doxxed a few times just because people were bored
reminds me of peeps who think a VPN is like a golden ticket to being safe
how do i instantiate a boolean
but say i already defined a bool, how do i insantiate one
you just make it equal to false or true
boolean is a primitive type
so you don't use the new keyword
boolean isFlying;
// Sets isFlying to true
isFlying = true;
// Sets isFlying to false
isFlying = false;
new Boolean
haha yes
wdym?
I mean sure... if you want to use the Object Boolean instead of the primitive...
sometimes it makes sense
e.g. if it may be nullable or sth
Β―_(γ)_/Β―
why does a boolean need to be nullable?
why not by default it be false?
I can give a nice example
or use the Boolean.TRUE/FALSE
If your lazy and want to have 3 states for something
there are no silver bullets for browsing online but in terms of privacy using a vpn is like step 0 of privacy 101
Boolean isSomePluginInstalled = null;
public void something() {
if(isSomePluginInstalled == null) {
checkIfSomePluginIsInstalled(); // This will set the boolean to true or false
}
if(isSomePluginInstalled()) {
doSomething();
}
}
touche I guess
Lmao
why could the boolean not already be false? the default most likely state without doing anything is that a plugin is not installed
or just have it check anyway
I've sort of come to understand that you can point to something in code or the world and get a true or false value from it
the null state of your boolean would be the init
if it would already be false, I wouldn't check again whether the plugin is installed or not
it is null when no check was done yet
afterwards it's true or false
there might be a better way, but yeah that's just a tiny example of why you sometimes want a Boolean to be null π
of course I could also just use two booleans instead
boolean haveIAlreadyChecked;
boolean isSomePluginInstalled;
but I think it's easier this way
java is picky abt static/non-static and i hate it
true internet privacy would be incognito mode + vpn that switches with each new search to obfuscate your behaviour
it has a very good reason
as the way you browse the internet is also collected
while it is bad practice because not being proper, you could technically use Null as a third state that doesn't use anymore extra resources π
you probably did not understand what static means if you think it's "weird" or if you "hate it"
static = you never intend to create instances of this and every reference of this variable is the same and always will be
static = it belongs to the class
non-static = it belongs to the INSTANCE
why use values when you can just use different types of null
it also means won't get GC'ed
oh ok
really?
yep
Huh, why?
it would be very bad if static got gc'ed lol
because it's static π
lmao, technically you could
if I fill a list with million integers and then clear it is that not GCed?
then what does Non-static field cannot be referenced from a static context mean
basic rule:
null, nuller, the nullest
If ANYTHING has a reference to something, "something" will not get GCed
wouldn't be proper or good design, but if you had to work against resource constraints that is an acceptable solution @torn shuttle
that's what I thought
yes and static things always have a reference
so by clearing a static list, those cleared vars are GC'ed
at least I would imagine so
I understand that reference
lol
help
you CANNOT access non-static stuff in static methods
and your understanding of it will always be the same too π
show your code @fleet imp
i need u to dumb it down a lot for me
I didn't say my understanding of that reference was final
static methods can be called with ClassName.MethodName, instance methods can only be called using an instance of the class
theseus' understanding, if the reference is the same but the value becomes different am I still understanding it the same way
to explain it in one sentence: static things are stuff you can always access, non-static can only be accessed if you have an object / an instance of your class
if the method is static and you try to grab a reference of an object or another method and they are also not static, the compiler will yell at you because you can't use non-static stuff in static methods π
like for example, you have a person
I could probably GC a static class by forcing the URLClassLoader to purge it
Does anyone know why FileConfiguration#save(File) might be failing me?
if it was dynamically loaded
I'm modifying an instance of a FileConfiguration and I'm trying to save it using that method
the age and the name of a person are associated with one special person. You can't just do Person.getAge() because the age depends on a specific person. However, we could in theory say that the planet of a person is always the same because we're all from earth, so getPlanet() could be a static method
lies, I'm from PLuto
for whatever reason I just can't get permissions to work and it's really starting to annoy me
maybe you're just drunk π
what isn't working?
Nah I'm just bored, it's a Sunday night :/
you can get drunk with me
they always evaluate to false
using Bukkit API or sth like Vault?
But I only have Vodka, and some Whisky :c
mix it with something non-alcoholic
bukkit
So, I'm making a plugin with the JDA and this method sends whatever is in a specific channel to the MC chat
public class Main extends JavaPlugin {
public long PostID = Said "channel" id;
}
public class msgRecive extends ListenerAdapter {
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if(event.getChannel().getIdLong()==Main.PostToMinecraft) {
Bukkit.broadcastMessage(ChatColor.DARK_PURPLE+event.getAuthor().getAsTag()+" said: "+ChatColor.RESET+ChatColor.BLUE+event.getMessage().getContentRaw());
}
}
}
does vault even let you do that?
Are you using a permissions plugin?
no
well.. that might be why
look at me , I am the permissions plugin now
the server does not store the permissions you give to players
I know
over restarts
this is impossible
do the impossible see the invisible
then how does spigot do it?
static members are stored in or with the class object at runtime
I mean technically class loading can cause static referents to be unloaded
Or well enqueable for gc
yes but lets not get too much into it
they wanted a basic explanation on what static means
True
Spigot has some fancy code for keeping track of plugin classes
Itβs not anything reliable regardless
when you unload them it will purge them
Like youβd have to rely on ::finalize which has some major flaws
so they are no longer referenced
so you're telling me that moving forward I should create all static objects by dynamically loading their classes in and out?
Does anyone know why Fileconfiguration#save(File) is not working for me?
any errors?
None
it just doesn'T save?
Just complete failure to save anything I have changed on the file
Do you save it to an existent file
nah that's just what I do
do you have that file open in some other programs?
I guess some code could help us find out about the error of well issue
Nope
windows can be weird when overwriting opened files
oop is cringe, static oop is the new hotness
I looked at spigots code for how it loads plugins and made my own version
so I can have a modular plugin
Yeah, oop overrated obv
yes fuck OOP
well yes, it just depends on inheritance of what is or isn't doing the loading or unloading but even then I suppose you could just drop down to JVM methods and really wanted to force it, but you will probably encounter a lot of issues or unpredictable problems XD
let's go back to italien spaghetti code
some people on the youtubes saying oop is dodo and we should all be using procedural
this is unironically all Unity devs right now
lol
humanFile = new File(plugin.getDataFolder() + File.separator + "humans.yml");
if (!humanFile.exists()) {
try {
humanFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
humanConfig = YamlConfiguration.loadConfiguration(humanFile);
humanConfig.createSection("humans");
try {
humanConfig.save(humanFile);
} catch (IOException e) {
e.printStackTrace();
}
}```
This creates my configuration file. It works as expected, and the "humans" section is created as expected
ECS it was
void addHuman(Player player) {
humanConfig.getStringList("humans").add(player.getUniqueId().toString());
try {
humanConfig.save(humanFile);
} catch (IOException e) {
e.printStackTrace();
}
}```
This is what I'm trying to do
tbf ECS is much faster, just like it is much more of a pain to develop
Yup one of the ways we used to handle gcing was with ::finalize but like sometimes you could by mistake make an object no longer gc reachable and then it was the problem on which thread finalize would run on.
I know I must be missing something very simple here, but it will not append the list with the values I'm trying to add
ECS?
I just don't understand why the list is not being updated in the file
yeah that's pretty much what the devs agree to
your code above shows you reading but never writing
ECS sounds like OOP with extra steps...
oh
Oh I see that
having done a bit of both let me tell you ECS is not oop
still just getting started with it though
I must implement methods but...
How can i make that?
and if you think ecs is weird and annoying you should see what trying to offload processing to the gpu looks like
Maybe click the blue underlined implement methods text
I've figured it out before, but that's what still won't implement x() π
Maybe you got a method which already matches the signature but different return type
also just on the topic of unironic oop sucks, the main thing that is usually brought up about it is how you generally can't create a class that is a subclass of two different classes
which does really suck tbf
I do not have
Well multiple inheritance would make Java a lot more complicated including the introduction of a whole new set of problems
Like the Diamond problem iirc the name
I understand why it is the way it is, but it doesn't make the issue suck any less
if java allowed multiple inheritance it would create more pain haha
Fair, guess you should move to not java
move? I was born in Java, molded by it
lol alright bane
Hmm run //undo maybe
I didn't even look at other programming languages before my spigot plugins were at a few ten thousand downloads
do you wear a coffee mask?
Idk it worked on my test server atleast
Yeah same
just one of those helmets that hold two coffee cups and straws
I also have a cool pit at the java island
Ever travelled to lombok?
every time I see lombok I just think bollocks
Lombok π€€
Lol
and I see lombok a lot
No Toby
hot
Toby, first it sucks, second it haunts me
π
getter I hardly know her
Coming back to the problem, does anyone have any idea?
@tender shard
Click on implement methods
It'll markdown the metbods you need to implement
s
You have to write code in it and return the desired types
Implement it manually maybe tusoo
Yes
It must be public
Read the error message
when it is void
so when it is boolean i have this
Make it void?
my soul is void
Or maybe youβve run into a compile time dependency mismatch
Oh I got a spare elytra in case you need
I don't want to get high but thanks for offering
And jfc ios why does autocorrect suck
Alrighty buddy
brah why it no work
Use luckyperms maybe
I can't
Ah that one hurts

Is it possible to get a Player instance even if a Player is offline?
What would you do with this instance @slow oyster
You can get an OfflinePlayer
Yeah I know, there's just some methods I need to use that use Player. I.e get their Inventory
Look at above @slow oyster
And yes I know about OfflinePlayer etc, it's just some API methods that need a Player instance
well that's lame by jdbc driver doesn't support #getBlob
I feel discriminated against
this is some form of data structure shaming
No you cannot have a Player object if the player isn't online
Thats why you need to create a registered player class like I sent if you looked at it
Nah it doesn't matter I needed a Player instance to get their inventory but it makes sense it's not possible to get it when the player is offline
But the json files are saved on the server
You cant get the items from the existing files
Yeah I need the Player for this method though: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/CraftServer.java#1320
That's the reason, it was a PR I made but now I'm realising it may need an option for OfflinePlayers too
Is it possible that players canβt use command blocks after there skin is changed through packets. Because I change players skin through packets and because of that they cant use command blocks
Wut
I made a system that change players to specific skins, but when there skin is changed they can no longer access a command block
I change player skins through packets so Iβm wondering if it has something to do with that
Oh thatβs a problem ok let me try that
ah yes, the client sided quirks of minecraft
gotta love how held together by duct tape and string this game is
for what
there might be a VehicleMoveEvent or something
?jd
Doesnβt work or I donβt know how to make it so they are recognized as op
I found VehicleMoveEvent
There doesnt seem to be away to get the player in the vehicle tho
I never played with those methods
But braindead like this
Look if the player coords match the boat coords
thats what i was thinking
Yeah I disabled the skin change and it started working again but after I enabled it back it stopped.
Iβm trying to retrieve a clicked inventory and want to store that inventory but the contents donβt update when the item is taken. Like if they take out a block at the index of 8 it will register the inventory before that item was removed. Iβve been creating a thread that waits 1 millisecond then returns the correct inventory. Is there a better way to do this or is the way I did it the only way?
Sorry if the codes a bit messy I was about to do some cleaning up before this issue sprang up π
Hi guys how fast is it the cloning of the itemMeta? I need to access PDC very often every time with a different persistenDataHolder
I think it is a detail meant to be ignored, or you can assume it to be fast.
why not store pdc as a local variable.
very often every time with a different persistenDataHolder
But I suppose pdc is also cloned with itemmeta right
^ Even if you want to access from the same persistent data holder everytime
sry! i thought u were talking about different PersistentDataType
Hi
check these sources.
but i don't think u can do anything about that.
@Overridden
@Override
public CraftMetaItem clone() {
try {
CraftMetaItem clone = (CraftMetaItem) super.clone();
if (this.lore != null) {
clone.lore = new ArrayList<String>(this.lore);
}
clone.customModelData = this.customModelData;
clone.blockData = this.blockData;
if (this.enchantments != null) {
clone.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
}
if (this.hasAttributeModifiers()) {
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
}
clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), DATA_TYPE_REGISTRY);
clone.hideFlag = this.hideFlag;
clone.unbreakable = this.unbreakable;
clone.damage = this.damage;
clone.version = this.version;
return clone;
} catch (CloneNotSupportedException e) {
throw new Error(e);
}
}
Thanks all of you. I think I will benchmark with some milli's to know if it is faster using reflection or the normal method
I will not touch reflection unless absolutely required for the task to even be possible.
why?
And you can trust that if both ways works O(n) time, reflection is most likely more expensive by a scalar
Meaning if you wont use reflection to change one prc
You wont use it to change multiple prc too
i don't think reflection is expensive after java 7 or 8.
oof
whats reflection
If it's cached it's pretty fast
Even if it isnt expensive, it is a bad se practice, increases coupling
Probably decreases testability too, if you ever do unit tests anyways
as the member org.bukkit.inventory.ItemStack.meta doesn't belong to nms, it's fine enough to be accessed with reflection.
That's just an interface
org.bukkit.inventory.ItemStack is a class instead of an interface.
Reflection has nothing to do with whether something belongs to nms
Oh right Itemstack is the weird one
because when it comes to nms or craftbukkit wrappers, things become complicated.
even the package names no longer change, they still don't guarantee their internal structures.
hi, I'm trying to fork a plugin that uses the chat component api, but I can't seem to download the api to include in my source. I went to this website https://www.spigotmc.org/wiki/the-chat-component-api/ , but clicking on "Chat Component API Javadoc" leads me to a broken page with no option to download the api. where should I download it from?
Its part of spigot
What is your dependency
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
this is what I'm importing, and it can't find the md_5 submodule
.
Ah sorry, what's that in java?
what interesting is, bukkit uses reflection in its own event executor.
so no need to worry about the efficiency.
EventExecutor executor = new EventExecutor() {
@Override
public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
try {
if (!eventClass.isAssignableFrom(event.getClass())) {
return;
}
// Spigot start
boolean isAsync = event.isAsynchronous();
if (!isAsync) timings.startTiming();
method.invoke(listener, event);
if (!isAsync) timings.stopTiming();
// Spigot end
} catch (InvocationTargetException ex) {
throw new EventException(ex.getCause());
} catch (Throwable t) {
throw new EventException(t);
}
}
};
What jar
I can give you the name sec
Also what mc version
1.18.1
spigot-api-1.18.1-R0.1-20211226.225430-20.jar
a blank plugin compiled successfully before in the same environment, so I believe I set it up correctly?
You can depend on the full jar instead and that should give you the bungee api
hm, I thought I did that? I don't use java that often though, so maybe I overlooked something
I do remember that I had to explicitly import JavaPlugin, but I wasn't able to do that with this
with this I mean I let my ide do it, I don't know what it actually did lol
spigot-api is just the api
You want Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar iirc
i'm looking for a simple solution of player request and acception. anybody knows?
Player request and acception?
something like invite and accept in chat.
Probably just a map that stores a UUID -> Request Object
The request object would contain the requesters uuid and any other data you need
whose UUID?
Like expiry time
The targets uuid would be the key
Or you could use a bi-map of just two UUIDs if you don't need any other data
You can create an association class
You would have to use a custom object with overriden .equals
A request class or sorts
when the inviter send a new request, i'll need to replace the old one with it. so requests need to be associated with both inviters' UUID and targets' UUID.
There is an error in NPCLib on version 1.7.10, can anyone help me?
NPCLib 1.7.10 error
mc 1.7.10??
u want the link...?
@young knoll sorry to bother you again, but now it can't recognise org.bukkit? with the first jar, I was able to import both spigot and bukkit but not the chat api, and with the second jar, it isn't able to require bukkit
and adding both jars doesn't work because it finds the spigot dependency in both jars...
That's weird, the shaded one should contain the full API
just add the jar u running the server with.
hmm
I mean I can try again
so to be clear, the shaded jar is supposed to have org.bukkit?
I see
eclipse still tells me that org.bukkit cannot be resolved to a module in module info, so I'm not sure what I'm doing wrong
for me i use maven to import the jar created by BuildTools.
it's called spigot-1.17.1-R0.1-SNAPSHOT.jar.
i mean, he will just need to import his spigot-1.18.1-R0.1-SNAPSHOT.jar.
I have a string of data in json format and I wish to send it to the player, however, it does not send (there is no output whatsoever) with Player#sendMessage, Player#sendRawMessage or in fact in Player#spigot#sendMessage even though it is a String, outputs fine to console, no errors - 1.17.1
Example of the string: {"type":"GLASS","name":"Block of Glass"}
I tried both files and I'm not sure if it works?
That should also work, but it has NMS as well
Share code
that would be guuuud
val serialized: String = ItemStackSerializer.serialize(player.inventory.itemInMainHand)
player.sendMessage(serialized) // does not send
player.sendRawMessage(serialized) // does not send
player.sendMessage("Hello") // does send
player.sendRawMessage("Hello") // does send
Bukkit.getLogger().info(serialized) // does send
the serializer I am using: https://gist.github.com/slohth/1472498381b7f4d269af535f68302ff1
this is an example of the logged serialized string
it just does not send to the player
Hey it's my 1st time writing a plugin and was wondering if any of you would like to revise my code and/or organization in intellij?
I'd love to hear criticism and maybe some helpful tips from more experienced users
gib code
i don't think it's correct to send a serialized item stack as a raw message.
i cant send files in here :(
verify when
Verify
!verify
Usage: !verify <forums username>
Or upload it to git or whatever
u might need to try a tellraw generator to create a raw message with correct syntax.
It's not an issue with serializing/deserializing, I've tested with numerous strings and it prints to console and adds the item to inventory perfectly fine with no issues
Try stripping off the { }
imagine lul
just post codes where you want us to see in gist
i dont think anyone would download it just to check lol
uh
Usage: !verify <forums username>
!verify SlamaPig
This account is already verified!
I cut the opening and closing braces off, and now it has sent to the player just fine, very weird
Perhaps Player#sendMessage just has an allergy to json format
Spigot (or minecraft) is probably trying to do something with it
well this plugin has no clear directive other than practice, mainly in efficient code and organization
I made a class to handle my itemstacks and another class for behaviours but not sure wether to lump them together or not
i treated it sorta like if I were creating a mod
possibly, most likely interfering with the syntax of a packet sent from the server
you can just remove it because it is unnecessary
You create a new ItemBehaviours each time
You shouldn't do that if you have no reason to
As you are running on 1.17, you can quickly cast and check in one line
if (sender instanceOf Player player) { player.whatEver }
not on minecraft 1.17, if you using java 16+ you can use patterns variables
oh yea
he is using java 16
1.17 uses java 16
So there is no reason not to use it in your plugins
List<String> wandLore = new ArrayList<>();
wandLore.add("Β§cRight Click Anywhere To Create TNT!");
Just call setLore with Arrays.asList()
Or the enum
is it possible to change a non-static var to a static var
Add static to it
put static word
i made this dohickey but it still doesnt like it static long channel = nonStaticVAr;
Well yeah, you can't declare it inline like that
You will have to assign it in the constructor or elsewhere
but i need the initial var to be non static or the method fails
But at that point, why is it static
Non-static method => non-static var = X > static var => static void
What
thats kinda how my program is going
It sounds to me like you are abusing static
bruh idk what im doing
You really don't need to be using static for much
Constants, enums, purely utility methods are some good use cases
I'm trying to get a setting from getConfig and that works, but that's not static (and Spigot API made that very clear). I need to use that var in a "static context" but it doesn't let me
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
its not
always bully the disabled
he is doing his best ok, leave him alone
this could be considered as a bug. couldn't it?
lets ping the admin
what
You pass an instance of your main class to any class constructor where you want to access your config
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
i did that but it still doesnt work
this is the err I got Non-static field cannot be referenced from a static contex
yes, because you should not be using static
access in a non-static way - Dependency Injection
but i need to do that for the method im doing
no you don;t
You cannot elevate a non static field or method to a static one
What are you actually trying to do
At a higher level
You are trying to access it static because you don;t understand when to actually use static
im using the JDA to send messages from a specific channel to the minecraft chat
what? i've used JDA and i don't recall it needing static stuff
i have it check if the channel's id matches the one in the config file, but somewhere in there it says its static
BUT I DONT KNOW WHAT IT MEAAAANS
static means global kinda.
static methods can be thought of as methods that belong to a class itself, and not instances of the class (object)
so a static method in a class doesn't have a this, and other such things.
No its saying you are trying to access it statically. Its NOT static, you need to use DI to access it
Hey everybody, I'm working on a network and the owner is looking to have something like this go on in chat. This is mineclub. Doing it with mods wouldn't be too difficult for a mod dev I would think but this is accomplished in vanilla. Any idea how they're doing it?
JavaPlugin#getProvidingPlugin or getPlugin will give you a static instance of your plugin @fleet imp
public void onMessageReceived(MessageReceivedEvent event) {
if(event.getChannel().getIdLong()==Main.ChannelID) {
Bukkit.broadcastMessage(stuff);
}
}
i need the config file, not plugin
The plugin has the config file
You get the config via the plugin instance
Custom font with a resource pack
AHAHA! I KNEW IT!
so getPlugin().geConfig()?
Tysm
JavaPlugin#getPlugin
will that return the config as well?
read teh DI link I gave you. Use DI correctly and you don;t need to getPlugin
would it be fine to use import static org.bukkit.ChatColor.translateAlternateColorCodes;
no thats a method call. You don;t import methods
correct uses of static import https://www.geeksforgeeks.org/static-import-java/
GL says otherwise
GL?
example?
oh wait importing specifically a method ok nvm
ok
ok
You donβt have to import a static method but you can if you want to use it without specifying the class
Yes thatβs fine
im starting a server to test rn
Itβll work
but i had thought so since i had no error compiling and such
Yeah
Itβs valid syntax
It means youβll be able to do translateAlternateColorCodes() instead of having to do ChatColor.translateAlternateColorCodes()
Thatβs all
Yup thatβll do the job then
That is statically importing method calls
Itβs just statically importing all of them from the Math class instead of specifying one or two
Itβs the same thing
Confused the heck out of me when you said they couldnβt do it and then linked an article saying they could, let me tell you
π
In all the years I don' think I've ever seen anyone static import a single method.
i need help
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
is there an api method for comparing and updating keys in resources config vs data folder config
i am trying too create method in java for c rafting recipe but since there are many not primitve data types i am getting confused
?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.
If you are confused by anything non-primitive, I highly recommend those links
when i went on last link and searched method it gave me awarnign the the link might not be safe
nvm it was safe
From what im reading using saveDefaultConfig and copyDefaults will make sure that new options will get added to the plugins data folder config yeah?
saveDefaultConfig is a dumb copy
hey so im using better rtp plugin and it is taking 100 years for it to teleport you
any way how you can reduce the time that it takes to tp you to a random location
copyDefaults will update from the default
The docs on copydefaults are confusing i Cant tell if its saying it will overwrite values that were set by the server owner or not
just says they will be impossible to distinguish
it wont overwrite
item = new ItemStack(material,1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Β§4Pro Armour");
item.setItemMeta(meta);
item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,5);
//proSword = item;
sr = new ShapedRecipe(NamespacedKey.minecraft("pro_armour"),item);
sr.shape("DDD"
,"EAE"
,"EDE");
sr.setIngredient('D',Material.DIAMOND_BLOCK);
sr.setIngredient('E',Material.EMERALD_BLOCK);
ItemStack ingredient = new ItemStack(material);
ingredient.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL,4);
sr.setIngredient('S',new RecipeChoice.ExactChoice(ingredient));
},
public static void createProHelmet(){
Material material1 = Material.DIAMOND_HELMET;
ItemStack item2 = new ItemStack(material1);
ShapedRecipe sr2 = new ShapedRecipe(NamespacedKey.minecraft("pro_helmet"),item2);
diaCraft(material1,sr2,item2);
Bukkit.getServer().addRecipe(sr2);
}
i used the method wau to make this by seeing the docs but its not working π¦
is anyone online on 1.18.1 rn that can hop on a server for like 3 seconds?
did u call createProHelmet() on startup?
also //proSword = item; is commented out
i can
alr
yah
i only sent the code where i think there is an error
u didnt set ingredient 'A'
trying to get a player from PlayerDeathEvent and it seems i cant get the player
so im curious what i should do
getPlayer ?
Whatβs the issue?
π€·ββοΈ
i tried but its still not working and not showing any error also
you'll get used to it xd, the method namings are incosistent sometimes
on the javadocs it says get entity involved so i was thinking maybe its like if you die to a zombie lets say you get the entity but it returned player so i was like bruh what
might as well deprecate PlayerDeathEvent and replace it with EntityDeathEvent
ik it exist, not surprised if that event will be deprecated in the future
just like the player pickup item event
how do i convert Math.floor(tempTData.timer/3) to a string
i know its probably basic java but still
Double.toString
Or Integer.toString, whichever it is
Or just append a string to it
don't
you do String.valueOf(...)
appending a string to it has the possible side-effect of instantiating an entire string builder to append the value + the empty string, then returning the built string
( this is cuz string appending actually uses builders or dynamic calls when compiled )
Sure, but I mean if you have actual text to append
well then sure
so i have this thing that keeps the player in the air by teleporting them every tick and apparently this happens if you do that
Minecraft fly checks go brrrr
Or set a barrier below them or something
Does anyone know why this does not do anything?
public void onChat(AsyncPlayerChatEvent e) {
e.setCancelled(true);
Player player = e.getPlayer();
getServer().broadcastMessage("" + ChatColor.valueOf("#eb4034") + player + ":" + ChatColor.AQUA + e.getMessage());
}```
This is the full code
I'm trying to just make a simple chat formatter
Have you registered it
wdym
Have you registered the class as an event listener
i am a beginner, but this should work fine, right? public final class HexColors extends JavaPlugin implements Listener {
that's what i was missing! thank you!
there is a problem this piece of code does not show any error and also does not give the output i wanted π¦ can anyone tell what i am doing wrong?
?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.
So using saveDefaultconfig as well as copyDefaults is not copying over missing fields
saveDefaultConfig does nothing if the file already exists
copyDefaults is still supposed to copy over the missing fields no?
its confusing
I believe it only works if youβve explicitly added defaults
Why not just read both files and copy any missing fields
I was but then i read there was just this magic copyDefaults method to update it
But idk not working
hold up
CopyDefaults looks to be a getter
Well, the one is
The other one that takes a Boolean is a setter
Which is very weird naming
I know there is surely a way to achieve this with 1 method this is something any basic plugin would use
Well if there is you could be able to find it
And if there isnβt you should make an issue/PR
I think maybe I need to use Plugin.saveConfig after im going to try
yep that was it im dumb
So that works?
yep
like a charm
but heres something not working
public void onPearl(ProjectileLaunchEvent e){
if(!(e.getEntity() instanceof EnderPearl)) return;
Player p = (Player) e.getEntity().getShooter();
p.setCooldown(Material.ENDER_PEARL, (ConfigManager.PEARL_COOLDOWN*20));
}``` also players are the only thing that throws ender pearls right
Afaik yes
the cooldown isnt being affected
Probably need a 1 tick delay
Yeah wondering if maybe could set priority and that would change it maybe? just wanna avoid that if possible
mm ok
Hey, what should be included in the plugin shutdown logic? (onDisable)
Alrighties, I read somewhere someone was saying that plugins can cause memory leaks so I was wondering if it was related at all
Cheers
Hey, I'm making something with Maven, and i have my resources folder setup, it reads .yml, .json, etc.
For some reason, my plugin.yml will not accept the fact that its api-version 1.18:
*I've compiled it several times now
lmao
this is the life of a developer
i've been up for the past 15 hours redoing plugins! =)
youd think so
Why should it
dont feel guilty
Thatβs a valid key, itβs just not the key spigot expects
there is edge cases of this however with those edge cases generally it isn't the responsibility of your plugin to ensure objects related to your plugin are removed. But your plugin could create some kind of object on another plugin and due to that other plugins design have a flaw where your plugin doesn't bother telling it that its shutting down and now that other plugin has inadvertently leaked memory. But as I said in the beginning, in general or principle usually that shouldn't be the responsibility of your plugin to handle.
help pls
[02:36:54 WARN]: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'player' at row 1 [02:36:54 WARN]: at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104) [02:36:54 WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) [02:36:54 WARN]: at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370) [02:36:54 WARN]: at com.vomarek.hideitem.data.database.MySQL.setState(MySQL.java:62) [02:36:54 WARN]: at com.vomarek.hideitem.data.PlayerState.setPlayerState(PlayerState.java:41) [02:36:54 WARN]: at com.vomarek.hideitem.events.EventsClass$1.run(EventsClass.java:90) [02:36:54 WARN]: at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) [02:36:54 WARN]: at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:58) [02:36:54 WAR
Looks like you are trying to insert data that is too long for the column
i set the value and signature
any solution?
how to make switch case from this please im idiot (intellectual diagnosed illness of technology)
right click on if and click convert to switch statement
is there any packet for skin ?
and which do you think is more apt to finish in a short time?
Idk, depends on your use case
Can you store smaller data without that causing issues
Or do you need to store bigger data for everything to work
Is there a way to update a scoreboard objective for all Players ever joined in the server? I tried looping over Bukkit.getofflineplayers and from OfflinePlayer getplayer but it doesn't work (getplayer returns nulls which is normal) and then getScoreboard...
Ohh I see, thanks for the in depth reply π
Did it work
why its highlighted?
Ask your ide
ay yo what?
Its broadcastMessage isnβt it
case GRAY_STAINED_GLASS_PANE
yh
Yeah broadcast is a different method
thank you very much @quaint mantle @mighty sparrow
thank you guys
guys why i cant change skin of an entity player (npc)
i put the value and signature in properties of the game profile
and enable the second layer in datawatcher
but the skins are steve and alex
but other plugins are showing the skin correct
that was very funny
Lol
that is not funny
that is true
wha
β
no seriously
what should i do
that is true
I got the same.problem and went on another project
i dont want to make the plugin public or anything
did you send the packet to player?
i was messing around lol
spawn
and add_player
Mb im tired
spawn? dunno
metadata
i will send these
look at other plugin
dunno this
i think citizens open source?
im not good at reading others code
did you resend the player packet to all the other players
what ?
there is a packet, think its the tablist packet that keeps track of the player skin in regards for other players
if you update the skin on the player object, you need to send the tablist packet(still not sure if this this the correct one) to everyone else so their clients update the skin they see
otherwise the alternative is for the person whose skin was changed to re-log
what packet
I told you what I think it is, there is the link above for the protocol specs
tablist packet
sorry if I am incorrect in remembering which packet it is
PacketPlayOutPlayerInfo ADD_PLAYER ?
i send it
but REMOVE_PLAYER after it
cause i dont want it to be in tablist
let me remove it for a sec and test it
forgor break; π₯Έ
ok i removed remove_player
and it worked but
what should i do to remove the npc from tablist ?
not entirely sure lol
at least you have more info then you did previously
anyways that tablist packet is used by the clients to know information about the players that join
for instance, what skin they have π
this
βοΈ Just as you thought you defeated the Umbra, she reveals her secret ability... Behold, THE GIFT OF GIVING!!!! π
π Happy Holidays from the Umbra & @paradoxum_games team! Join #TowerDefenseSimulator between the 24th - 26th and redeem the code below for a special gift! π https://t.co/olVj42UbQA
391
2569
but they are in tablist
bruh this is #help-development
well the thing is, they don't need to be in the tablist
the packet just needs to be sent to the clients so that their client updates their info on a player mainly in regards to their skin
WAIT LOL
??????
literally 0 errors?
it worked but some skins are not working i guess wrong value and sign
thanks anyways
Well like I said you have more information to work with now
and a better idea where to look
roblox moment
So in my case, should i use a concurrenthashmap?
Basically it uses some locks to make it thread safe for write operations in regards to the concurrency level you supply to it. What are you doing specifically?
well first off, you shouldn't be using player objects to store in the map
second, do you need concurrent access to the map?
how should i use RegionAccessor to modify biomes of locations?
i've tried new RegionAccessor(), no constructor.. and then i tried a static refrence of it like RegionAccessor.setBiome(my location, biome);
also didnt work, couldnt make a static refrence to it
Why not?
And if im ONLY writing async to the map do i need concurrency?
how to delete lines of lore? i have few items and its adding itself to next lines
Wat
You know async is subjective
Like it just when some process executed on another thread than some other thread
However if that process was to be executed on the "some other thread" then itβd be executed synchronously in respect to that thread
But yea letβs say you do write and read from the map from different threads
Take the common pool as our backing pool for instance
well it is generally bad practice to store objects when the object itself is not necessary to be stored. You can store the player object, you just need to ensure when the player leaves the server however you do indeed remove it from the map
Having a ConcurrentHashMap would be crucial unless you go with the Collections::synchronizedMap which is extremely cumbrous
otherwise lots of bad things happen π
It's just a kind of cache instead of querying the db every time
And then for your cache mechanism, do note that Guava has caching methods too
in this instance, probably better to use Guava's methods in conjuction with your DB
will probably solve most everything in question XD
I mean a normal ConcurrentMap could work just as good
Like the CacheBuilder you mean?
That's just time based
Yeah itβs more for expiring caches
I know, just there is methods in relation to cache that is already setup to work with querying a DB π
Or if you need soft/weak keys/values
Yeah Ig
@tardy delta take a look at Guava's methods never hurts to have options π
not saying you need to use them, but it could be more ideal
There is a few different methods available, take a look at them all. Not call caches need to keep the objects around all the time you know
Well it has an automatic loading feature if you can supply a cache loader function
sometimes it is ok to remove the object from memory if it really isn't being used
doesn't mean the object can't come back of course
just bring it back when its needed π
Yeah well if youβre building something scalable thatβs more or less necessary
I'm doing that rn
After the user leaves
Yeah well technically you could just unload and invoke your removal listener when the user disconnects
Altho I found it good to keep the user around a little bit after in case itβs one of those spam join-leave users
Yea i was querying the user for removal 5 minutes after he leaves but most of the times that was just unnessecary
Like they don't come back in that time
Oh I just have a housekeeper/cleaner which I delegate cleanup to
Like it could be useful if you wanna create an api as well
Not erasing users at disconnect if the user is being used by some api dependent
Tho thatβs if this plugin of yours is gonna have such an audience
Nah
While this is generally acceptable for scaling purposes it starts to become necessary where you start removing objects not in use including player ones until they are needed in which case if you use Guava cache methods will bring back that key/value stuff automatically if its not present in the cache. This is also handy too because you don't need a separate load method to get objects in there, just invoke the cache.
Yeah why not
as I said I am not saying in what you should or shouldn't use. I am merely giving you options so you can better decide what it is you want
