#help-development
1 messages · Page 73 of 1
Can OnclickEvent and BlockPlaceEvent.setCanceled be used at the same time?
I have to execute the code without being placed when I right-click on LANTERN.
If you want to set a value for muted you need it as a field in the class not a local variable
however you can;t get the value of muted until its been set, and you won;t know when that happens
why are you not simply checkign litebans for muted when they try to talk?
you mean why im checking muted or not in runnable?
i need to store it that way
yes, why use a runnable? it should be memory persistent data from litebans.
plus
thats why im using runnable
ah
lets create a cache lol
are you checkign litebans every time they talk?
I don;t know litebans, does it have a mute setting?
yes
everytime they talk, place signs, make books, join with nicknames, rename items
xd
💵
how can i update placeholder?
every 5 orso so munties
could u be more specific?
i have placeholder in sidebar scoreboard (its smth like: Purse: %myplugin_coins%), if i die all my coins are divided by 2, but placeholder says still same value
Is it you who code the scoreboard?
anyone knows how to properly create a commandcontext in acf?
make a paste
can i somehow update that placeholder
it is but thats not what i want
When the player dies, or at regular interval just call PlaceholderAPI.setPlace.... again
So you'll have to figure out how to update your scoreboard
ah managed acf to work
Is an empty inventory slot null or air?
null if you use Itemstack[]
🆒 🌭
how can i make the public void createPlayer(Player player, Town town){ town to json?
i tried to use ```java
Gson gson = new Gson();
String j = gson.toJson(town);
plugin.getLogger().info(j);
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
the error is [10:08:21 ERROR]: Could not pass event TownAddResidentEvent to TownyMySQL v1.0 java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @5332f755
I want to make town into json or a string
?paste town fields
town having location?
gson doesnt know what to do with the locations WeakReference<World>
so write a typeadapter
this is the town.java https://paste.gg/p/anonymous/11d591581485428dbd8c88636f56fe0d
basically im trying to store the whole town information in a sql database
uhh i hope youre not storing json into a database?
whats so bad with that
just create a storage implementation for a database
im not reading it again from the plugin its so i can just get town information on a discord bot
its not going to be constantly read
maybe i just use independant things like name residents etc
and you gotta save your stuff in a very big varchar
which is not the point of a database
1 big varchar = bad
that town object is huge lmao
Say the people using yaml for flatfile storage
i'd create a townsettings class
do i?
if so where so i can punish myself
that is too efficent if done right
I'm having problems using CorpsReborn API, like getting the inventory on a corpse, if the event is cancelled, it will return null.
How do is I make plugin ok
Yes
Is there a difference between #getServer()#getPluginManager() and Bukkit#getPluginManager() ?
okay
Hey, I'm trying to only include 1 class(XMaterial) during maven-shade-plugin, but the final jar is tiny... what am I doing wrong?
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>com/cryptomorin/xseries/*</exclude>
</excludes>
<includes>
<include>com/cryptomorin/xseries/XMaterial*</include>
</includes>
</filter>
</filters>
No, if you take a look inside Bukkit's source code, it delegates all calls to the Server instance - so you should never use getServer().
CompletableFuture.runAsync(...).thenRun( this runs on the original calling thread? );```
Yes
Actions supplied for dependent completions of non-async methods may be performed by the thread that completes the current CompletableFuture, or by any other caller of a completion method.
This is what the docs mention (https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html)
is there a reason there is no PersistentDataType.BOOLEAN?
or are we supposed to use a byte?
hmm would work ig, only forgot the set the meta back on the item
also wondering if ItemStack::hasItemMeta is the same as checking if the meta is notnull
ij doesnt seem to understand that
it looks like it validates it, and most likely returns false if it's null
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
your map is either empty, or doesnt contain a mapping for the key
Hello can someone help me with some Plot Plugin for Version 1.17?
or the entry specifically is set to null... afaik thats also possible
but every player after joining gets assigned to hashmaps
No
getItemMeta will create it if it doesn’t exist
i can just check if the meta is notnull then 👍
second: which line does the error come from
here is error
in a class called aWelcome
welcome to #help-development
here are my debug messages from System.out.println
that code gives me a small but kinda dense headache ngl
also when i reload the plugin while im on the server hashmaps seem to be okay
can you paste this as text? either in paste or here, idc
dont wanna write it all out by myself
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
ive sent pastebin with my original message
that looks like the code i wrote nearly two years ago 👀
why dont you just have a map with the players uuid and an object that holds those three values instead of three maps
i honestly don't evne know what you're trying to achieve in the end
What does it mean for a headache to be dense
hey, I am trying to use Json to save custum data for a spigot plugin, I have some json knowledge however I have no clue how I can use java plugins to work with json
uhh saving and loading data into json format?
if i'm not completely dumb
and i am
public void test(PlayerJoinEvent e) {
if (e.getPlayer().hasPlayedBefore()) {
Bukkit.getOnlinePlayers().forEach(p -> {
hasWelcomed.put(p, false);
});
}
isNew.put(e.getPlayer(), !e.getPlayer().hasPlayedBefore());
timeLeft.put(e.getPlayer(), getConfig().getInt("time", 0));
hasWelcomed.put(e.getPlayer(), e.getPlayer().hasPlayedBefore());
if (e.getPlayer().hasPlayedBefore()) return;
e.getPlayer().sendTitle("§cWitaj na serwerze, §f" + e.getPlayer().getName() + " §c❤", "§7Życzymy miłej rozgrywki!", 20, 60, 20);
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_SPAWN, 1.0F, 1.0F);
}```
this should be like exactly the same
correct me if i'm wrong
i'm tired af
How to remove "Decoration Blocks"
its only when you are in the creative view
^
Thanks
yes correct, I'm trying to save basic info like a player's favorite fruit
i mean why not using the builtin config file then?
when a new player joins, other players can greet them and get rewarded
Anyone know of or has some open source code that uses the luckperms api, I want to have a look at it to get a sense of how to integrate my plugin with luckperms, and yes I have read the docs and getting started, just want inspiration
can i cancel sync repeating task
the question is.. why do you need like 20 hashmaps for that
yep
if its a bukkit runnable it's just cancel()
Why do you need to hook to luckperms?
just google the lp wiki
Permission shit
Hook vault
ok so ill have to use bukkit runnable instead of runnable
😉
yeah it's easier
that was my cat on my keyboard
I'll hook your mum
same
luckperms barely works with vault
or atleast it barely worked when i did it, a year or two ago
i hooked into luckperms in order to get the prefix of a group and change groups
my dev told me once that i shouldnt do one object as a value and instead do seperate maps for all values
screw vault, anyone know of a project?
Something…
xD
🙏
if you just want to interact with the player(s) once
hm?
You need a Map<UUID, Pair<Boolean, Pair<Integer, Boolean>>>
why is this polish
because it isnt a config, its alot of data I am trying to save, e.g player data and team data
why tf does he need a map? what is the need of storing the player
I am making a clan plugin
ask him, not me
whos he
he
Don’t actually do this
i don't even know what it means lol
DID YOU JUST ASSUME X GENDER
you did too mate
Yaml is not only config, it's for saving data
then just create another yaml file?
I'll use x for gender of individual
how can I work with this ?
ok BRO
check the docs for config files
definitely not satire
keep LGBTQ away from this server, this is a development server. If you want to promote your values do it somewhere else 🙏
i always say "he" to people in the internt in cases where the gender isn't instantly guessable. if it's the wrong one, people can tell me, and i'll apologize
lol
😶
I try to go with they
Okay so how do it without hasmaps
he is joking tho
@quaint mantle https://bukkit.fandom.com/wiki/Configuration_API_Reference
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
like i need to somehow store if player is new, if they welcomed already
thx ✌️
List<Bla> list = new ArrayList<>(){
public final Bla test = add(new Bla());
};```
Erm why can't I access test here (using list.test)? it's public right?
I want to use this to create a list of elements for looping, but also be able to access individual items
**I know add doesn't return the item added, just for explanation**
Player#hasPlayedBefore()
why do you need to store if the player is new?
that's what Player#hasPlayedBefore is for
you can also count players since plugin was installed, by just adding uuids to array
Anywho, whats the best way to get the instance of an api, such as handling the plugin not being enabled, different mc api versions etc
I would use a set
okay thats a good idea and how about timer? Is there any sense to have an individual timer for each player? Or just one global timer that is triggered by joining of new player?
By access I mean outside the class
i think he means in the config file
Sorry what ? What are you trying to do?
Have a list of items, but some items be accessed individually in a member variable
Isn't your code totally in red ?
Wdym? xd
Hi, Is there any alternative for YamlConfiguration but for Bungeecord api?
I have the same fu...ing question. Hahahaha
:)
Also not wondering to sound rude, but dont know how java works or atleast know the lang?
Yup, 3 years. I was just playing around, I know there is more ways, but I was trying to get it as compact as possible
Timar the problem is that you are using a prvate acess modified
Which doesnt allow using a method/field from an external. Class
Sorry but im on cellphone and i type prettt bad
I also not native english speaker i native Spanish speaker
oh, Intellij told me that so I made it private.
It seems I have to add the generics to the constructor for it to work
he wants the item signature no?
He want to call a method from a external class
So he wasnt allowed to
Don't worry about that naming, it's more a structural question
And the problem was that he is using.a.Private access modifier instead of a public
Shity corrector
Lmao
xD Thanks, it worked
Hm another question, should I use a singleton for my managers, or instantiate in plugin class?
don't do a singleton
What is the problem with a singleton?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
answer in there
yooo im here again, why this doesnt spawn the armor stand
are you sure it doesn't spawn? SetVisible false will also hide the custom name I think
hmm that might be the problem
🙏
registered it?
Any idea how to use the luckperms api to get the permission node of a command, yes I am reading the docs still
Is it a specific command or the command permissions from any plugin
Any plugin, so basically all the mapped commands and their nodes
can i disable the extensive logging of every mf thread mongodb does
its spamming the console
no idea, but maybe this guy does https://stackoverflow.com/questions/30137564/how-to-disable-mongodb-java-driver-logging
Not all plugins register their permission
and none do for sub arguments and such
LuckPerms overrides the permissions map and listens for permission queries, then it maps a permission node to each command
If I can hook into that then my problem is solved
Then you need to run all commands
It depends
and what about per user perms
Its only for commands, shouldn't that be irrelevant?
How to stop a running task?
like there is a timer for 30 seconds and for example i want to stop it with a command whenever i want
Bukkit.getScheduler().runTaskLater(this, () -> rewardAvailable = false, time * 20L);
If that doesn't work try this https://gprivate.com/60gzv
i want to add some stuff to nms classes there is any guides how to do that? I think it called patching isntit
You basically need to make a custom spigot fork
Forking spigot just always looks so fun
I still don't really understand relationship in between spigot and bukkit
wasnt spigot just a fork of bukkit or sum
Yea spigot is a fork of Bukkit but Bukkit is dead
Spigot, for whatever reason, still has a repo called Bukkit and craftbukkit that it maintains
And then applies spigot patched on top of those repos
damn
🤨
Some may say that
years old code, if good code, no need to replace
How to make Blue firework particle?
there is fireworkmeta afaik
thanks
i lookd into litebans api and i want to first check if player is banned and if not ban him but there is one problem
@Override
public void run() {
boolean banned = Database.get().isPlayerBanned(uuid, ip);
}
}.runTaskAsynchronously(plugin);
new BukkitRunnable() {
@Override
public void run() {
if (!banned) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "example");
{
}
}.runTask(plugin);```
how can i get variable "banned" in another runnable?
Why is this not running?
public class TabFunctionality implements Listener {
@EventHandler
public void onPlayerTab(PlayerCommandSendEvent e) {
Bukkit.broadcastMessage("PlayerCommandSendEvent");
for (String commandString : e.getCommands()) {
Command command = Bukkit.getServer().getPluginCommand(commandString);
Bukkit.broadcastMessage(commandString);
if (command != null) {
Bukkit.broadcastMessage(PermissionCheck.getPermission(command));
if (!e.getPlayer().hasPermission(PermissionCheck.getPermission(command))) {
e.getCommands().remove(commandString);
}
}
}
}
}```
I've registered the listener but for the life of me I can't figure out why it doesn't work
idk but im using this PlayerCommandPreprocessEvent
^ use that and cancel the event
oof alright
how?
I’ve not ever used litebans API but why are you using two runnables separately?
first of all
reason of why im getting boolean Asynchronously is that litebans throws exception if you do that on main thread
second runnable is that you need to run tasks as runnable or it will throw exception
i dont blame litebans for that issue
Call the other runnable in the first one
i just want to get "banned" variable
You can use CompletableFuture task
why dont you cache stuff
TaskChain 🙂
ew
love it
banned is only defined in the first scope, you need to declare it outside of the scope of the first runnable if you want to access it in another one
But he'll have to wait it to populate, and since it's asynchrous it's not beginner friendly
just use a cf or execute all your stuff async and go back to the main thread when the bool is found
why do people instantiate bukkitrunnables too :/
The method runTask(Plugin, BukkitRunnable) in the type BukkitScheduler is not applicable for the arguments (new BukkitRunnable(){}, BukkitRunnable)
what?
instead of creating the scheduler
That is fine
and gives error
Yeah call it in the runnable don't pass it as a parameter
all that nesting stuff looks weird
Yeah it looks messy but if done right it works
how?
scheduler looks much cleaner in my eyes
i cant understand what are you saying
first time?
wdym
that code hurts my eyes
ill clean it when fix
what does it wants?
?scheduling
Choose one way of calling the scheduler don't try to mix two
also you need ::replace instead of ::replaceAll
^
why
Terrible naming
No
ye
Should have been replaceRegex or something
Of course if you need to replace a char it's slower, but it's actually the most optimized string searching
i cant find any sulotion of my issue here
Well, except some special cases
I told you what the issue was
someone told me to mix it in one
Literally take this code and move the second runnable in to the first one
That's all
Don't change it
.
uhh whats actually the problem
Professional ignoring
He messed up using the scheduler while trying to change it for some reason
Yes
.
so like this?
new BukkitRunnable() { @Override public void run() { boolean banned = Database.get().isPlayerBanned(uuid, ip); new BukkitRunnable() { @Override public void run() { if (!banned) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "example"); { } }.runTask(this); } }.runTaskAsynchronously(this);
Yes
this is it basically?
damn that looks ugly
kinda stupid that PersistentDataContainer::remove doesnt return a boolean
PR time
never done that lol
whats abi?
Application binary interface
hmm yes
Spigot doesn’t like changes that effect existing plugins
No idea if changing the return type would break old jars
can you paste the code
how to modify block of Particle.BLOCK_CRACK
Hi! Do you know how to add heads in Deluxe Menus?
lets just do it like that then
the method runTask(Plugin, Runnable) in the type BukkitScheduler is not applicable for the arguments (Main, () -> {})
says this
uhh put smt between the brackets ig
you need to pass an instance of the plugin as well, not just the class
i dont see any errors lol
Probably missing a }
am I watching eclipse?
Yes
That's why there are so much bad spells around
yes
no
i just saved it now
and errors dissapeared
Eclipse moment 🗿
^ (I hated that IDE because of this, you can't learn from your errors cause you can't understand where they're from... So when I began programming that was a pain)
;-;
This is what that "emoji" makes me think of
not really an emoji
xd
i heard that looping all players in skript was laggy
will this be laggy too?
for example on 100 players
Well, it's not free in term of performance. But if you need to reach all players at once, there is always a time you have to loop them all
In that case it's not laggy if it's just some times
But to broadcast a message use Bukkit#broadcastMessage
instead
is there any other way to send message to all players online with permission "example"?
ik
Nop
so i need to check permissions on all players?
Loop all of them and send if they have permission
Bukkit.broadcast
isnt that laggy?
Does Bungeecord api have any alternative for the YamlConfiguration from Spigot????
that sendmessage was for example
yes
Oh which
same?
I want the class name which i should extends
hot
ConfigurationProvider
as i remember
Because i cannot find the one which i can extend and works the same as YamlConfiguration
That why but thanks Greened!
You'll finally need to make an interface, after x tries ^^
(I'm sure you've already seen this but it speaks of YAMLConfiguration so in case https://www.spigotmc.org/wiki/using-the-bungee-configuration-system/)
Oh ok
Because im trying to find the bungeecord file magnament class which you use it for loading files and doing CRUD operations (Create, Read, Update and Delete)
Not all code crashes servers
does this crashes?
Only computationally-expensive code will hinder your server's performance
And usually in massive amounts
or
Any code that intentionally "lags" / slows down execution
Such as Thread#sleep
BlockPosition blockPos = new BlockPosition(loc.getBlock().getX(), loc.getBlock().getY(), loc.getBlock().getZ());
PacketPlayInBlockPlace packet;
packet = new PacketPlayInBlockPlace(blockPos, -1, stack, -1, -1, -1);
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
entityPlayer.playerConnection.a(packet);
}```
does anyone know that the player is not being updated to draw an bow?
You're sending an incoming packet
You can't really do that
wdym
PlayIn means Client -> Server
You can't really do the other way around
In the worst case, you disconnect the client
in the best case, nothing happens
how can i make the player draw the bow then?
You can't
i mean
You can send packets to all other players saying that that player in specific is drawing a bow
make player x look like he's pulling a bow for other players
i mean this
That's a different packet
what exactily
I have just find some issues, that YamlConfiguration doesnt have any public constructors on Bungeecord api
But you don't need to instantiate that object?
is not that
Yeah metadata
Found PacketPlayOutEntityStatus on google
I want to recreate my spigot FileHandler into Bungeecord that why:
FileHandler config = new FileHandler(JavaPlugin, "file-name.yml");
config.reload();
config.save();
config.getString("bla.bla");
Oh yeah, unfortunately doesn't work like that. Did you try the tutorial I sent?
Anyone know how to get an entitytype ID?
Entity status is more for sound effects
You gotta mess with the registry
I'm also working on packets and I'm just trying to get entity type IDs
someone of these values what would be maybe to pull a bow
Oh ok i suppoused haha i wil ltake a look now. I was looking bungee api javadocs that why
for the Spawn Entity packet
Type VarInt The type of the entity (see "type" field of the list of Mob types).
private static final int ARMORSTAND_ENTITY_TYPE_ID = Registry.ENTITY_TYPE.getId(EntityType.ARMOR_STAND); // EntityType.ARMOR_STAND.getTypeId() apparently spawns a ghast??
TypeId is only required for SPAWN_ENTITY_LIVING
according to the NMS packet impl
So if you're using ProtocolLib, you skip that
Check around this area for how to convert formats to protocollib
wat
I'm using ProtocolLib, but I need the entity type.
How would it know what to show the player, otherwise?
anyone know some good tutorials for plugin development? I already know the basics about java and plugin dev and also database/config stuff but I am looking to learn higher level stuff now
It reflects the nms fields on the packet class
From Comphoenix: " indirectly, by telling it a player has right-clicked on an item, or directly by sending a play animation packet.
Unfortunately, like a lot of places in the protocol and for little good reason, it's the former. The server sends an ENTITY_METADATA (40) packet setting the 4th bit in the flag metadata that indicates the player referenced in the packet is performing a right-click action. When the player releases the bow, a new packet is sent to clear this bit."
I generally just recommend doing bigger and bigger plugins
I learned a lot from making a gta plugin
Messed with npcs, luckperms, storing player data, schedulers and all
Thats exactly what I am doing as of right now but I fee like theres a ton of features I am missing out on
yeah i see that
Then come up with challenges that force you to mess with those features
Can i dm you? I want to ask something private
Have a look at others' plugins. You'll see new things, wouldn't understand so it's new challenges to find!
sure
If you don't know how to do NMS mobs with custom pathfinders, focus on making a plugin that changes mob AI
thanks for the help guys 🙂
deal
public static void spawnEntity (Player player, Entity entity, String i) {
WrapperPlayServerSpawnEntityLiving packet = new WrapperPlayServerSpawnEntityLiving();
packet.setEntityID(entity.getEntityId());
packet.setType(EntityType.valueOf(i));
packet.setUniqueId(entity.getUniqueId());
packet.setX(entity.getLocation().getX());
packet.setY(entity.getLocation().getY());
packet.setZ(entity.getLocation().getZ());
packet.setYaw(entity.getLocation().getYaw());
packet.setPitch(entity.getLocation().getPitch());
packet.sendPacket(player);
}
Specifically, it's this: packet.setType(EntityType.valueOf(i)); which confuses me. I've been trying to figure out ways to make one entity look like another entity, but this doesn't seem to work.
@echo basalt
Okay so you just want a bootleg libsdisguise
Like it appears to be the incorrect entity, I give it the string ZOMBIE and it looks like an ocelot.
Kinda!
¯_(ツ)_/¯
lol
I mean I want to know how to do this for other purposes too, like later on I might want to summon phantom entities and whatnot
did discord image upload die again
https://wiki.vg/Entity_metadata#Entity_Metadata_Format
now and find out this flag metadata which indicates that the player referenced in the package is performing a right click act
can you show me where they get ARMORSTAND_ENTITY_TYPE_ID from?
That's what I need!
.
oh... eh? But Registry doesn't have that method....
oh fuck
what can I tell you
You can do some funny stuff
Or mess with reflections
For example, using reflections to loop through IRegistry
get the registry that returns entitytype
finding the method that returns int from entitytype
and calling it
then calling it for each entity type and tossing it on a map
hmm and that works too
Hm
Your resource pack is pretty
What is the difference between ACTION_BAR, CHAT, SYSTEM of ChatMessageType?
https://javadoc.io/doc/net.md-5/bungeecord-chat/latest/index.html
Action bar is the bar just above the hotbar, chat is chat and system idk
?tryit
System is from not a player
dang i love this elytra texture
@echo basalt solved it, but I do have a follow-up stupid question
int entitytypeID = IRegistry.ENTITY_TYPE.a(EntityTypes.ARROW);
etc.
How do I get the EntityTypes enum thing from a string? Like getting EntityTypes.ARROW from the string 'ARROW'?
nvm
o
shit
well hang on let me see if this other thing works
omfg
there must be an easier way to do this
Create a map 🤡
nooo
I don't want to write it all out by hand...
if this takes more than 30 minutes i might though
When you're engineer, you're lazy. And I already see me copy paste all the variables, and use some cool Regex Find-Replace to create a map lmaoo
I'm making a boat "step-up" effect where if a boat runs into a 1-high wall it goes over it (velocity needs to be conserved). The number is the speed of the boat each second. The runnable is created when the boat approaches the wall. For some reason the velocity sometimes suddenly drops off a few ticks after it approaches the wall, as can be seen in the screenshot. If anyone has any ideas as to why this happens it would be appreciated
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
public static void spawnEntity (Player player, Entity entity, String str) {
WrapperPlayServerSpawnEntityLiving packet = new WrapperPlayServerSpawnEntityLiving();
packet.setEntityID(entity.getEntityId());
int entitytypeID = IRegistry.ENTITY_TYPE.a(EntityTypes.a(str).get());
packet.setType(EntityType.fromId(entitytypeID));
packet.setUniqueId(entity.getUniqueId());
packet.setX(entity.getLocation().getX());
packet.setY(entity.getLocation().getY());
packet.setZ(entity.getLocation().getZ());
packet.setYaw(entity.getLocation().getYaw());
packet.setPitch(entity.getLocation().getPitch());
packet.sendPacket(player);
}
For anyone who wants to know
The code ^
this is the code to use
to make an entity (entity) look like any other entity, with the entitytype defined by a string (str)
whats going on? My events arent being called and the class is empty
Quick q: If I load a chunk as a plugin with no players in it, does that instantly start some sort of timer as to when the chunk should unload?
Did you registered the class?
when im doing e.setCancelled(true); in signchangeevent sign is not dissapearing why?
text is appearing also
yes,
To cancel the placement of the sign, it's block place event
To remove text, change the text of the event to nothing
whats funny, is that my main class doesnt seem to have been used either, i remeber in my other projects intellij marks my main class as used/instantiated as well
but mine is grayed out for this on
e
Did you try adding a debug message on the event ?
Show the code
ill copy over the entire classes
?paste it
religiously i must use hastebin
Did you forget to put it in the plugin.yml?
Screenshots are a pain to work with. Hastebins also prevent flooding of the chat
hm let me check
i did refactor my code names and classes a while ago and im not sure if i updated that
how?
yeah the onenable is being called
How are you checking that your listener is being called
same q
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
becomes yellow when used
Put this.playerStore = new PlayerStore(); in onEnable
Your constructor is never called
how do I make the comments stay in a config.yml file? when the plugin loads up and creates the folder with the file in it, I can see the fields but not the comments I put in there
this issue has been bugging me for a while
still doesnt seem to work
Comments should stay in modern spigot
also why is listener class empty and not used by anything other than my class
its a marker interface
alternative would be for you to pass objects to registerEvents
You can ignore the color
which is just meh
but this is what it looks like in my other profjects
ill try runing the plugin again tho
ill add a sout call to see
You've told Intellij that @EventHandler means that it's used
It doesn't matter for the compiled project
oh
how can i make the third argument of a command red?
take args[1]
wait 3rd
args[2]
or whatever u named ur string[]
from the command executor thing
my command has only 2 arguments and I want it to be red when you put more than 2 (like the commands of many plugins)
setItemInMainHand to null
in the tab completion i mean
Make a custom tab completer
i use the onTabComplete but i didn't find how to make args red
Yeap
how to get player's swapped item?
Swapped?
Hello there,
I have a problem : When I registered a command in my plugin and started my server, there was an error. (java.lang.NullPointerException: null)
Console error : https://pastebin.com/rD9qwK4c
Main Class : https://pastebin.com/yQntnuyv
Command class : https://pastebin.com/siFJZMh1
Plugin.yml : https://pastebin.com/PDzHxhqe
Can someone help me please 🙂
Code
blocco.setTypeIdAndData(175, (byte) 3, false);
Only half of the plant comes out, how do I put the whole plant out?
ew legacy code
Gotta change the block above it too
Why is everything indented in the plugin.yml?
What do you mean ?
There are two spaces before everything
Oh ok I got it. I don't see that. Maybe it's IntelliJ which did that.
Ok thank you
I tested to remove them, and it's not working yet
it seems to be everything okay
Plugin.yml command name and api registrarion thru spigot
Is the same name
Like the command name is the same in the plugin.yml and in the api registration
Something else is happening
Do you have any decompiling tool? Like Luyten or JD-Gui
So then you can decompile the jar and see if everything is okay
I also do that when i have that type of problems
If not should be something related to registraion thru plugin.yml or api
Also something not related, but are u french?
Yes
My english is very bad lol
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
That gui should be useful for you to check
Oh ok
Im really sure that we are missing something
name: CasinoMoney version: '1.0-SNAPSHOT' main: fr.pr11dev.casinomoney.CasinoMoney authors: [ pr11dev ]
In JD-Gui I see that on plugin.yml
I will see than later
how to get player's swap item?
how can i send a hoverable message?
declaration: package: org.bukkit.event.player, class: PlayerSwapHandItemsEvent
yes
i dont need event
i mean
how to get item in another hand?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
PlayerInventory#getItemInOffhand
k
I thought getItemInHand was deprecated in favor of getItemInMainHand
They are probably depending on an old version
yes
what version?
p#getInventory lmao
p#getInventory -> PlayerInventory
PlayerInventory#getItemInMainHand
PlayerInventory#getItemInOffHand
i dont see any offhand
there is no off hand prior to 1.9
find that improbably
I don't think you replaced your 1.8 api
also if your switching to 1.12 might as well make the jump to 1.18.2 or 1.19.2
error now
don't reccomend the latter due to bugs latest stable I'm aware of is 1.18.2
Incompatible operand types ItemStack and Material
speeks for itself
is onDisable called on a reload? From my testing it's not. Is there anything else I can use?
simply don't reload
.>
good way to cause memory leaks and other issues
?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.
It should be?
public class Message {
private String message;
private final List<TextComponent> messages = new ArrayList<>();
public Message message(String text) {
this.message = Chat.style(text);
this.messages.add(new TextComponent(this.message));
return this;
}
public Message hover(String text, String hover) {
this.message = Chat.style(text);
TextComponent component = new TextComponent(Chat.style(this.message));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style(hover)).create()));
this.messages.add(component);
return this;
}
public Message open(String text, String hover, String url) {
this.message = Chat.style(text);
TextComponent component = new TextComponent(Chat.style(this.message));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style(hover)).create()));
component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
this.messages.add(component);
return this;
}
public Message execute(String text, String hover, String command) {
this.message = Chat.style(text);
TextComponent component = new TextComponent(Chat.style(this.message));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Chat.style(hover)).create()));
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
this.messages.add(component);
return this;
}
public void sendComponent(Player player) { player.spigot().sendMessage(this.messages.toArray(new TextComponent[0])); }
}
I'll try again ig
Nvm I'm just dumb. It is called
[20:45:24 WARN]: [Chat] Plugin Chat v1.0 generated an exception while executing task 22
java.lang.IllegalStateException: Asynchronous entity add!
what?
something is adding entities off the main thread
e.getBlock().breakNaturally();
it points on this line
Yes
is block entity?
no but what happens when you break a block naturally
and drops an item
a
beyond that
how to break without dropping item?
Also don't modify the world async
then?
so what to do?
Do it sync
don't interact with anything in the minecraft world off main thread unless specifically specified to be safe
^
with runnable things?
push a new runTask onto the scheduler
ah ok
Bukkit.getScheduler().runTask(this, () -> {
e.getBlock().breakNaturally();
});
like dis yuh?
👍
k
Wondering to learn this: If im not wrong block when you are breaking, placing, and etc, they are managed async or sync?
depends how do you do it
okay
Because logic told me tha tthey should be managed async
So then you dont have problems like ticks, lag, etc
mhm
im learning too
Because if you thought, many players breaking, placing block, dropping, etc all at the same time? That should take all resources i suppouse
Oh nice
if that did sound wierd
its because of my england
:DDD
english
Na dont worry is okay, im also a spanish native speaker so my english is even worst
😂
sync
minecraft runs on 1 thread
yes, minecraft isn't designed to be multi threaded
but you can make it work
with tasks that run next tick
ok and something else, if its designed to run sync, how does it execute async things?
what things?
minecraft doesn't do anything async
Some events, for example AsyncPreLoginEvent
ah, that is handled by bukkit / spigot
They usually deport computing that don't need to interact async
Let me translate this
😬
I'm French that's maybe the pb
You mean, change minecraft code?
oh no I get it
why is this bugged? p.getInventory().setItemInOffHand(null);
Move code that doesn't need to interact sync to a thread
Can u explain it in english-english timar - HAHAH
Exactly 😂
but yes that is handled by spigot itself
what is the problem?
better solution: bla.bla.setItemInOffHand(new ItemStack(Material.AIR))
lemme explain
when i have editable book in second hand
and edit it
it is edited
BUT
when i drop it
and get it
then
it is old text in there
non edited
- item not deleted when edited
those are 11 lines my man
can you maybe show some code ?
it seems as though the old ItemStack is getting dropped, and only then the item gets edited
if (p.getInventory().getItemInOffHand() == new ItemStack(Material.BOOK_AND_QUILL)) {
why isnt this check working?
how to check if its book and quill
you need to check against itemStack.getType()
itemStack.getType() == Material.BOOK_AND_QUILL
ItemStack represent the item itself, you can have two pens but they aren't the same, even if they're the same type. As timar said, you're looking to check for types
uh right
It is not smart to start learning Java with Spigot, that's why.
not saying you are doing that
yes ofcourse
first java tutorial:
if its not working try .getType()
yes
;-;
No, rather:
First Java tutorial:
Two instances of the same class are not necessarily the same.
I'm not going to spoonfeed you learn how to learn yourself
its part of coding
i already knew that it wasnt same
?jd
its part of learning the api
learn how to use the java docs as well mate
hte = the
Is there a way to make hostile mobs deal more damage?
yup
you can add a damage attribute modifier
@quaint mantle yes i want to do that but I want to make it so every mob that spawns has it
listen to the spawn event and give the mob an attribute
you cannot edit base mob values
pretty sure
Ok
how can i create a method that sets a random block on X location
have some collection that contains all the materials that are blocks, or stream then when needed and use a random to set the block type to blocks.get(random.nextInt(material.size()))
if i understand your question correctly
where can i get that collection
😨
this?
uhh ye smth like that
or Arrays.stream(Material.values()).filter(Material::isBlock).collect(Collectors.toList())
hello i'm using nms but is all obfuscated, how can i see the methods name?
Oh another like me which love using Lambda expressions and in-liners
When you are trying to upload a file which is inside a zipped or rar file, discord fail with that issue also
@tardy delta
Is something weird because while mc is not multi threaded, netty does it
HAha
always fun when it happens in native code
think it was sqlite
hmm wondering if i use completable futures in my onDisable, the server will wait for them to complete before shutting down the server?
ig not
this is good?
bruh store some of those variables
instead of new Random you can use Random r = ThreadLocalRandom.curren()
am i seeing Material.getMaterial(int) or whats happening there?
😨
you need to get a material from that collection by getting a random index
nextInt gives a number between -2.1 billion and 2.1 billion
i don’t think there are that many materials
and then asking the collection ::get(index) or use an array or smth
how does that compile?
might be me getting blind too
@dim palm just have a static List<Material> field
which you intialize with that stream method i told you
this? xd
yes
and later on you set the block type to materials.get(random.nextInt(materials.size()))
thanks
hey, so i have command cooldown system like this:
import java.util.HashMap;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import net.md_5.bungee.api.ChatColor;
public class Rtp extends JavaPlugin {
static HashMap<Player, Long> commanddelay = new HashMap<>();
@Override
public void onEnable() {
saveDefaultConfig();
}
@Override
public void onDisable() {}
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player)sender;
if (label.equalsIgnoreCase("rtp"))
if (!commanddelay.containsKey(p)) {
commanddelay.put(p, Long.valueOf(System.currentTimeMillis()));
} else if (System.currentTimeMillis() - ((Long)commanddelay.get(p)).longValue() >= TimeUnit.MINUTES.toMillis(5)) {
commanddelay.remove(p);
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou need to wait &6" + TimeUnit.MILLISECONDS.toMinutes(commanddelay.get(p)-System.currentTimeMillis()+TimeUnit.MINUTES.toMillis(5)) + "&c minutes before RTPing again!"));
}
return false;
}
}```
But problem is that when player executes command and it has cooldown and he cant execute it again because of cooldown, if he leaves the server and rejoins he can run that command again
i cannot understand why
If a player rejoins then he gets a new Player object. The old one is invalid then. Never hard reference a Player object. Always use the UUID of a Player.
aaa
Thanks
why uuid cant i use names?
"uuid is more flexible"
xd
if you hate yourself sure go use names but be ready for bugs
wdym
how?
why using names would cause bugs/
@EventHandler
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
System.out.println("Test");
Block furnaceBlock = event.getBlock();
ItemStack smelting = event.getResult();
System.out.println(smelting.getItemMeta().getDisplayName());
if (smelting.getItemMeta().getDisplayName() == ChatColor.GOLD + "Boom") {
World w = furnaceBlock.getWorld();
w.createExplosion(furnaceBlock.getLocation(), 5, true);
}
}
does anyone know why doesnt work? it doesnt even print "Test" in the console
names can change UUID's can not
so it only makes sense to use a UUID in every case
how?
🤦♂️ I'm done with you nvm
if account name will change wouldnt uuid will change too?
nope
unless you are using offline mode
i got the point
in that case cope nerd
it took you a long time to type that lmao
i have another problem about this code
skill issue
help perhaps?
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.
how to check if player has typed message since he joined?
god damn
what if i dont want to
what if i want to spoonfeed
jk jk
well anyway it should print "Test" to the console but it doesnt
the event just doesnt execute
damn thats crazy
frfr
on god never seen that before mate
Sounds like you didn't register the listener
+1 ^ mans
oh wait