#help-development
1 messages · Page 1386 of 1
ok, ill note all of these. Not to be rude or anything I appreciate that ur trying to help me be better, but can u get to the fixing shift click part. It's kinda late and sleep is sadly a thing that is needed 😄
im just compiling
Ok so your jvm targets are set properly... hm
im using java 11
Your pom says that you use java 1.8
compiling
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.3.11:compile (compile) on project potpvp-nd: Compilation failure
[ERROR] Unknown JVM target version: 11
[ERROR] Supported versions: 1.6, 1.8
[ERROR]
[ERROR] -> [Help 1]
Im not sure if 1.7 is even capable of being compiled with java 11
how
tf
do
I install java 8
I cant find it
how do u install jdks
from inside intelliJ
File > Project Structure >
ik that
but like where do I choose
its asking me to select
can I just download it
from intelliJ
If you click on the plus sign you can select "download jdk"
what intelliJ ver?
latest.
ok, ill note all of these. Not to be rude or anything I appreciate that ur trying to help me be better, but can u get to the fixing shift click part. It's kinda late and sleep is sadly a thing that is needed 😄
like shift shift
It doesn't seem to be working
Sry but i dont feel like fixing that rn
k
I guess then you just need to download the newest intellij version and update your old one with that launcher
what do u think it is
Should I paste my code here or through a site like PasteBin?
Or that
Here is fine in most cases. Unless its long.
@EventHandler
public void onInteract(PlayerInteractEvent e) {
try {
Player player = e.getPlayer();
if (e.getClickedBlock().getType() == Material.DISPENSER && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
this.getLogger().info("Checking if it is a booth...");
Dispenser dispenser = (Dispenser) e.getClickedBlock().getState();
NamespacedKey key = new NamespacedKey(this, "isVotingBooth");
if (Objects.equals(dispenser.getPersistentDataContainer().get(key, PersistentDataType.STRING), "true")) {
this.getLogger().info("Booth detected!");
if (player.hasPermission("voting.vote")) {
String running = (String) this.getConfig().get("data.running");
if (running.equals("true")) {
e.setCancelled(true);
showVotingGUI(player);
}
} else {
player.sendMessage(ChatColor.RED + "Access denied.");
}
}
}
} catch (Exception exception) {
}
}
making a realistic voting plugin
I put the "checking if it's a booth" thing to see if it came to that line, and it did. but the if statement doesn't seem to work
} catch (Exception exception) {
}
So you catch all exceptions and then just hide them so you wont have any idea of why your plugin doesnt work.
Are you a masochist?
Never ever catch an exception unless java absolutely forces you to. Exceptions should be avoided at all costs.
There are a few small exception to this rule. But generally avoid them
so print the exception or remove the catch altogether?
one moment pls
Ok this is your code. Just null safe and cleaner.
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block clickedBlock = event.getClickedBlock();
if (clickedBlock == null) {
return;
}
Material clickedType = clickedBlock.getType();
if (clickedType != Material.DISPENSER) {
return;
}
Action action = event.getAction();
if (action != Action.RIGHT_CLICK_BLOCK) {
return;
}
this.getLogger().info("Checking if it is a booth...");
BlockState state = clickedBlock.getState();
Dispenser dispenser = (Dispenser) state;
NamespacedKey key = new NamespacedKey(this, "is_voting_booth");
if (!dispenser.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
return;
}
event.setCancelled(true);
this.getLogger().info("Booth detected!");
if (player.hasPermission("voting.vote")) {
boolean running = this.getConfig().getBoolean("data.running");
if (running) {
showVotingGUI(player);
}
} else {
player.sendMessage(ChatColor.RED + "Access denied.");
}
}
wow, thanks!
how to move a player by a certain amount of blocks in a certain direction(north, south, etc)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (java-compile) on project potpvp-nd: Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags -> [Help 1]
switched to mac
so im on java 8
@lost matrix
player.teleport(player.getLocation().add(5, 0, 0));
this is for +5 blocks in the X direction
you can set there movement velocity?
I dont believe you can force them to walk in a certain direction
you can with entities
Sheesh you made that much from making plugins?
development on mac is fcking amazing
5 commissions a day
Like 15 messages
A day
How tf do you get commissions
I’m in so many service teams
Took a 2 year break tho 13 hours a day of coding for 2 years ain’t good for u lmfao
And I do like 1 comiszion / month
Mcmarket, spigot, mctrades building a name, wom
Being known is a big thing
U get a lot of random messages
i stopped doing commissions a while back and just got a normal software dev job
no more scammers and health insurance
Yeah I might have to do that
a lot less demanding, only code like 4 hours a day
start early tho, the skills i got from spigot programming was like super helpful
Yeah
i breezed through university compared to some of the code we do here
university programming a joke, a semester to learn about booleans and strings
Yeah lmfao
Does anyone know how to send a play or all players a big title on the screen on 1.16.5?
isnt it part of the player api?
just iterate over all the players and trigger this function ( https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#sendTitle(java.lang.String,java.lang.String) )
declaration: package: org.bukkit.entity, interface: Player
there are some libraries like lucko/helper that simplify overcomplicated things in spigot btw
But that's not over complicated ;/
The title API has existed for a while
i want to get a variable by for loop
for (Main.i = 10; Main.i < 1; Main.i--) {
if (p.hasPermission("damage.get." + Main.i)) {
Double d = (Main.(("level") + Main.i + ("_getdamage")));
Double d2 = (Main.("level" + Main.i + "_damage"));
getdamage.put(p.getName(), d);
damage.put(p.getName(), d2);
but it doesn't work
actually i am getting the permission of damage.get.(10 to 1)
How to do so?
getServer().getMessenger().registerIncomingPluginChannel(this, Channels.BROADCAST, new BroadcastListener(this));
TeleportListener teleportListener = new TeleportListener();
getServer().getMessenger().registerIncomingPluginChannel(this, Channels.TELEPORT, teleportListener);
getServer().getMessenger().registerIncomingPluginChannel(this, Channels.BROADCAST, teleportListener);
this will process BROADCAST on two listeners right?
How can i make a Tablist like this?
pretty sure the API can accomplish that BitLukas
SO does spigot treat commands ran by a command block as a player or console?
Furthermore, can you get the position of the command block responsible for running the command?
hi
ty
hi i have a problem with my plugin it says this
my error: https://paste.md-5.net/avuxurojot.css
main: https://paste.md-5.net/emecekipak.cpp
command: https://paste.md-5.net/epaserejay.java
registerCommand("astreansbuildsystem", new AstreansBuildSystem(), new AstreansBuildSystem(), false);
its like you're creating two more units of ur plugin
replace new AstreansBuildSystem() with this and you should be good to go
this refers to the unit itself, not a new one
lol ye I'm afraid so
i dont get it i just woke up to many imports missing and then this error
lol
never call new ClassThatExtendsJavaPlugin()
bukkit does that for you
or spigot*
yeah yeah ik
pog
i know that i putted command class yesterday
ye
Hello,I wanted to ask. If anyone has exepreinced this. I opened a project thru github with intellij and when i tried to put some code in. No code examples, nor errors were shown. Is there a way to fix this?
whats the issue if I may ask?
yeah this happend to me before when I was sharing my project using Code With Me plugin and There wasn't any suggestions to complete the code, try typing something wrong and check if it shows errors
like suggestions when putting a dot etc?
tried, doesnt work
is it possible to teleport a player to another world without the use of a 3rd party plugin such as multiverse to load the world?
is it possible for me to load the world?
i tried to put random code which had alot of mistakes in it. But no errors were shown
Invalidate and restart caches
yes if i got what u mean right
wdym by that?
Try restarting IDE
File -> Invalidate Caches/Restart IDE
tried multiple times
with my own singular plugin, i wanna p.teleport(Bukkit.getWorld("customworld), 0, 0, 0); @wispy monolith
try updating IDE
so that a ya?
p.teleport(CustomWorld, 0, 0, 0);
yes
didnt work..
update IDE also like hesham said
i updated it a few days ago
so you're on latest with other words?
should i try to reinstall it?
yes
uh yeah that might the last resot
it's probebly bcz that u get it from github so the project doesn't have the Intellij files
it does, my friend who im working with has intellij aswell
if this didn't work try:
Location ExampleLoc = new Location(CustomWorld, <X cords>, <Y cords>, <Z cords>);
p.teleport(ExampleLoc);
that won't change anything (: i can instantiate the location without initializing it
i've just had trouble with teleporting players to a world in the past
bcuz i'm pretty sure you do have to load it, but i'll try in a sec
public static void setBlockInNativeChunkSection ( World world, int x, int y, int z, int blockId, byte data ) {
net. minecraft . serwer . v1_14_R1 . World nmsWorld = ( ( CraftWorld ) świat ) . getHandle ( ) ;
netto. minecraft . serwer . v1_14_R1 . KawałeknmsChunk = nmsWorld. getChunkAt ( x >> 4 , z >> 4 ) ;
IBlockData ibd = net. minecraft . serwer . v1_14_R1 . Zablokuj . getByCombinedId ( blockId + ( dane << 12 ) ) ;
ChunkSection cs = nmsChunk. getSections ( ) [ y >> 4 ] ;
jeśli ( cs== nmsChunk. a ( ) ) {
cs = new ChunkSection ( y >> 4 << 4 ) ;
nmsChunk. getSections ( ) [ y >> 4 ] = cs ;
}
cs. setType ( x i 15 , y i 15 , z i 15 , ibd ) ;
}```
I find this metod to fast place block but how I can translate this to 1.12.2?
Yeah but i mean if something goes wrong
By teleporting player, the chunk will automatically loaded, at least that's what md_5 said.
I tried it at my own and it works fine
it must work i think
without translate
bcz spigot api doesn't change alot
That code would never work, even on older version. There are spelling errors in it.
but put it in an IDE and change the dependencies to the 1.12 api
and change the api version in plugin.yml
if (cs == nmsChunk.a()) {
cs = new ChunkSection(y >> 4 << 4);
nmsChunk.getSections()[y >> 4] = cs;
}```
This fragment don't work
from what I understand, it forces the section to be loaded
bcz u already got the .getSection in cs
and nmsChunk.a won't work bcz u already added .getSection to cs
is an excerpt in case the section fails to load
I don't understand
ChunkSection cs = nmsChunk. getSections ( ) [ y >> 4 ] ;
yea this fragment I understand
no sometimes this true
True how section is empty
can anyone send me a if statement which asks if a player have a elytra equipped?
i struggle hard with this
haha
We already did that yesterday
no i dindnt work idk why...
I gave you the full code, it works
hmm the thing is i want to ask if a player has a elytra equipped if not he can execute the command
Yep, teh code I gave you yesterday check if they had an elytra equipped
and then .equals() i guess
No, you need to get the type.
oh yes true and then ==
And also don't forget to null-check it.
How can I display the players hearts on tab?
use /scoreboard command
but i want to do it with my plugin
Ok first make a method that gets the player health
player.getHealth()?
Yeah I think
alr
and get the player name too
okay
And then
player.setPlayerListName(<player.getName variable> + " " + <player.getHealth variable> + "HP")
@summer scroll now it says an error message if the player has no elytra and if he has an elytra it does the else as i want it but i dont want the error
Is the error is an NPE?
Just make a take damage event
if(!(p.getInventory().getChestplate().getType() != null || p.getInventory().getChestplate().getType() == Material.ELYTRA))```
this is my code
alright
my if statement
if(p.getInventory().getChestplate() != null && p.getInventory().getChestplate.getType() == Material.ELYTRA)
ah okay thx
so this is my Class:
@EventHandler
public void Health(EntityDamageEvent event){
Player player = (Player) event.getEntity();
for (Player all : Bukkit.getOnlinePlayers()){
all.setPlayerListName(all.getName() + " " + all.getHealth() + "HP");
}
}```
and this is the error message that is constantly repeating: https://ghostbin.com/paste/38LX6
I will send u the code
Check If the entity is instanceof Player.
@EventHandler
public static void onPlayerDamage(EntityDamageEvent event) {
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = ((Player) entity).getPlayer();
player.setPlayerListName(player.getName() + " " + player.getHealth() + "HP");
}
}
You have unchecked cast.
ohh okay ty
yo, why static
it works
yes, but it's unnecessary.
I'm used to it
@EventHandler
public void onDamage(final EntityDamageEvent event){
final Entity entity = event.getEntity();
if(entity instanceof Player){
Player player = (Player) entity;
player.setPlayerListName(player.getName() + " " + player.getHealth() + "HP");
}
}
```better.
@wide galleon
and make a PlayerJoinEvent and add the code to it
@EventHandler
public static void onPlayerDamage(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.setPlayerListName(player.getName() + " " + player.getHealth() + "HP");
}
like that
I did it on the onLoad, is that okay?
idk maybe
also, is there a way to display the "HP" as just hearts?
what do u mean?
like the hearts next to the player name
like a heart icon?
just change HP to the heart symbols
like this https://imgur.com/XD36Frz
/scoreboard
This is how to display it like that
I don't think that there is a way to display it like that using plugin
oh thank u i didn't know that objective was a thing in spigot api
Hello.
hi
How do this stuff, when someone is clicking text, that I can execute code
hmmmmm
there is way to make it using minecraft vanilla command
and u can use plugin
For example:
Hello Verox [cancel]
By clicking [cancel]: execute this.plugin.cancel()
@eternal oxide How do you deal with loading and data syncing in groupmanager and what type of cache design are you using? I'm just curious ignore if you're busy I can check the code else wise.
Can you send a Link to the docs or something that might help me?
Did u make spigot with a team or by ur self only?
By myself
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ClickEvent
Lots of people contribute
Thanks
GM uses a ReentrantLock to ensure only one Thread is saving/loading at a time. New loads are performed to a new cache object which (if successful) then replaces the current.
If I remember correctly
hmm okay and when do you save data precisely? I mean I guess you would do it from time to time but also post player quit or no?
by a config setting, default 10 minutes
It checks the timestamp on the file to see if its been altered since the last save
ah nice okay thanks for answering 🙏
If any data (cached) is changed between saves its is flagged as changed, so when the next save cycle happens we only need to check the changed flag.
clever, I was also looking in to LuckPerms the other day but it seemed like they never saved the data so wanted to get another aspect of how the handling of data is done btw
I've not looked at LP much, other than their loading
How I can send a message with a normal String + a TextComponent
From what I understand they load data on join, then they have a housekeeper which is responsible for the unloading (unloads non online users) and is running like once every 30 seconds or something. And when it loads the data of a user it creates a new user object and then later mutate the user based of their storage implementation I think.
You choose one or the other
Can't I send a TextComponent with another in one message?
Because I dont want that you can clik the whole text to execute a ClickEvent
use a component builder
Okay
Does the EntityPotionEffectEvent only exists in newer versions?
And if so, how else can I make something happen when a player gets/loses a potion effect?
In 1.8.8
didnt work.
Hello, so I have this really weird problem that I need help with so if someone can help, please do.
Here is what's happening:
I am making this tutorial plugin for someone, and I am now setting it up in their server, and for some reason, the player gets removed (Entity#remove) and I try to teleport them but because they are removed it makes a lot of errors and doesn't teleport, but I don't know why it's removing the player, in my code there isn't a single time that I remove a player (I remove another entity but I check that's it's not a player before I remove), if anyone can help, please do @supple marsh
I was wondering if anyone has anymore info on this help page
https://www.spigotmc.org/threads/applying-velocity-to-only-one-axis-on-a-player.284694/
Applying a velocity on only 1 axis and leaving the rest unchanged.
(ping me)
No one can help you without you showing code. You are obviously doing something wrong.
To apply a velocity in a single axis you use the Vector length
player.setVelocity(new Vector(1,0,0).multiply(player.getVelocity().length()))
That will set the players current velocity in a single axis. If the player is not moving there is no velocity
i also need it to apply a velocity if their not moving too
then you just setVelocity with a new Vector
player.setvelocity(new Vector(1, 0,0).length()) you mean like that?
if i do that then if the player moved against a different axis it sets any others to 0 which feels weird
Thats precicely what you asked for. Explain exactly what you are trying to achieve
A wind like adding velocity, i tried taking their current velocity and adding to it by 0.02 on x axis but it interferes with their sprinting etc even if their going in the direction the velocity is pushing them. And setting a new velocity as 0.02, 0, 0 pushes them yes but if they then jump becuase its every 2 ticks it stops them mid air. pushes them, stops, pushes etc.
If teh player takes any action it will cancel your velocity
unless you apply it in a 1 tick timer
i set it to 1 tick but now it doesn't move the player when their not moving or affect them in anyway just slows them down in a way
show what you are doing
code or in game
mind i i dm it u
you have nothing in your code everyone here has not seen 100 times
You are trying to move ALL entities in the world?
yes
including the player
but affecting the player has to be smooth or it interferes with gameplay, im looking for a way to push the player a tiny bit without affecting their inputs by glitches etc
your current code is going to slowly increase the velocity if nothign counters it
yep, but you are adding that value every tick to the entities current velocity
your saying realisticWeather.windPushPower the value is too small
its 0-0.02 so yes very small
no, I'm saying if an entity doesn't do anything to cancel that push its going to move faster and faster
you need to cap you addition so it won;t exceed a set speed
the code your seeing there does this in game
You are also scheduling a repeatign task inside a repeating task. None of those tasks ever end
you are going to run out of memory as your server slows to a crawl with all teh tasks you are adding
https://gyazo.com/2b804b709ed627ee0140fd6251007b79
i need it to run constantly and the wind direction changes every 3 minutes.
yes, every 3 minutes you start a new repeating task. However the old task is still running. Its never cancelled
use a BukkitRunnable so you get a cancellable task object back
for which the velocity or wind change
the runnable where you set the velocity needs to be cancelable
I dont understand why
make it a field inside your 3 minute runnable
then if its not null you cancel it when yoru 3 minute runnable starts
It is possible to get player's inventory on death?
If its not cancellable you are starting a NEW runnable every time your 3 minute repeats. So now you have 2 running. Next time you have 3 running and so on.
pogh
hi what is the enum value for sharpness in Enchantment Enum
DAMAGE_ALL iirc
thx
oh thank you enchantments names are a bit confusing in spigot ^^
How can I read and parse a YAML file and also do all yml files except plugin.yml get put into plugins/PluginName/?
Look at the custom files section https://www.spigotmc.org/wiki/config-files/
thanks for teh link
when i start my local server i have this error in console "Unsupported Java detected (60.0). Only up to Java 15 is supported."
how can I fix it
Don't use Java 16 lol
just read this through. It's being explained in that thread
ok thank you
Hello
Is there an alternative to JavaPlugin#getResource that just returns a File?
Ah getTextResource returns Reader which I can use, nvm
What is the maximum distance at which a player can see another player?
Is it managed from the view-distance property?
ur render distance
does the server send any packet that tell the client how much far a player should be rendered?
Don't think so. I just think it tells the client to unload the player and no more data is sent
Does the server decide that a player shouldn't load another player thanks to the view-distance property?
The reason for your question?
I'm making a NPC plugin and I don't want send the packet to spawn the player to all the clients.
There's a setting called
entity-tracking-range-players
It controls how far you see players
If you are creating NPC's then you have to control who you send their data to
thanks
what do you mean with that?
If you are creating NPC's that you only want specific players to see you have to manage what packets are sent.
Ahh, yeah
how to make an event in command run with 5 sec delay?
bukkit scheduler
if (sender instanceof Player) {
Player player = (Player) sender;
if (args[1].equalsIgnoreCase("sharp10")){
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta swordItemMeta = sword.getItemMeta();
swordItemMeta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
sword.setItemMeta(swordItemMeta);
player.getInventory().addItem(sword);
}else{
player.sendMessage(ChatColor.RED + "Invalid command usage !");
return false;
}
}else{
return false;
}
return true;
}```
is there too much return ?
Not really, but you can make it look nicer by inverting the statement and not having indentation hell.
if (!(sender instanceof Player))
return false;
if (args.length != 1) {
sender.sendMessage("....");
return true;
}
// etc.
ima try this
That thing with the screen I showcased yesterday btw has a partially functional dev server at etm.dev
Called EscapeFromMars
Very cool image generated screen map thingy
if (!(sender instanceof Player)) {
return false;
}
if (args.length == 1) {
sender.sendMessage(ChatColor.RED + "Invalid usage ! : /kit <kitname>");
return true;
}
if (args.length == 2){
switch (args[1]){
case "sharp10":
Player player = (Player) sender;
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta swordItemMeta = sword.getItemMeta();
swordItemMeta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
sword.setItemMeta(swordItemMeta);
player.getInventory().addItem(sword);
break;
default :
sender.sendMessage("Invalid usage ! : /kit <kitname>");
break;
}
}
return true;
}```
i went for that but when I type /kit sharp10 is sends me invalid usage ! : /kit <kitname>
/kit sharp10 is args.length() == 1
no
okay ill fix it
hey can someone help me with this please :)
https://www.spigotmc.org/threads/vault-command.501945/
?paste
Why are you items.add(air) ?
to add them to the inventory
you are adding air every time. no items
You are also not setting the players inventory onJoin
ok theres a few issues with yoru code.
First you don;t need to check if sections exist and create them.
oh, i did that because it returned an error when i tried to add items to them even when i did this.saveDefaultConfig(); in the onEnable()
ok guys thx for the one that helped me
if you want to store the players inventory java plugin.getConfig().set("Vaults." + uuid, player.getInventory().getContents());
if (!(sender instanceof Player)) {
return false;
}
if (args.length == 1) {
switch (args[0]) {
case "sharp10":
Player player = (Player) sender;
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta swordItemMeta = sword.getItemMeta();
swordItemMeta.addEnchant(Enchantment.DAMAGE_ALL, 10, true);
sword.setItemMeta(swordItemMeta);
player.getInventory().addItem(sword);
break;
default:
sender.sendMessage("Invalid usage ! : /kit <kitname>");
break;
}
}else{
sender.sendMessage(ChatColor.RED + "Invalid usage ! : /kit <kitname>");
}
return true;
}```
You may have to parse teh contents into an array is all
I ended up with this
ok, ill try that
@eternal oxide this returns an error
ItemStack[] items = (ItemStack[]) plugin.getConfig().getConfigurationSection("Vaults").get(player.getUniqueId().toString()); and i have to do inventory.setContents(ItemStack[]) what should i do
You can;t cast like that.
don't itemstacks have cool serialisation?
yes
is there an event when a user receives a chat event?
hi! it is possible to get a list of items on player on the moment of his death ?
not what I meant, but yeah I just found a workaround in that event clearing the recipients in the event
you can just cancel the message and send it to who you want if that's not what you're doing
no I need the event to not be cancelled
as plugins like discordsrv use it to then display the messages
you could probably get the drops. but i am not sure
yes
PlayerDeathEvent#getDrops, you can modify that list, so go ham
hey Can some one help me with building? On my server
thank you
How can i do something when i click on an item in my inventory?
You mean a method that calls InventoryClickEvent?
that is called by*
Thanks! and for XP ? I want XP before players dies, not the xp that he drops
How can I make it where when someone plants a tree it adds one point to a leaderboard
BlockPlaceEvent and then listen for players placing saplings
then either a placeholder or just make your own leaderboard
Yeah I want to make a leaderboard
You need to get the slots items are placed in and compare it to the slots for your custom recipe
if its correct
then you can set the result to be the custom item
Then just update the leaderboard when they place one using that event
Check the items in each slot?
one sec, let me check
could someone tell me whats wrong with this code? java @EventHandler public void onInvClick(InventoryClickEvent event){ Player p = (Player) event.getWhoClicked(); if(event.getView().getTitle().equals("§6Settings §8• §bConditions")){ event.setCancelled(true); if(event.getCurrentItem().getType().equals(Material.SLIME_BALL)){ if(event.isLeftClick()){ if(Main.getInstance().getConfig().getBoolean("isChunk", true)){ p.sendMessage(Main.getErrorPrefix() + "§bChunk Effects §care already enabled§8!"); } else if(Main.getInstance().getConfig().getBoolean("isChunk", false)){ p.closeInventory(); Main.getInstance().getConfig().set("isChunk", true); Main.getInstance().saveConfig(); p.sendMessage(Main.getPrefix("Chunk Effects") + "§bChunk Effects §aactivated§8!"); Bukkit.reload(); } } else if(event.isRightClick()){ if(Main.getInstance().getConfig().getBoolean("isChunk", false)){ p.sendMessage(Main.getErrorPrefix() + "§bChunk Effects §care already deactivated§8!"); } else if(Main.getInstance().getConfig().getBoolean("isChunk", true)){ p.closeInventory(); Main.getInstance().getConfig().set("isChunk", false); Main.getInstance().saveConfig(); p.sendMessage(Main.getPrefix("Chunk Effects") + "§bChunk Effects §adeactivated§8!"); Bukkit.reload(); } } } } }
everything
huh
your code is super messy
use variables
Main.getInstance should be dependency injection if inside of a listener class
and dependency injection for most other things
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yeah use dependency injection although I guess you could still use static singleton
yea you can, just make the custom itemstack :/
you could use event.getInventory().getItem()
and check each item in the table then
np
amitco
Whats it supposed to do?
r u trying to make a recipe with itemstack ingredients rather than material based
?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/RecipeChoice.ExactChoice.html this might work, keep in mind this is a draft which means it may not work fully
declaration: package: org.bukkit.inventory, interface: RecipeChoice, class: ExactChoice
change something in the config to true on left click and to false on right click
also yes you can @SuppressWarnings("deprecation")
yeah
cuz its a draft
Idk I think it still works to a certain extent
might be worth trying needless to say
If you save the config using that method doesnt it delete all the comments?
wdym with comments?
ConfigValue1: "hjeiu9ijosej3ij90 r20 9" #This is a random string
ConfigValue2: 82 #This is a random int
ConfigValue3: false #Random bool
would become
ConfigValue1: "hjeiu9ijosej3ij90 r20 9"
ConfigValue2: 82
ConfigValue3: false
using .saveConfig(); i belive
i dont have any comments
when the config is set to true, and i click the item, nothing happens
So, anyone got the saucy for converting a player object to a username string?
and when its set to false, it just says its either already activated or its either already deactivated
Ok, let me try something
found it
@EventHandler (ignoreCancelled = true)
public void onPlace(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (!event.getView().getTitle().equals("§6Settings §8• §bConditions")) {
return;
}
event.setCancelled(true);
ItemStack item = event.getCurrentItem();
if (item == null || item.getType() == null || item.getType().equals(Material.AIR)) {
return;
}
if (!item.getType().equals(Material.SLIME_BALL)) {
return;
}
if (event.isLeftClick()) {
if (plugin.getConfig().getBoolean("isChunk")) {
//Send your message
} else {
player.closeInventory();
plugin.getConfig().set("isChunk", true);
plugin.saveConfig();
//send your message
}
} else if (event.isRightClick()) {
if (!plugin.getConfig().getBoolean("isChunk")) {
//Send your message
} else {
player.closeInventory();
plugin.getConfig().set("isChunk", false);
plugin.saveConfig();
//send your message
}
}
}
Use this and see if it works
no
Wow no images
lmao
package com.synth.tns;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class PlantSapling implements Listener {
String[] saplings = {Material.OAK_SAPLING, Material.SPRUCE_SAPLING}
@EventHandler
public void onPlayerPlantSapling(BlockPlaceEvent event) {
Block saplingPlaced = event.getBlockPlaced();
if (saplingPlaced.getType() == saplings)
}
}```
you cant compare an material to a string array...
Well, my bad. I barely know java and I am trying to make something in 2 days
one sec
How can I compare saplingPlaced to all of the sapling types?
how do u check if player only has their inventory open?
one sec, let me grab ya something
ill try ty
Set<Material> materials = ImmutableSet.of(Material.DIAMOND, Material.DIRT);
//then
if (materials.contains(block.getType())) {
}```
damn it, ya beat me to it XD
Is that for me?
ye
heh
Oh, thank you!
Do I need to import import com.google.common.collect.ImmutableSet;
yup
Not sure if there is a method for it, but you could just make a hashmap and have it update using InventoryOpenEvent and InventoryCloseEvent and store the status as true or false 
I think you could do smtng like getOpenInventory()
probably shouldn't compare inventory api objects
y
they're just delegates to nms inventories essentially
when you compare with == you actually compare objects memory addresses
.equals
if(Tag.SAPLINGS.isTagged(block.getType()) {
}
btw is probably the better solution for @hushed crescent
Idk but from what I know bukkit api recreates new inventory api instances for events etc yanlol
I get that when starting my server and plugin, can someone help me?
[15:09:25] [Server thread/INFO]: [PleromaMC] Enabling PleromaMC v0.3.2
[15:09:25] [Server thread/ERROR]: Error occurred while enabling PleromaMC v0.3.2 (Is it up to date?)
java.lang.NullPointerException: null
umm
public class PlantSapling implements Listener {
Set<Material> materials = ImmutableSet.of(Material.OAK_SAPLING, Material.ACACIA_SAPLING, Material.JUNGLE_SAPLING, Material.DARK_OAK_SAPLING, Material.BIRCH_SAPLING, Material.BAMBOO_SAPLING);
@EventHandler
public void onPlayerPlantSapling(BlockPlaceEvent event) {
Block saplingPlaced = event.getBlockPlaced();
if (saplingPlaced.getType() == materials)
}
}```
This did not work
is there more
Yes:
[15:09:25] [Server thread/INFO]: [PleromaMC] Enabling PleromaMC v0.3.2
[15:09:25] [Server thread/ERROR]: Error occurred while enabling PleromaMC v0.3.2 (Is it up to date?)
java.lang.NullPointerException: null
at com.kaonashi696.pleromamc.listeners.PlayerDeathListener.<init>(PlayerDeathListener.java:24) ~[?:?]
at com.kaonashi696.pleromamc.PleromaMC.onEnable(PleromaMC.java:23) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:493) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:407) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:435) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:218) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:809) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.5.jar:3018-Spigot-db99f82-a021e33]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
What do you mean? @dense kestrel
send that line
well
just send those lines from that class
the whole area around line 24
getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
package com.kaonashi696.pleromamc.listeners;
import java.io.IOException;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import com.kaonashi696.pleromamc.HTTPSPostRequest;
import com.kaonashi696.pleromamc.PleromaMC;
public class PlayerDeathListener implements Listener{
PleromaMC core;
public PlayerDeathListener(PleromaMC core) {
this.core = core;
}
FileConfiguration config = core.getConfig();
String post_url = config.getString("post_url") + "api/v1/statuses";
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) throws IOException {
String deathMessage = event.getDeathMessage();
List<ItemStack> drops = event.getDrops();
String dropsMessage = StringUtils.join(drops, ", ");
if (StringUtils.isBlank(deathMessage)) return;
HTTPSPostRequest.sendPOST(core, post_url, "status=" + deathMessage + " and dropped " + dropsMessage);
}
}
well
which is 24
thats obvious npe
you realise that later java versions have cool http apis right?
fields are initialized before constructors run
oh
does anyone know where i can find out about scheduled tasks?
XD
like a source
yep, i tried looking there. Its out dated
the config is null..
:/
no is not...
oauth: <token>
post_url: https://zecircle.xyz/
// SOLUTION
MemorySection config;
public PlayerDeathListener(Core core) {
config = core.getConfig();
}```
```java
Core core;
MemorySection config = core.getConfig();
public PlayerDeathListener(Core core) { //contructor
this.core = core;
}```
Look at the latter. Both the variable core and config is initialized before the constructor runs. So it's effectively equivalent to:
```java
Core core;
MemorySection config = null.getConfig();
public PlayerDeathListener(Core core) { //contructor
this.core = core;
}```
How can I make that see if the block was placed
assign it in the constructor
^
Random question, I wanna learn to use JSON configs anyone have anything good for it by any chance?
ok, GSON XD
Well I would recommend using configurate if you just wanna use JSON formatted configs. But yeah GSON is the way to go when working with JSON in Java.
Yea, I mainly just want it for auto-updating configs
a reminder that json was designed to store data in a compact manner
not to be readable
this does exactly that, but i also need to compare against the top inventory being null and it seems that it's never null?
Ok, how do I create a leaderboard? Do I make a new class?
what type of leaderboard
oh a sidebar scoreboard?
Yes
I mean you don't need a new class for it however I would strongly advocate it
I want my plugin to add one point to the person on the leaderboard when they place a sapling, and minus one point when they destroy one
.
it can be if the player opens his own inventory I think
well e.getWhoClicked().getOpenInventory().getTopInventory().equals(e.getWhoClicked().getInventory()) is somehow always false (:
yes as I said you cant compare
in onPlayerDeath() you mean
uh
.
ok, i have a problem my code runs everytime aplayer takes something out of a crafting table, I am trying to stop the player from being able to take things out of the crafting table if they don't have a specific item. Here are my attempts to stop it, the event i'm listening to is inventory click event, and it checks if they click on the output slot of a crafting table, the problem is that if you shift click you can steal the item faster then my plugin can stop you. any ideas on how to fix? Here is code: (I know it's not very clean 😜 ) https://paste.md-5.net/vukonopewe.cs
I personally use InventoryHolders but yeah people hate on them although they're perfect for tracking inventories tbf
Nah, using the views is better
?
by comparing?
Yes
So I made the scoreboard.
public void createBoard(Player player) {
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
Objective obj = board.registerNewObjective("Saplings", "", "Saplings Placed");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
}```
How Can I make it show the each users points
are ya'll talking about my thing?
uh no nrn I m checking inventor views
May I ask how you even compare that? By storing it or am I just stupid now?
seems random but i think it could fix my problem
yeah Bukkit.getScheduler().runTaskLater(plugin,() -> { ... },20L*seconds);
ok, dang that seems overcomplicated
You can just store them in a hashset and use .contains
But I use a map so I can connect them to my custom inventory instances
Did you get your issue resolved?
hmm interesting coll
uh well I can explain if you mind
How can I convert this:
ItemStack{IRON_INGOT x 3}, ItemStack{IRON_SHOVEL x 1}, ItemStack{IRON_AXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=131}}, ItemStack{IRON_SWORD x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=8}}, ItemStack{DIAMOND_PICKAXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=164}}, ItemStack{IRON_SHOVEL x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=77}}, ItemStack{HONEYCOMB x 3}, ItemStack{TORCH x 58}, ItemStack{BAKED_POTATO x 40}, ItemStack{SHEARS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=1}}, ItemStack{ROTTEN_FLESH x 3}, ItemStack{STICK x 6}, ItemStack{WHEAT x 7}, ItemStack{BIRCH_DOOR x 2}, ItemStack{CRAFTING_TABLE x 1}, ItemStack{IRON_BOOTS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}, ItemStack{IRON_LEGGINGS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}, ItemStack{IRON_CHESTPLATE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}, ItemStack{IRON_HELMET x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=10}}
to something clean
@dense kestrel How can I make this listener add one point to the users scoreboard slot?
I would like something like:
3 IRON_INGOT, 1 IRON_SHOVEL, 1 IRON_AXE, etc etc
it says plugin here. What do I put in that space?
the plugin,()
but if you have a bunch of itemstacks (non tostringed) do smtng like:
List<ItemStack> list;
String items = list.stream()
.map(it -> String.format("%d %s",it.getAmount(),it.getType()))
.collect(Collectors.joining(", "));
tho it might be slow
why?
AverageSam you plugin instance, which is your main class I believe you might have smtng like Main.getInstance() or else dependency injection
its negligible but String#format, could concat for faster speed and also avoid the stream and just use a raw for loop
sure yeah its nothing remarkable but fyi
Could it be main.getPlugin?
ok
and then what would i put in the space I asked about? sorry for being slow 😄
Bukkit.getScheduler().runTaskLater(Main.getPlugin(Main.class), () -> {
// delayed code
}, 20L * seconds);
chance: 1
items:
diamond_block:
name:
- "name of the diamond block"
lore:
- "the first lore"
- "the second loe
- "the third lore"
enchantments:
durability:
level:
- 10
emerlad_block:
name:
- "name of the emerlad block"
lore:
- "the first lore"
- "the second loe
- "the third lore"
enchantments:
durability:
level:
- 9
gold_block:
name:
- "name of the gold block"
lore:
- "the first lore"
- "the second loe
- "the third lore"
enchantments:
durability:
level:
- 15```
is it possible to get those items and their meta, and add it to a chest using inv.addItem
yeah it is
how
i ahve no idea how to do it
https://www.spigotmc.org/threads/adding-items-from-a-yml-file-to-a-chest-inventory.324701/ this didnt help
yea
so far i have been using this
Chest chest = (Chest) b.getState();
Inventory inv = chest.getInventory();
ItemStack one = new ItemStack(Material.DIAMOND);
ItemMeta oneMeta = one.getItemMeta();
oneMeta.setDisplayName("test diamond");
oneMeta.addEnchant(Enchantment.DURABILITY, 1,true);
one.setItemMeta(oneMeta);
inv.addItem(one);
to add items
but idk how to addapt that to take items from the config
I mean you would loop through the config keys so smtng like:
ConfigurationSection section = plugin.getConfig().getConfigurationSection("tier1.items");
for (String key : section.getKeys(false)) {
Material material = Material.matchMaterial(key);
String name = section.get(key+".name");
List<String> lore = section.getStringList(key+".lore");
//etc
}```
gtg
I wouldn't split it but yes
I'd just get @waxen plinth to write me a parser
a challenge he cannot resist
Looks like you're just printing out the ItemStacks
that's what i thought lol
My library already has methods to convert items to JSON and back
👀
Yaml is simpler
@EventHandler
public void onQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
Map<Integer, ItemStack> inventory = new HashMap<>();
ItemStack item;
for (int slot = 0; slot < player.getInventory().getSize(); slot++) {
item = player.getInventory().getItem(slot);
if (item != null && item.getType() != Material.AIR)
inventory.put(slot, item);
}
plugin.getConfig().set("vaults." + player.getUniqueId(), inventory);
plugin.saveConfig();
plugin.reloadConfig(); // reload so the Map is correctly converted to a MemorySection
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
String uuid = player.getUniqueId().toString();
if (plugin.getConfig().isConfigurationSection("vaults." + uuid)) {
MemorySection section = (MemorySection) plugin.getConfig().get("vaults." + uuid);
player.getInventory().clear();
for (String key: section.getKeys(false)) {
player.getInventory().setItem(Integer.valueOf(key), section.getItemStack(key));
}
}
}```
save and load an inventory
I have a short for color but I need a DyeColor, how?
there should be a DyeColor#getBy...
how do I get a Color from a short?
declaration: package: org.bukkit, enum: DyeColor
oh I thought he meant #getByColor lmao
just wasn't sure about the method^^
thanks a lot
just make sure to feel ashamed for using shorts for colour xD
There is no reason not to. Sure there are better db systems btu yaml is simple, human readable adn so long as you Thread it there are zero down sides
but I need to get the color from an item, how would I do it elseway? #getDurability seemed like a good option
you dont store entire player vaults in a yaml file
that looks like its all in one file as well
Yes, its an Example class.
And why not? make an arguments instead of just saying "don;t do it"
ok ok lets say you have
20 players
each with 2 vaults
and they put all of their good stuff in there
then u load that all into memory
and you write the entire file every time it changes
Bad example, the file is written on logout
however, still whats your downside you are trying to point out?
a terrible idea lmao
well
its a good idea for your system
what if the server crashes
the items just
gone
luckperms actually has that option ironically
If the server crashes there is just as much chance of the player.dat file being corrupted
Hmm, I mean most of it is deprecated when it comes to byte colour data. I guess EnumMap ? Actually no idea if there is a neat way to map these over.
it worked to yeah idc
I wouldn't mind, it's 1.8.9
lol
doesn't have it essentials too?
thought they use per file approach
could someone show me a way of doing this? at least what i have to use, i have no idea where to begin
Is there any outstanding features in the API?
Literally just set a config path to an ItemStack
ItemStack item = new ItemStack(Material.GOLD_INGOT);
config.set("path.to.item", item);
item = config.getItemStack("path.to.item");```
yea but the item stack name can change
the idea is to be able to edit that config file
not set a premade Material.GOLD_INGOT
idk how many items there will be, or how many enchants or lore lines
Yeah you can set it in config and it can be named
The name of an item can then be modified
Chest chest = (Chest) b.getState();
Inventory inv = chest.getInventory();
ItemStack one = new ItemStack(Material.DIAMOND);
Main.get().getConfig().set("items", one);
one = Main.get().getConfig().getItemStack("items");
ItemMeta oneMeta = one.getItemMeta();
oneMeta.setDisplayName("test diamond");
oneMeta.addEnchant(Enchantment.DURABILITY, 1,true);
one.setItemMeta(oneMeta);
inv.addItem(one);```
so i made this
Why do you modify the item after setting it in config?
ah
but
Chest chest = (Chest) b.getState();
Inventory inv = chest.getInventory();
ItemStack one = new ItemStack(Material.DIAMOND);
Main.get().getConfig().set("items", one);
one = Main.get().getConfig().getItemStack("items");
inv.addItem(one);```
would this take all items and add them? or do i have to loop it?
Hey there, does anyone know how I can easily save an entire folder from within the jar to the disk?
(with multiple subfolders)
if you add the item to a list before adding it to the config you can use getList to retrieve them, then .toArray() will return an ItemStack[]
You can then add that array to your inventory
Does anybody know why this doesn't work? I want it to stop all block placements ```java
public class onblockplaced implements Listener {
@EventHandler
public void onBlockPlaced(BlockPlaceEvent event){
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
}
getServer().getPluginManager().registerEvents(new onblockplaced(), this);
you are missing an { ?
no
You didn;t register the listener
Correct he isn't :"D an if (or any statement) which is only 1 statement can be without { }
nope, ignore that
If all the code is as you showed there is no reason for it to not work
That should work fine
if(something)
doSomething();
for(Object o : somethingElse)
doSomethingElse(o);
``` is valid, learn something new every day 😄
Yup, I tend to avoid it though for consistency
I assume the player is in creative mode when you tried it ingame, right?
no, I was in survival
Try doing a few printouts and make sure it actually enters where you cancel the event.
Didnt see !=, whoops
I had it in multiple files for listeners for some reason so I just put them all into the sam efile
But now I have the issue of this, this is in the right file but still doesn't work
@EventHandler
public void PlayerJoinEvent(Player playerJoined, String joinMessage){
playerJoined.getPlayer().setHealth(60);
}```
Is this something to do with the player joining before the entity spawns?
thast not a valid event
The name of the method is mostly irrelevant. It does not make it a PlayerJoinEvent because you named it that. The parameter would be PlayerJoinEvent
No, you just have teh whole definition wrong
myPlayerJoinEventAnyName(PlayerJoinEvent event)
bukkit looks for methods annotated with EventHandler then uses reflection to determine what events they listen for based on the parameter, that needs to extend Event in one way or another
the method name, like elgar said, has nothig to do with it :)
hi, how do you set the weather to clear? i thought it was world.setClearWeatherDuration(0); but that doesnt seem to work
i dont want to specify a forced duration of clear weather, i just want the duration to be natural
i do know there is setStorm(false) but does that work for rain as well?
Set the clear weather duration. The clear weather ticks determine whether or not the world will be allowed to rain or storm. If clear weather ticks are > 0, the world will not naturally do either until the duration has elapsed. This method is equivalent to calling /weather clear with a set amount of ticks.
So you would have to provide the duration of ticks you want the weather to be clear.
Otherwise you can set the gamerule on the world such that the weather will always be clear.
so you're telling me what i want is impossible?
I think the average duration is 6000 ticks
at least that is what the weather command defaults to
oh rly, hmm
No. The exact opposite. You can clear the weather for x ticks or disable weather via gamerules.
^
Didn't see that. Well then I suppose you could use the default duration as Lynx mentioned.
you reckon thats also what waking up to a new day defaults to?
Eh probably not
:/
but I mean the value you set there forces the weather to some degree
so realistically you should be fine just setting storm and thunder off
and just waiting no ?
world.setThundering(false);
world.setStorm(false);
javadocs for both say it resets the worlds clear weather ticks
so I'd imagine it would just equal a storm ending
im impressed how much NMS code have been deobfuscated
fair enough
Well people have been modding the game for well over 10 years now
i've been working with NMS 24/7 for the past 2 weeks, and in some points its as flexible as craft API implementations
awesome, isnt it?
This is my scheduled task class, I'm getting a null pointer exception in line 23 (run function) and I'm not sure why, could someone help me out? https://pastebin.com/Xg1iZniA Here's my main class: https://pastebin.com/xQ6n7AVC
Some people just have too much time on their hands
Probs is that that the plugin.player field doesn't contain player implementation object
ah, I declared the player in main and didn't give it a value
i think probably everyone here was very excited when mojang announced they would start rolling out obfuscation maps from 1.15 onwards
I'm a bit blindly following this tutorial, I'm still pretty new to java https://bukkit.fandom.com/wiki/Scheduler_Programming
This tutorial will guide you in using the scheduler provided by bukkit. It will allow you to defer the execution of code to a later time. This is not the same as registering a Listener, a block of code which is executed in response to an event in the game. Blocks of code may also be scheduled to be executed repeatedly at a fixed interval, with o...
and then everyone realised that spigot cannot adopt them easily and the plugin community just cried
At least we can use them as refrence
Hey, I was wondering if I could make a plugin that resets the end every time a server restarts, I'll run the function every time the plugin starts but what do I put inside the function to reset the end
🤷♂️
this
no joke if there would be deobfuscated and with full of performance improvements version of spigot without the Bukkit API, i would grab that instead, because for at least me, backwards compatibility is not what im achieving. I love tinkering with things.
i am at least delighted to use them for reference
You can just remove / rename the end file and the server will generate a new world_the_end for you
^^^
Yeah, but the plugin is loaded after the world files are, so it wouldn't generate a new one
Yeah just get mojang to release their damned plugin api for java
if you rename the file while the server is running it will generate a new one on startup
and ship some fun paper performance patches
Use CRON jobs to delete the folder, or create a plugin which uses bukkit world api to delete and create worlds.
i would use cron jobs because i would be too lazy
I didn't know that existed, Tysm
good point, a plugin probably isnt even necessary
just use bash script to launch the minecraft server and delete with rm -f command
cron jobs are only for scheduled tasks
How could I pass the player there?
pass it in to the constructor
@Override
public void run(player) {
Location loc = new Location(Bukkit.getWorld("world"), 120, 62, 342, 0, 0);
player.teleport(loc);
player.sendMessage(ChatColor.RED + "You have been teleported to the afk location.");
}```
ah
specifically constructor injection
that way you could reuse the runnable
that is a pretty basic OOP concept though, i recommend you spend some time learning those kind of concepts
right, I'm using player from the Main class, it points to null though because I declared player public Player player; my actualy player is in the OnCommand function, how can I reuse the variable then?
Thing is puffer panel dosent have the sh/bat file
my bad, the null might have been in the loc which I did not declare...
make the field static or pass the plugin instance to the command executor and set it through the onCommand method
Is BlockDamageEvent simply for when players are breaking a block (like a spamy event) or something else?
so umm
can i make the server console type something in chat?
dispatchcommand type stuff as a command
and i dont ant that
block dmg event?
is that a new event?
i think it gets called when a player starts to fine a block
mine*
can i make the server console type something in chat?
@digital plinth I think “say” is a default command to send messages to in game chat from the console
yup Called when a block is damaged by a player.
ik but that is broadcast
so what im trying to do is
automate world creation by mv
mvinv
so i do
/mvinv group
then i need to type "create"
as a word and NOT a command
Use the mutliverse api
this command is ran by cosole
so theres no easier way around it?
oh right
console can only perform commands
I mean. Yours is just hacky
XD
"Startup script './start.sh' does not exist! Stopping server." - Any help? I have been trying to solve this for 3 days
They have an api
Is there like some kind of built-in method for detecting if a block/material can be affected by gravity?
Always use apis instead of dispatching commands
Check javadocs for blocks, use ctrl+f and find anything related to gravity
Thanks for the tip I guess, but that's not really helpful. Especially with the way Spigot docs are written. Most of them are not really detailed at all.
They are
Ok, so my database is a yml file. Is there any way to extract the lines to a minecraft leaderboard?
Jesus christ wtf
Fk my ears. Can someone pls warn or temp ban this guy?
Is it possible to get the Bukkit Player from a ProxiedPlayer (bungeecord)
Bungeecord doesnt know about bukkit objects. What do you need the Player for?
@worldly ingot
open inventories
Then send a plugin message down to the server and let your spigot plugin open an inventory for the player.
If you use one of those two then you know it.
Yes
what is a "plugin message"? how to send and how to recieve it?
.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Sure. But a yml file is not a database. You can just read the File using the FileConfiguration api from spigot.
I know it's not a database. Just like json in javascript is not a database
I just need an easy way to put players points in
thanks
In you yml file? Use the FileConfiguration API from spigot. Or use Gson to create json files. If the data has a simple structure like Map<UUID, Integer> then
you can just pass the whole instance to Gson and get it later back when you need to load it again. Ill give you an example.
I am new to java
How can I get the list of tags for a player?
Just needs to store Username and Points
Then you probably shouldnt be writing spigot plugins. You need to at least understand the basics of Java before jumping into spigot.
There are some concepts in Spigot that will just confuse you for months without you getting anything done if you dont know a bit of Java.
So you should at least learn to the point of where you understand
What a method is
What a constructor is
What an instance is
What the differences between scopes are
What static means and why it should be used sparcely
?kick @lunar wigeon We don't do that here
👢 Kicked zitreF#4365
ngl I was expecting a monkey dick or something lol
lmfao
XD
By tags you mean the scoreboard tags?
Yes
Player#getScoreboardTags() -> Set<String>
Is mutable btw. So can also be used to add/remove tags
It's mutable? o.O
The field is not but the set itself
I have a feeling it's not because there's addScoreboardTag() and removeScoreboardTag()
how do i create a startup script I have been having this problem for 3 days
Probably returns a clone
oof
How can I get the username of the player who placed an item
just returns the ay set...
Yeah but it really should not be mutable given that there's no size check on it
addScoreboardTag() does check
Never noticed lol
I mean changing it now would probably break a plugin or two so it's not really worth changing tbh. 1024 tags is a hard limit to hit lol
But changing it now might break some plugins
ye
I would use the add/remove equivalents though if you plan on doing so
Unless the docs explicitly state that a collection is mutable, you should assume it's not
Or a new Set implementation with internal size checks on add/remove XD
lol right
Does anyone know how to send to discord webhooks in your plugin? I couldn't find any guides or tutorials online
It's just a regular ole HashSet tho
Discord's API has that documented. It's just a web request with a bot auth token
listen to the onblockbreak event, check if entity type is player if it is, cast the entity to the player, and get its name via getName() method
The field is a Set so returning a wrapper that implements Set for it wont hurt
I might add that.
Oh you mean to change its implementation? Meh. It's honestly not worth it
use aikar flags and paste it inside .sh file
Yeah
Thanks. I'm not very good at coding so I'll try using that but if I have difficulties I'll ask back here
I have no idea about what you're talking about i don't have an sh file
Discord's docs should cover most of what you need