#help-development
1 messages ยท Page 1457 of 1
then restrict it to less than 1.5gb
so how did it get to 1.9
cant
"the host is really generous"
How can I check if a player has permissions for a specific command?
you can't restrict it but it is limited
(If the command is a string)
literally what
its stuck on this command java -Xms128M -Xmx1500M -Dterminal.jline=false -Dterminal.ansi=true -jar server.jar
Player#hasPermission
ah
yeah that limits the heap to 1.5gb
but like does it work for the command, or does it have to be in permission format
you can also put the permission under the command in plugin.yml if you want to directly define it
an off-heap memory usage of about .5gb is fine
there is nothing to worry about there
is there a way to get the way a player is looking in vector form?
Location#getDirection
any issues you faced "because" of that are either the host being shit or you going crosseyed
nah the host is fine
it clearly isn't
idk java
if your server crashes with an oom after overallocating resources
is # a pointer
wot
nah its just a limit put in by pterodactyl
you mean something like Player#sendMessage?
you aren't supposed to allocate all of your available memory to the heap with pterodactyl
your issues are caused by a misconfiguration
which is unsurprising
just means you run the method on an instance of the object
talk to the host about it
vs . which usually references static methods
im not doing that lmao
and i think thats default
just allocate below the maximum memory
lol
pterodactyl does that
your host has given you 1.5gb of memory
you have allocated 1.5gb of memory to the heap
yeah but theres like a overhead bit
your system memory footprint consists of more than just the heap
so it can go over
then the overhead given to you isn't sufficient
and needs to be increased
by lowering the heap allocation
the overhead is like .5gb
yes
dude my jre uses more than 1.5gb even i only allocated 1gb
lmao why
because that's how native memory works
get more memory then
well yeah but this is just default settings in ptero
that doesn't mean it's right
anyway, i'm done with this retarded argument
do what you will
that is completely irrelevant
yeah but plugins use memory lmao
not really
why does mongo keep wanting to import from com.mongodb instead of org.mongodb
it just only uses the amount of allocated memory after all
i added the maven thingy
also tps is low on 1.16.5
no it doesn't
1.16 performs significantly better than 1.14
no for me
you have just configured your server like ass
at least it's better than 1.13
for some reason spigot 1.16.5 uses less memory
yes, paper uses somewhat more memory
but its still quite alot 1.11 GB
1.13 performs better than 1.14 mostly because of villagers and entity ai changes
im getting this error when I added an event:
https://pastebin.com/JtkiiKZC
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i have never gotten it before so im confused
1.15 performs better than 1.14 mostly because of villagers getting fixed
1.12 performs better than 1.14 because 1.13+ uses the shitty overengineered chunk system
look at Bedwars.java:27
wait how is it null
the manager could be null
1.16 has negligible performance degradations compared to 1.15 so it still performs better than 1.14
idk how ptero calculates memory tho
i need code to look at bruh
it calculates it poorly
this is the code:
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getMainScoreboard();```
the numbers it shows are irrelevant
i was getting it
it was working before
now its not
yeah but cuz its a free server on this host the tps and ram usage is high on 1.16.5
thats why i was on 1.14.4
yep
recompile it and restart your server
yes
why does mongodb want to import from com.mongodb and org.mongodb doesnt exist?
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.0.1</version>
<scope>compile</scope>
</dependency>
is there a way to make something the player is wearing invis? like I want to add armor that turns the player invis but I dont want the armor to show
wth, it worked
yo it must be some magic with /rl
or maybe your plugin load before scoreboard actually loaded
ok
so now, im getting a different issue
but its ez to fix i think
if i wanted to check all the teams and see if a team already exists how would i do that?
try forEach on getTeams()
wdym
actually just use getTeam()
oh i see
it will returns null if it does not exists
What event gets fired when a player leaves the server?
PlayerQuitEvent
oh yeah i just found it in the javadocs, thanks!
?paste
how would you make a fireball/tnt not do block damage, but only for that fireball/tnt
nvm
any clue why this didn't work?
@EventHandler
public static void onBlockExplode(BlockExplodeEvent event) {
event.setCancelled(true);
}
should i use players usernames or uuid to store in an arraylist
i would think uuid because you can edit usernames
if(e.getPlayer().hasPermission(e.getMessage().replace("/", "")) && ((Bukkit.getServer().getPluginCommand(maincmd)!=null))){
Currently I have this, I want to make it so that it responds with true if the player has access to the command and false if the player doesnt have access to the command/the command is invalid. So far it works, but it for some reason doesn't work with official minecraft commands. It only responds properly to plugin commands. Also, if the player isn't OP, then it returns false for all commands, even the ones they can do.
So I just need to figure out how to make it work for minecraft commands, and how to make it work for non-op players.
How can I make world border for only one person? another players cannot see it (Btw, I googled it. and I found only 1 thread. and person that replyed said "Google it. packet done." lol)
What packet should I use
and etc
Check if player is op return true
Ur using getPluginCommand which gets plugin commands I think XD
There is I think but yeah its not in the Server api
Oh
Well, I think this would do the same thing. Do you know how I can check if a command runs successfully or not?
^ this was it
for some reason this event isn't called when a block is exploded:
@EventHandler
public static void onBlockExplode(BlockExplodeEvent event) {
System.out.println(event.getBlock().getLocation());
event.setCancelled(true);
}
Yep, but it doesn't include MC commands.
Did u register it
yep
i think a bot is deleting your ur sure
Yep
I said u sure
It's cuz I tagged u
u sure
nope
the bot just doesn't like you lmao
Nah it's cuz I tagged a person before u
?
?xy
Asking about your attempted solution rather than your actual problem
@cyan bluff ^
wdym
Maybe that event only works with tnt
im testing it with tnt
Oh then idk
Uuid or IP cuz both is mostly static but then IP can change lmao
So uuid
this is so weird
the event isn't being called at all
event with large changes to the code within it
Maybe the name of the method is wrong
Basically, I'm trying to make a commandspy plugin. I have that part done, but I also want to make it so that the command appears green when the player has permission to run it, and the command appears red when the player doesn't have said permission. Also, if it isn't a command, then it's red.
I suppose checking if the command had run successfully would also work, but I don't know how to do that either.
some bad plugins will check their permissions via code, so that will cause false negatives
but the vanilla commands should work
one problem with your code is it uses getmessage which includes all arguments
I'm ok with that
Yep, I already fixed that by splitting it up
you need to split on space and check only the first part
ChatColor cmdc;
String maincmd = e.getMessage().replace("/", "").split(" ")[0];
if(e.getPlayer().hasPermission(e.getMessage()) && ((Bukkit.getPluginCommand(maincmd)!=null))){
cmdc = ChatColor.GREEN;
}else {
cmdc = ChatColor.RED;
}
ok this is very strange, this code:
@EventHandler
public static void onBlockExplode(BlockExplodeEvent event) {
System.out.println(event.blockList());
}
```doesn't work, but this code:
```java
@EventHandler
public static void onPlayerChat(AsyncPlayerChatEvent event) {
event.setMessage("Hi!");
}
``` does??????
is BlockExplodeEvent broken?
Nah it's probs not called onBlockExplode
u mean BlockExplodeEvent right?
?
the event name that im trying to call is this:
BlockExplodeEvent
which u can see inside the parenthesis
Dont make it static
How can I make world border for only one person? another players cannot see it (Btw, I googled it. and I found only 1 thread. and person that replyed said "Google it. packet done." lol)
It's packet based
public void onDisable() {
MongoCursor<Document> cursor = dbHandler.getDocuments("minecraft_ranks");
while(cursor.hasNext()) {
BasicDBObject filter = new BasicDBObject();
filter.put("id", cursor.next().getInteger("id"));
dbHandler.getCollection("minecraft_ranks").deleteOne(filter);
}
rankHandler.getRanks().sort(new IDSorter());
for(Rank rank : rankHandler.getRanks()) {
Document newRank = new Document("_id", new ObjectId());
//....
dbHandler.getCollection("minecraft_ranks").insertOne(newRank);
}
}```
I have this onDisable method (I removed some lines bc it's unnecessary)
It doesn't work because the plugins already disabled so none of the Mongo shit works.
Any work arounds?
I can't seem to find an answer for this anywhere;
Does anyone know how I can download things from the SpigotMC website automatically?
Spiget is able to get the resource information, but isn't downloading files for whatever reason
Is there any way to interact with the SpigotMC website without Spiget?
Any other APIs or anything?
Block explode is for when things like Beds explode. TNT is an Entity when it explodes
Your plugin is not already disabled when that method is invoked, however there are certain API calls which you can not access from it.
For example, you can not schedule any events.
lmao what is this
if(has permssion) send plugin list
else send plugin list
surely thats not intentional right?
looks like two different methods to me
well yeah, but both produce the same result
How do you know? I don;t see the contents of those methods
you can check the code yourself if you wish
org.bukkit.command.defaults.PluginsCommand
wait, do players have bukkit.command.version by default?!
I don;t see that code in teh class you mentioned
@Override
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {
if (!testPermission(sender)) return true;
sender.sendMessage("Plugins " + getPluginList());
return true;
}```
Bukkit
You didn;t say spigot
^
I'm not seeing the same code you are
what could stop an EntityDamageEvent from being called at all?
No annotation or not registered
trying to debug why the hell i'm not taking damage from natural sources, been at this for a few days
nah, it's definitely being called in general
or another plugin is cancelling it before you get to see it.
can't reproduce it on my test server, ignoreCancelled is false in my listener
Then you should be seeing it
all i can think of is god mode
but the player is not in god mode...
normal mobs take damage
only in a certain world as well
is there a gamerule?
๐
so what would be causing the error?
You havn;t shown any error, just said its not working
at com.orecraft.core.util.DBHandler.getCollection(DBHandler.java:23) ~[?:?]
at com.orecraft.core.util.DBHandler.getDocuments(DBHandler.java:46) ~[?:?]
at com.orecraft.core.Core.onDisable(Core.java:90) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoader.java:361) [spigot.jar:git-Spigot-596221b-9a1fc1e]```
return core.database.getCollection(name);``` Line 23
is it set as a depend in plugin yml?
either core or database is null
why would it be null tho? cuz the plugins disabling?
what
System.out.println(core.toString());``` this is throwing a NPE
private final Core core = Core.getInstance();```
You either havn't initialized it, or you are setting it to null before trying to access it in your onDisable
does it work other places than onDisable?
Yes
I initalise it in onEnable()
is it in your plugin.yml as a depend?
Core is just the name of my Main file
if you are in onDisable just use this
Really weird, just accessing database directly worked fine
have you loaded it once?
yes
then otherConfig.load()
what do I put in the load parameter
What?
FileConfiguration.load(file) or FileConfiguration.loadConfiguration(file) or something to load it
Give them a read once in a while?
and im just getting back into it
The Spigot JD is great, the search box is yoru friend
a decent IDE will give you java docs too in some way, shape or form :p
I just wish they added it to the Bungee JD
intellij doesnt give me javadocs
you can add them in yoru pom
<!-- Spigot Javadocs -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>```
Don;t use new Main
Main.java:125 perhaps
actually BlacklistCommand.java:25
so the issue would be in the command class mayb?
but why would that cause an issue
ive done that before
lol
show yoru registering the command
getCommand("blacklist").setExecutor((CommandExecutor) new BlacklistCommand(this));
why are you casting it to CommandExecutor
same format as literally every other command
You shoudl not cast to a CommandExecutor, it shoudl implement it
idk i made this a long time ago and am trying to update it
oh yea it does
lets go
thats unrelated tho
yep
did you forget to delete an old jar and you haev two copies on your server?
?paste your main else
hm
lemme try something
the name of the folder with the config n stuff got all messed up
idk why
so imma try resetting it
i bet thats the issue
I also recommend you rename your class from Main
Something relevant to your plugin. Usually the plugin name
Main is for stand alone programs where their entry point is main
Plugins are simply extensions of Spigot so have no Main
cause literally 99% of my plugin dont work now lol
true
lol
?paste your main
ah ok
also, line 29 is accessing main before its been intialized
other than that and it should be BlackListCommand implements CommandExecutor ๐
and fix your getConfig() ๐
where?
in your BlackListCommand
config comes from Main
so you need to set it in your constructor
FileConfiguration message;
FileConfiguration config;
public BlacklistCommand(Main main) {
this.main = main;
this.config = main.getConfig();
this.message = main.getMessages();
}```
ok
so ive been doing it the way i have it in there for the message
should I change it for all my classes?
yes
main is only initialized when your constructor is called, however the fields are initialized on class access, before the constructor runs
so trying to access main in a field will result in main being null
I have one final question for you
then im done for the day
cause ive been at this for a long time
what should I make FileConfiguration as
to save the file
because its null rn so im getting an error
and I cant save directly with FileConfiguration because its a static reference
FileConfiguration fc = new FileConfiguration();
File file = new File( main.getDataFolder(), "data.yml");
fc.load(file);```
np
Hey folks, I am trying to replace the items in player's hand/hotbar for a few minutes, then put them back in the same position they were before. To do so, I am trying to use the "extra slots" defined by Spigot, but it is not working as expected. Could someone please explain to me if this idea makes sense? I mean, what exactly are these extra slots? Can I use them as a "backup" inventory for items that I want to save?
Couldn't you store the UUID & item in a list and use Bukkit's scheduler or something similar?
extra slots aren't additional slots
the "extra slots" are just what aren't armour slots or inventory slots
i.e. a player's crafting slots
I could, I am just trying to find the safest way to replace the items
I mean, I don't want to lose what items the player had in hands if the server, for example, crashes.
Thank you for your answer
I'm not really sure ๐ค
A hacky solution would be using a .yml file or similar... but that would end up with a lot of reading/writing..
If you wanna be 100% sure it'll survive a crash or something, you'd have to save it to a file of sorts
I see
I am writing a plugin about magic, they will use a wand (i.e. a stick) to switch between the magic mode (where the hotbar is full of spells) and the normal mode (minecraft items)
I don't to lose information about the normal mode
otherwise they would kill me
but thanks anyway
I'm sure I'd have something better, sadly I haven't had a reason to do that myself ๐
use https://gist.github.com/graywolf336/8153678 and store the resulting String to the players PDC. Clear it when you reset the inventory. Then you can easily check at login if there is data stored.
There's the better answer ๐
Hahaha, thank you Elgar!
you could even strip it down to not bother with Base64 and just store the Bytes
Thats perfect!
Thank you so much
just one question
when I convert it to base64
does it save the lore
or just the item?
Just be sure you call Player.save when you add or remove data to the PDC.
I mean, the metadata
it saves everything
perfect, thank you!
Base64 is unecessary
Why wouldnt store bytes directly in pdc
as I already said
Oh sorry
Hi all. I have a row of problems with my changing inventory.
- When giving an item with the tag
for_mage: 1, the plugin considers this issue asPlayerDropItemEvent. I don't need that. - On the third drop(1 problem counts as "drop") second hoe adding.
- After the fourth drop, all hoes are removed.
I need to fix them, how i can do this?
PlayerDropItemEvent
https://paste.md-5.net/imebepuxex.java
Utils
https://paste.md-5.net/cenedexigu.cs
hey guys
how could i remove the mob spawn and the creeper destruction radius
for my lobby
i dont want to get mob/creeper explosion in my lobby
how could i do that
is your lobby a world?
its not a bungeecord server
my lobby is technically 5 chunks in my world
its the same world
then you'd have to monitor spawns and explosions and cancel them if they are in yoru defined area
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntitySpawnEvent.html and check the location
?paste
World world = Bukkit.getWorld("world_active");
if (world != null) {
File folder = world.getWorldFolder();
Bukkit.unloadWorld(world, false);
deleteWorld(folder);
}
WorldCreator wc2 = new WorldCreator("world_active");
this.world = Objects.requireNonNull(wc2.createWorld());
activeLoc = new Location(this.world, 0.5, this.world.getHighestBlockYAt(0, 0), 0.5);```
why isnt this regenerating the world
it doesnt throw any errors
unloadWorld is not instant
at me.mrs.theheroes.command.IronMan.onCommand(IronMan.java:23)```
what package do i need to import to access the BungeeCord class? i have net.md-5:bungeecord-api:1.16-R0.4 but i cant access the BungeeCord class with that
What do you mean "access Bungeecord"?
how do I get more than 1 config file?
getConfig() doesn't take arguments
I mean like have more than 1 config files
whoop nevermind, i was looking at the wrong class
how do i make it wait until it has unloaded
a Future or a repeating task
how do i get a future from the unload world
probably the simplest woudl be run a task 1 tick after this event fires for your world https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/world/WorldUnloadEvent.html
so I followed this guide and did all the things, but I can't do plugin.getCustomConfig(), why's that?
getCustomConfig is public in main
is a World object still valid after it has been unloaded?
no
why does worldunloadevent have the world object then
hey ElgarL I can't access get config from other classes, ideas?
You didn;t follow the tutorial properly.
yes
in the scenarios:
- only ur plugin in the server, and you are testing it
- big server with like 20 plugins
- reload is ok ig
- just restart man
It depends on how competent you are with OOP. Wether you designed your plugin to handle a reload
i used to use static in everything lmao
idk y
now i only use it in small amounts for being able to get a class' instance
and like util methods
am I dumb or is ```java
public void PublicMethodInMain()
{
}
cause if yes then I have no idea why I can't refrence it
no
It all depends on how you are obtaining yoru reference to main
if you are using a static reference Main then no.
if you are using an instance, then yes
ok so what am I suppose to do if I want to call this method
you pass a reference of your Main to whatever class needs it
like
package.name.main.PublicMethodInMain()
?
no
Its called Dependency Injection. You often use it for command classes and event listeners.
main main = new main();//?
Non DI listener = new MyEventClass(); With DI listener = new MyEventClass(this);
That is using DI to pass a reference of the current class to your listener
via its constructor
would that not create a new instance of main?
using this? no
if you did new Main() it would, and your plugin woudl fail to load.
Read more tutorials and Learn Java
World world = Bukkit.getWorld("world_active");
if (world != null) {
world.setMetadata("regenerating", new FixedMetadataValue(SpeedrunRace.getInstance(), true));
Bukkit.unloadWorld(world, false);
} else {
WorldCreator wc = new WorldCreator("world_active");
wc.environment(World.Environment.NORMAL);
this.world = Objects.requireNonNull(wc.createWorld());
}```
why
does that not work
How does it not work?
Thats null because its not a loaded world and you'd not set it as you are in teh else section of your code.
yes
ok so
whats up with it
in the unload event
shouldn't it immediately load it back in
First things first. Does your unload and delete work?
see if the folder is deleted
comment out the world creator stuff?
oh
it doesnt delete it
on unload it only deletes it
and it doesnt work
the deleting doesnt work
JavaPlugin.getPlugin(package.name.main.class).getRegenEnabledConfig()
is this how?
The world is not going to have the regenerating meta as you never save it
No, learn dependency injection
:(
Its really simple and I already explained it to you
its something you REALLY need to understand to work with Java
ok
Do you know what a class constructor is?
You don;t
How can I spawn CLOUD particle without the particle being "explode"?
for some reason I feel like DI isn't what Im looking for
You are trying to access a method that exists in your Main from inside another class. DI is what you need
ok cool
Do you know what a class constructor is?
Can i set the contents of an inventory whilst some1 is using it?
I dont think?
yes
set contents, then inventory.update()
is it really that complicated to have more then 1 config file?
No its really simple
can you provide an article, I can't find any good ones
guys how to get text from the wall sign? i mean clicking at that and if text is "abc" do something
I'll talk you through it...
?paste the class you want to access this extra config in.
How do inventories work with crafting tables
they aren't linked to the block are they
I'm trying to spawn a particle that stays in place, but when I spawn it the particle "explodes"
player.spawnParticle(Particle.CLOUD, location, 1);
they are just random inventories
a WORK_BENCH Inventory is teh 3x3 crafting
Yeah, but the inventory it opens has no relation to the actual crafting bench?
try one of the campfire particles
Alright, I'll try it.
ok, thats a basic class. It has no constructor and you create an instance of it by new AntiNaturalRegen()
yes
If you wanted to pass a reference of your Main to it, you would add a constructor like so... https://paste.md-5.net/luyewepexi.java
and you would instance it like so new AntiNaturalRegen(this)
Doesn't work, and it's giving me weird behavior, like the smoke will stays on the block.
Different particles have different animations. Depending on how you spawn it can affect where it spawns and moves
The spawn events are odd. Sometimes the values are locations, sometimes areas
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(reflectedField, reflectedField.getModifiers() & ~Modifier.FINAL);
In java 16 I get java.lang.NoSuchFieldException: modifiers
Adding the constructor like that and passing it a reference to your Main is called Dependency Injection. Passing references between classes
I want it to spawn exactly like this
I'm pretty sure NNYa explained that yesterady. Thats impossible to do with current Java.
Yes, I have to find another way. I didn't know where the exception came from but now I know
name as in main? or the name of the constructor? main can be anythgin you like
you can do anythign like https://paste.md-5.net/odidajoquv.java
Yes, thats the constructor. Has to have the same name as the class
main screw wine it keep trying to open links instead of firefox
What you pass to the constructor is DI. You can even have multiple Constructors which accept multiple references.
I saw this when I was trying to do the custom damage thing in the bukkit sauce code
I was confused as to what it was doing
this cleared up a lot thanks
If a Class has no constructor you create an instance by new YourClass(). When it has a Constructor you can only instance it by matching the constructor signature.
So in your example you will only be able to create an instance of that Class by passing Main.
it will expect you to put this inside its constructor
registerEvents(new AntiNaturalRegen(this), this)
or the other way around, I forget if the register takes plugin first or second
Second I think
it's the other way round
fixed
Main is your class name. main is a Field name
it says "this" is main but it expects Main
this is a keyword that simply means this class instance
You are registering your events in your Main class?
yes?
then this is correct
but it says required type is Main but provided is main
Show me what you mean
public AntiNaturalRegen(Main main)
{
this.main = main;
}
this in the AntiNaturalRegen class
Have you imported Main?
this is in main
getServer().getPluginManager().registerEvents(new AntiNaturalRegen(this),this);
and here
the "this" in (new AntiNaturalRegen(this)
is underlined
Import Main to your Anti class
I see the problem
the code you gave me had the variable main as type "Main"
but since my main is "main" no capitcal M
it imported some other class
so the type was different
oh, rename that. ALL class should be capitolized
just had to change this to (main main) and the variable
oh
only package names, methods and fields should be camel case
Is it like an organization thing?
Yep, coding standards
it's basically part of the java language specification's strategy to minimize name hiding
Intresting
*obscuring, not hiding
I have capitalized all my classes but for some reason past me just thought all lower case main is how it's suppose to be
Standards vary by language
I learned java as my first language but since I didn't know what to do, i abandoned it for like 3 years and was pushed to learn C++
and recently came back because I want to make plugins
so a lot of basic knowledge was lost
I really should re-read all the books
Help, the particles is always flying like this and I didn't want that.
Practice and time.
what is yoru spawn line?
player.spawnParticle(Particle.CLOUD, finalLocation, 5);
Is there a generic Event for a player moving an item between or in an inventory
Does your location have a direction?
I'm not sure, basically I spawn the particle on break event.
And get the location from the block.
The "cloud" particle is normally After jumping into water while on fire in Bedrock Edition or an entity dies in Java Edition.
I bleieve it has a random trajectory set in teh particle
So I need somehow set the trajectory?
You probably need to use a different particle
well.... its not what i asked ๐คท
try the poof particle
Poof particle? which one, can't find it.
So there is no way to make the cloud particle stays in place?
does anyknow how to teleport a target player to a specific plot in the plotsquared api?
How come this doesn't work:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryEvent.html
:
@EventHandler
public void onItemMove(InventoryEvent event) {
System.out.println("1");
}
Is it cause it is just the base class?
What should I put on the offset?
zero
I already tried that.
And same thing.
player.spawnParticle(Particle.CLOUD, finalLocation, 5, 0, 0, 0);
not yet, i don't see that on the javadocs
it works lmao
by adding one more 0
thanks Elgar
and the last is the data, idk what that is
extra - the extra data for this particle, depends on the particle used (normally speed)
is there any worldedit plugin
randomness means like the particle would spread?
yes
well, it would spawn slightly off your set location
so not all in once place
alright, thanks y'all
Hey, I want to cancel a VehicleExitEvent, but it doesn't work. I found it was a bug of spigot (https://hub.spigotmc.org/jira/browse/SPIGOT-1588) but it is marked as fixed. Do you know if it was really fixed, or if the last comment is considered as being the fix ?
its a double so upto 0.5 would all be in one block space
just set the player back as the passenger i guess
in delayed time
yeah, that'd fixed my issues.
@high gulch no worldedit was taken down and deleted
Do u guys know a good example plugin that would use the eventhandlers and stuff. Idk how to register them or where to put them so they would get called
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thanks
i have a problem: i want a command that is for example called /hello and i want to have 5 possible ways the server responds : hello/ how are you / hope you have fun playing minecraft/need any help/have fun. but i want the server to chose one of them randomly and then only wrote one of them: can someone help me
Put the respond on the list and get them randomly.
like what
wdym?
how do i do this
but just because it is a basic it does not mean i know how to do it
Yeah but it means the information is easily accessible online
yeah, pretty much what NNY posted should be enough to solve this
ty
Is there a thing inside spigot to remove the spawn protection ?(i wanna do it inside my plugin)
Nothing official I am afraid, you would have to use reflection to modify the value
huuu
Yes but that isn't inside the plugin code
i don't wanna the user to change it by it self
i wanna pre-configur the server with the plugin
it is not tho xD
what ??
while not changing the file, they could very much modify the value in the nms.DedicatedServer
what prevents them from just modifying the variable the value is stored in once their plugin starts ?
am I missing something
smart
this is not an event from spigot
no, no it isn't. There is nothing in the official spigot-api that allows you to do this
hi guys, so I'm using Eclipse and I'm not able to implement ParticleLib with Maven into my project. Idk why when I try to compile it doesn't compile the ParticleLib into it...
you will either have to a) modify the server.properties file and ask the server owner to restart or b) modify the variable the spawn-protection value is loaded into
what boolean xD
canBuild
oh, that value is calculated. Have you ever worked with reflection and the net.minecraft.server code ?
oooof
Ah
I think you are better off modifying the server.properties file from your plugin then
okay thx
can someone help me with this then please?
did you configure the maven-shade-plugin ?
idk, what's that?
the maven plugin you need to actually compile/shade your dependencies into your jar
yes
ah
you need the maven shade plugin
I have a Custom Inventory that i make when a player opens a crafting table. I am using this:
private Inventory inventoryMaker(InventoryHolder holder, Location location){
Inventory inventory = Bukkit.createInventory( holder, InventoryType.WORKBENCH,"G");
ItemStack[] contents = new ItemStack[10];
contents[0] = null;
for(int i = 1; i <= 9; i++) contents[i] = this.plugin.getItemFromTag(Objects.requireNonNull(location).getBlock(), "Slot"+i);
// ^^ Using RedLib to get contents from persistant block data
inventory.setContents(contents);
return inventory;
}
Which works, however i feel there is a problem with the holder as when i then try to get the block from the inventory it hucks a nullPointerError.
I am calling it like this:
event.getPlayer().openInventory(this.inventoryMaker(inventory.getHolder(), inventory.getLocation()));
But if i was to do this:
@EventHandler
public void onClose(InventoryCloseEvent event) {
event.getInventory().getLocation().getBlock();
}
It throws the null pointer on the getBlock()
are you sure it throws it on the getBlock specifically
how would I detect if a player clicked on one of the 4 crafting slots in their inventory? SlotType.CRAFTING seems to be for a crafting table only, and I don't know think InventoryClickEvent is called.
yeah
i removed it and it worked fine
i suppose the inventory returns null as its location then
couldn't you save the location/block when they first access it?
To what?
And then what would i use as an identifier
you're trying to get the crafting table block they right clicked right
Not really
what are you even doing anyway
that's weird but the plugin works
....
So i am making a crafting table that has persistent item storage, however now i need it to work for multiple people at the same time. Because the crafting table inv is not a common one i am making a new inv and showing it to the player when they interact instead of the default one
This is the working example
and the issue is
meaning if I leave an item in the crafting table someone will be able to see it in the grid when they open it?
yeah
but if two players open the same one, it dupes the items
because i am just adding them to the inv
instantiate a single inventory per block
Yeah, thats the idea
and let the inventory handle maintaining its state over multiple viewers
Block -> Inventory map
populate the inventories on chunk load or whatever
oh, hmm
or alternatively when the blocks are first clicked
populate the inventory on access
depends on how you're populating them
anyone know what this means tho
doing it on chunk load may be more performant
world gen issue?
corrupted something
yeah
i would guess either world or server jar
even if you load the inventory from file (individually) the momentary lag of it populating will not be noticeable to the player.
its the server jar
yeah, but having to check said file on every right click of every crafting table is noticeable to the server admin
cached
again depends on how you're populating it
I am using RedLib for it
i don't know how performant red's txt lib is
It seems pretty amazing tbh but i haven't done any testing
assuming it's just a Block -> data map too, it should be fine to do it on access
if it's slower, you'd want to load it in bulk on chunk load
what idk tho is why i am getting this error
your jar is missing a class or the classloader is fucked
what error are you talking about then
Caused by: java.lang.NullPointerException
at com.jeff.workbenchplus.listeners.SaveItems.onClose(SaveItems.java:37) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:315) ~[spigot-1.16.5.jar:3059-Spigot-4225eac-7ea8b96]
... 19 more
something is null
why the block is null
the block isn't null
the location is null
the inventory you created doesn't have a location associated with it
location.getblock never returns null
even if the block would be outside of the world
lol thats why i was confused
But i thought that if you gave the inv the InventoryHolder it transferred data like that
just store it when you first open it
depends on the inventory; the workbench inventory probably doesn't
Don;t create an Inventory, get it from teh Block. If you create a WORK_BENCH it will not work correctly as a crafting table.
get the information directly from the holder I suppose
Guys so here is my config.yml, I've got all the create file and stuff done, but how do I load it in as a string array?
excluded-worlds:
- exampleWorld1
- exampleWorld2
- exampleWorld3
oh you right ><
thats a StringLIst
Its just idk how to deal with people accessing it simultaneously
yeah that won't work then
oh
pretty sure the workbench inventory works even if you simply create it
config.getStringList("excluded-worlds")
no it doesn't
ok thanks
i just tried it
well then you're kind of fucked
I'm not sure it gets linked to recipies
valid
I know furnaces won;t work like that, but I'm suspicious of crafting too
does it create a new instance of the inventory for each player in under the hood then
yeah
It might
and stringlist have .getstrings to convert to a string[] iirc?
next thing to be uncertain of is how the clearing slots mechanic works
No it returns a List<String>
since normally, when a player closes the inventory, the slots are cleared
i take the spoon feed thx
yeah, atm i store the items in a blockdata hash
the question is whether that happens when the last player viewing it has closed the inventory
or whather it happens when any player closes it
Items shoudl drop to teh floor
actually, wouldn't recommend xD
that field is final
jigsaw is gonna come for you
oh so like dynamic size right
?paste
if it happens when any player closes it, you're kind of fucked, I don't see a reliable way of maintaining inventory state without flicker or jitter if that is the case
if it happens only once the last viewer closes it, you should be fine
the problem is that when a player closes the inventory i have it to clear the inv
y
cause if not the items ended in the players inv
in that case you're extra fucked
thats what i mean, sorry
A workbench that returns items to the player (example) https://paste.md-5.net/apenoyizah.java
i suppose the best you could do, then, is to have a separate inventory for each viewing player, and when any player mutates the contents of their inventory, reflect the changes in all of the other currently open inventories
kind of expensive, and going to result in some jitter, but based on what you've said I don't see any other way around it
thats what i was trying to do earlier
but i couldn't find a good event for the moving items
click/drag event
you'll have to do some of the calculations of where stuff ends up at yourself for shift clicks
and collect to cursor
and a few others
on the subject of crafting
how would I detect if a player clicked on one of the 4 crafting slots in their inventory? SlotType.CRAFTING seems to be for a crafting table only, and I don't know think InventoryClickEvent is called.
i don't remember how the inventory crafting table works
a lot of stuff about the player's inventory is clientside
but going by common sense clicking those slots should still fire events
is there an event for player disconnecting
I just tested and a WORK_BENCH inventory thats not backed by an actual crafting table knows no recipes.
does the InventoryClickEvent fire late enough that i can do inventory.getContents() ?
it fires before anything is actually modified iirc
What are some good items I could use for a back/forward in a paged inventory? I currently just use different shades of blue glass planes.
glass panes are generally fine
can always texture them to be actual arrows with a resourcepack
yea if ur using a resourcepack there a lot more possibilities
huuu my player has regenration but don't regen (i don't have event listening regenEvent)
very true..
how do I store yml files in a folder within the plugin's folder if that makes any sense
JavaPlugin#saveResouce and JavaPlugin#getResource @keen kelp
no I mean like a
The File you create points to teh location
subfolder
create a folder
well just put the files into src/main/resources/subfolder
then put the files in it
just be sure to save your config using plugin.saveDefaultConfig() in your onEnable to be certain your plugin directory has been created
there is no good way to extract an entire directory out of the jar though I don't think
He's not on about resource files
whot
No Im trying to do a player storage thing
just create a directory
Do as I just said
he wants to store into plugins/YourPlugin/subfolder (for example)?
it's not rocket science
yes
when you followed that Tutorial earlier it would have had you create a File. new File( plugin.getDataFolder(), "filename.yml")
yeah?
How can you compare two ItemStack[]
That defines where the file goes and what its name is
so when you have your fc you can fc.save(file)
how do I tell it to go into a subdirectory though
you want it in a folder under your plugin folder?
yes
ItemStack#equals
I was thinking each player has their own storage with the file name being their UUID
File file = new File( plugin.getDataFolder() + SystemProperty("File.separator") + "subfolder", "filename.yml");
file.mkdir();```
Arrays.equals
cant seem to cancel a player putting an item into their crafting grid but I can cancel them taking something out of it
however you will then have to call file.mkdir()
File.separator btw :fingerguns:
yeah, he can google that part ๐
how do I create a directory?
mkdir()
no
How to create an itemStack of Material Air amount 0 ?
so I dont need to check if it already exisits or things like that correct?
correct
You can;t, zero = delete
How do you represent an empty grid then
mc uses
new ItemStack(Material.AIR)
Yeah, but that creates
And i cannot reliably compare them
well, maybe actually
but it is more of a pain
isSimilar