#help-development
1 messages Β· Page 1428 of 1
my plugin.yml:
name: DontResetAttributes
version: 1.0.0
prefix: dra
author: krystejj
main: me.krystejj.dra.DontResetAttributes
api-version: 1.16
commands:
dratoggleforplayer:
description: Toggle DontResetAttributes for player
permission: dontresetattributes.dratoggleforplayer
usage: /<command>
permissions:
dontresetattributes.dratoggleforplayer:
description: Allows /dratoggleforplayer command
default: op
dratoggleforplayer.*:
description: Allows everything
default: op
children:
dontresetattributes.dratoggleforplayer: true
@mild kernelwhich line is line 18?
System.out.println(args); //<-------- this causes an error
don't use that line
did you shade deps @clear fable
delete it
i'll explain everything in a sec
don't use System.out.println
public repo doesnt have the jda with deps
ok i changed this System.out.println(args); to this Bukkit.getConsoleSender().sendMessage(args); and im still getting this error
for all the jda deps
just args is null and I don't know why
are u using paper
yes
go to paper support
@lofty mulchI'm already using shade bc it comes by default with the MC Dev spigot template
gimme a sec
cuz I used JDA before, I had no problem with it
I am making a spigot plugin to log joins and leave in my discord server. I use JDA for reading message history and a custom discord webhook solution to send webhook post reqs. When ever I send an http post req from my DiscordWebhook class, it causes this error to appear multiple times in the console. This makes no sense to me bc the post req has nothing to do with JDA but idek. For JDA I have a local jar for my IDE and on my server I am using JDASpigot. Here is my [main class] (https://pastebin.com/AC0ExLs2), my DiscorWebhook Class, and my pom.xml. Btw I am using paper build 654. The weird part is that it doesnt seem to interfere with anything (the code works as intended) but it throws hella errors
i downloaded spigot instead of paper and im still getting this error
@lofty mulch
I thought it would fix the error bc I heard it can be caused by a corrupted jar file
didnt do anything tho
so idr why I stuck with it
btw use JDA from maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.1_253</version>
</dependency>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
thats what I used
just use
ok
how to get the number of people connected to the server at the same time without using a weird for loop
as an int
getServer().getPlayers().size();
it returns a list
Bukkit.getOnlinePlayers.size() works as well
@lofty mulchI get this https://pastebin.com/Aheemfjh
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.
Idk how to actually do it the right way so I include an extracted version from the Project Structure settings to avoid this
if I do then I get this:
JDA needs to be on the server
Shade it in to your jar
Yeah shade that too
what
how do I shade it correctly?
you didnt use maven package
wdym
ok
double click
alr
u also need maven shade plugin
then use gradle
I prefer gradle
person I'm making it for wants maven
ok I ran the "package" task now what?
yeah that's there
find the *-shade.jar
Is there a way to automatically put it in my plugins dir?
ty
np
it still generates all 3 files is there a way around that?
nahh just ignore it
dude the gradle done the same things
ok ty
looks like it only works if the server is not running π¦
I cant reload while running
it will tell me about ambiguous plugin names
ye
wait wdym "change"
I have a different one set in the pom
but I didnt change the file after it made it
so you keep the jar name with -shade.jar?
ye
well the "clean" task only remove target jar
oh you mean with maven?
not the jar at output
people do clean install
yes
he doesnt want the fatjar still locate at target dir
clean removes the files or the jar of which was exported before, install or package reintalls the jar, this way compiling won't glitch out or compiling will not bug out whilst doing it. I always suggest cleaning the target file first because I've glitched out so many times bcz of it
he can move it easily
ah shiet
I want to either only generate the shaded jar or remove the others automatically
that's based on your maven plugins
it
inside of the poem.xml
if more than 1 jar is created
check if there are 2 plugins of which go for maven-compiler
if yes
then that will export you 2 different jars
if you want only the shaded jar, then check which plugin states shading and then just keep that and remove all other plugins
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.artifactId}-${project.version}-build</finalName>
<outputDirectory>D:/Adyo/Documents/Minecraft/Plugins/Server 2/plugins</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>```
yes of course, because it's shading all your libraries into the jar.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.artifactId}-${project.version}-build</finalName>
<outputDirectory>path to plugins folder</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
like that it would just deploy the shaded jar
he wants to delete the jars at target dir dude
even though by removing the other plugin, you are no longer stating which java language you are using.
I want to either only generate the shaded jar or remove the others automatically
He just wants to compile in the shaded jar
I get an error about multi-catch statement is not supported in -source 1.5 where do I change that?
yeah, that's because you are no longer stating your java language
what the other plugin did
was state your jar language
hold up let me fix that for you
ah
sure one sec
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.
thank you
I thought <java.version>1.8</java.version> which I already have would define the java version but ig not
it just define variable
ohhhh
a variable named java.version with value 1.8
im dumb
nah
ye that makes more sense
if you listened to the answer, ur not dumb
no I'm tired lol I could have figured that out by looking at it for more than 5 seconds
works just like gradle
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>34</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.artifactId}-${project.version}-build</finalName>
<outputDirectory>********/plugins</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
try this out
ok
Could not find artifact org.apache.maven.plugins:maven-plugins:jar:34 in central (https://repo.maven.apache.org/maven2)
maybe: maven-compiler-plugin 3.8.1?
to what?
anything below 34
33 doesnt work
try this out
30-32 dont work
<properties>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.artifactId}-${project.version}-build</finalName>
<outputDirectory>********/plugins</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
worked
gg π
what happened?
huh
original ofc
I ran it 2 times and it made 1 the first time and 2 the second time
I did
I have clean package clean
are you sure it's cleaning it tho?
I'll do it manually
that would remove the jar
remove clean at last
k
try remove the directory par
why do you want it to compile into a different directory when you can move it very easily?
bc I would need to move it every single time I make a change to the code
normally I just build artifacts and I can reload confirm right away
yeah i don't think maven supports that
ugh
it is
i think to do that you'd have to artifcat it
wdym
huh?
dude paper reload confirm is succ
what
i mean its not that bad
nah
it didn't reload my plugin
paper is WAY more optimized than spigot
so i decide to run spigot
π€
yes it is
but developing plugin is bad
anyway
if you use spigot-api
its fine lol idk what ur talking about
run plugin with spigot
if you develop using the spigot apif
you can run it off any spigot
it doesn't matter which spigot you are using
why dont use the original one
because it's bad
^
pre-load lib is bad
idk what u have against paper lol
it has many wrongs in it
@clear fable keep using paper spigot there is nothing wrong with it, but if you are developing a public plugin i'd recommend making it with the normal spigot that way it supports all spigots
Its not a public plugin
seems you guys understand wrong
oh then make it with whatever you want π
I just like paper
tuinity
flamecord is bad
flamespigot*
maven is succ π¦
no maven = no gradle
eclipse compiler is pog
wait I have an idea
So you want to compile with errors ;/
Also not everything compiles correctly with it
just hated eclipse becuase it doesnt support gradle kotlin dsl
sweats in Eclipse
it does
I prefer eclipse over intellij fsr
Eclipse doesn't like Kotlin in general
kotlin is bad
removes the fun of in-human java coding
guys
can I run a custom cmd command in the Command line section of the run config editor?
just like del "path to jar"
just ignore it
im sure
i dont even care to the build dir since you only interact with src folder
yeah
I want to run a cmd command after it finishes building
all I see is "Before launch"
I want to do smth afterwards
whatever
I'll just deal with the inconvenience
Where? In gradle?
If so you can make your custom task depend on build or make your custom task run after build. I do not have concrete examples but I guess some fabric or forge related repo should make use of them
i have code on my usb and i opened it and it cant resolve symbol of any bukkit/spigot stuff
maven part
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
but it works if i change 1.16.5 to 1.13.2
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
im using itellij
you sure it works and isnt still downloading libraries
Make sure you reload the POM after changing it
it finished downloading
Send whole POM
i have reloaded it
it was working earlier today
it says
Library Maven: org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT has broken classes paths: Β Β C:\Users\prest\.m2\repository\org\spigotmc\spigot-api\1.16.5-R0.1-SNAPSHOT\spigot-api-1.16.5-R0.1-20210509.073748-70.jarΒ [Fix]
that in project structure problems thing
Try deleting the org.spigotmc path and let it regenerate
is it running?
only when execute?
No
any time a discord event happens
the reason it was happening earlier was bc webhooks are events
for example GUILD_CREATE or GUILD_MEMBER_UPDATE are events
well i have no idea
I'm gonna ask the official discord guild for support
Compiling isn't working right
or you've obfuscated it wrong
show me your JDA code @clear fable
I asked in the official discord server for JDA
Did discord bump their api or what lol
is it possible to disable end and nether during the plugin loading (onLoad) ?
Probably but why
the question is not why but how
My question was why
But I guess you might have to inject into the mapped config values before itβs red or smtng
yep but i don't understand why because i'm just asking how. For answer this context is not necessary
I mean you can disable those through server.properties and bukkit.yml manually?
I don't see why automation would be a need for something like this, but the files would be the best course of action
yep but i wanna do it directly with my plugin for the user to not touch paramter and auto config the server
You would touch the in memory version not the file
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class God implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
player.setInvulnerable(true);
player.sendMessage(ChatColor.RED + "GOD" + "" + ChatColor.GREEN + "" + " mode on");
if(!player.hasPermission("god.use")) {
player.sendMessage(ChatColor.RED + "" + ChatColor.RED + ChatColor.BOLD +"You don't have permission to use" + ChatColor.GREEN + ChatColor.BOLD + " God" +
ChatColor.RED + ChatColor.BOLD + "!");
}
} else {
System.out.println("Sorry console, but only player can enter invincible state :)");
}
return false;
}
}
``` I tried many things to add toggle system to this /god command which turns u invincible, but whenever I type /god it always turns god on, never off, like toggle system, do u guys know what should I add so whenever I type /god it turns on, then I type /god again it's gonna turn off and so on ?
You need to add the user to a list of players with god enabled, when they do /god again or leave, remove the god effect
I doubt I'll be able to do it
step 1: create a collection of players
step 2: in the code, create a condition that checks if the player is already in the collection
step 3: if they are, remove them and remove the effects
step 4: otherwise, enable the effects and add them to the list
If you don't know about collections, you need to read up on the Java Collections Framework (particularly ArrayLists) @paper falcon
oh, I'm familiar with ArrayList, thank you, I never thought of that
Be sure to utilize streams, it's much more efficient and cleaner compared to your usual for each loops
Is there a player#isInvulnerable method ? (Not on my pc currently)
Also, check if player has permission before effectively putting him on god mod, if not send message then return
private void drop(final Player player) {
final PlayerInventory inventory = player.getInventory();
final World world = player.getWorld();
final Location local = player.getLocation();
Arrays.asList(inventory.getContents()).stream().filter(e -> e != null && e.getType() != Material.AIR)
.forEach(item -> { world.dropItem(local, item); });
Arrays.asList(inventory.getArmorContents()).stream().filter(e -> e != null && e.getType() != Material.AIR)
.forEach(item -> {
world.dropItem(local, item);
inventory.remove(item);
player.updateInventory();
}
);
inventory.clear();
}``` this method dont clear my armors contets but, drop..
Yes there is
What do you want to achieve ! Remove armors from inventory ?
yes
Well @paper falcon then you can just do player.setInvulnerable(!player#.isInvulnerable)
Then remove the line world.dropitem(local, item);
You're litterally saying that you want to drop the item in your code
i want remi want remove all itens of player inventory and drop
Oh ok you want both
i think ive fixed it
doens't getContents also include armor ?
no
Ok my bad
How can I make a Anvil-Input?
how do i enumerate all fields in all classes in jar files i load?
URLClassLoader child = new URLClassLoader(
new URL[] {new URL("file://"+file)},
Main.class.getClassLoader()
);
Enumeration<JarEntry> entries = jarfile.entries();
while(entries.hasMoreElements()){
JarEntry je = entries.nextElement();
String jern = je.getRealName();
if(jern.endsWith(".class")) {
ConUtil.println(je.getRealName());
Class classToLoad = Class.forName(jern.replaceAll("/", ".").replace(".class",""), true, child);
for(Field f : classToLoad.getDeclaredFields()) ConUtil.println(String.format("%s: %s",classToLoad.getName(), f.getName()));
Method method = classToLoad.getDeclaredMethod("myMethod");
Object instance = classToLoad.newInstance();
Object result = method.invoke(instance);
}
}```
thats my current code but it keeps throwing class not found
I didnt copy all I added the last ;
Hey guys, my plugin has loads of GUIs. Clicking on different items has loads of different uses.
Is there a good way to code for each of these uses? Rather than if statement after if statement?
there's probably some API that does it the sexy way
or u can code it urself
Doesnβt really take much
I have a hashmap and a custom inventory class that uses consumers
Haven't tried, but what about a hashmap<string, thread> where string is the localized name of the item
So when an item is clicked it'll do map.get(name).start()
Dunno, just thought of a method
inb4 switch statement lol
Only works in fixed GUIs I suppose, not much for a dynamic GUI
Then use a pdc entry on the item
Or just change the connections when you change the inventory order
how to set FaceDirection of a block with BlockData ?
yes
generated an exception
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.block.impl.CraftRotatable cannot be cast to class org.bukkit.block.data.Directional (org.bukkit.craftbukkit.v1_16_R3.block.impl.CraftRotatable and org.buk
kit.block.data.Directional are in unnamed module of loader 'app')```
block.setType(material);
Directional data = (Directional)block.getBlockData();
data.setFacing(BlockFace.NORTH);
block.setBlockData(data);```
and the test block.getBlockData() instanceOf Directional don't pass
the block in question is a log
package index
someone giv idea to make plugin thanks please I appreciate it
don't understand
does the Block class implement Directional or does BlockData
also make sure you imported the right directional
looks like there's 2 in spigot
import org.bukkit.block.data.Directional;
looks right
me to but got this error while trying to change direction of the block
and a log is certainly a directional block
else i can't find how to change it direction
what log class are you referring to?
a oak_log to be precise
that's not a class
Material.OAK_LOG?
as far as i know
yep i know but it's a Block and Block is a class i'm wrong ?
declaration: package: org.bukkit.block.data, interface: Orientable
a block is not equal to a material
a material is a property of a block
yep sorry misunderstanding from my part
u good
If the original is a Block its Directional
usually you can't cast nms to bukkit classes directly so thers something funky going on with that instanceof
what in the world
yep got the problem here
Test the Block instanceof Directional, Cast and setFacing
the problem come from the last block is not correctly save. When a player break a block i respawn it after X time but the problem is when i'm getting the last blockData from the last block it's air
and not wood with orientable data
How do you mean "the last block"? breaking multiple blocks?
when a plyer break a block i'm scheduling a task
and i send the "latest" block before replacement
you can;t send the block as that is only a reference to the block in the world. By the time your code runs the block has already been replaced. You have to use BlockState.
yes that was my mistake just before but know i'm sending the data
If you getState and pass just that you have everything you need. BlockData, Type, location
when i print axis it's right
but the block is not correctly oriented
maybe need an update ?
hoo okay easier
yes you need to update if you apply a state.
if you use a state you don;t even need to do any of the directional code
what do you mean ?
@EventHandler
public void onRightClick(BlockBreakEvent event) {
final BlockState state = event.getBlock().getState();
new BukkitRunnable() {
@Override
public void run() {
state.update(true);
}
}.runTaskLater(plugin, 100);
}```
the state already holds the block reference
The state is a snapshot of the block at teh time you obtained the state
yep but he don't hold the last block but the actual one ?
hoooo
but i don't understand your saying the state is a snapshot of a block at a time si i need to apply it to the new one
i think i don't understand
one sec
ok
thanks for your help
Hello, I was wondering if there was a way to know which key the player pressed
specifically here the forward/backward key
For the backward I think I can get it
but the forward would be a bit tricky since when he does double w
he start sprinting
The best you can achieve is a guess
I would like to implement a sort of dash mecanic
Yeah, backward, right, left would be ok
the forward though, I don't think so
There are many events that can push/move the player. All of those would also trigger your logic to think a key was pressed
Sure, the problem is not the dodge by itself, it's the way it get triggered, I mean, if the player is sprinting, I would like he got the possibility to dash forward
a decrease in velocity could mean the player pressed the back key, but it could also mean he just let go of the forwards key, or entered water.
don't he get a velocity in the opposite axis from where he looks ?
not until he starts moving in that direction
Like, if I look at north, my velocity is positive on forward, and negative in backward
as I said, the best you can achieve is a guess.
Oh! What if check for the toggle sprint event ?
Like, if he toggle the sprint twice fast enough he could dash
But that would work only on forward x)
Yep, sprint is the only one that has an event
The most sense, in my opinion, would be to check for a sprint jump and then listen for a toggle sneak event. pressing shift mid-air feels the most natural, in the sense of controls we have available in mc
Not a bad idea at all!
So, double sneak for a backward dash, and double sprint for a forward would be pretty neat π Thanks for the suggestions!
I have a question about plugin encryption, is there a tutorial on YouTube or other sites??
What do you want to encrypt
I did not translate this sentence from Polish, but my point is that you should not be able to open the .class file using, for example, luyten
My english su*ks
I think what you are doing is referring to obfuscation:
https://www.spigotmc.org/threads/rule-changes-re-obfuscation.420747/
there is no way to encrypt it afaik because it has to be run. Any plugin can be put through a tool like fernflower - it is just how it is
We can pretty much guarantee no code you write is going to be new or innovative enough that it needs protecting.
How can I get a float from config
I think so too π
thats for a double
My curiosity is just eating me up, so I asked this question
float value = (float) double;
float not Float
Does anyone know how to make reload config command?
Thanks!
my edit was to remove a ;
idk I swear I saw (Float)
this.reloadConfig();
It doesnt work
Its the correct method, you must be using it incorrectly.
this.getConfig().options().copyDefaults(true);
if (this.getConfig().getBoolean("IronHorseArmor")) {
this.getServer().addRecipe(recipeIronHorseArmor);
}
if (this.getConfig().getBoolean("GoldenHorseArmor")) {
this.getServer().addRecipe(recipeGoldenHorseArmor);
}
if (this.getConfig().getBoolean("DiamondHorseArmor")) {
this.getServer().addRecipe(recipeDiamondHorseArmor);
}
if (this.getConfig().getBoolean("Saddle")) {
this.getServer().addRecipe(recipeSaddle);
}
this.saveConfig();
This is my onEnable
And this is my config file
IronHorseArmor: true
GoldenHorseArmor: true
DiamondHorseArmor: true
Saddle: true
and when I do /che reload it will do this.reloadConfig();
why are you saving the config when you made no changes?
So do I have to remove this.saveConfig();
its doing nothing. I would put (at the beginning) saveDefaultConfig();
Reloading your config is not going to run your onEnable code again.
Okay but how can I make a reload config command?
so when I change the config I can reload the config without reloadig the server
reloadConfig() only reloads the values from file.
what do with that data is upto you
Okay but do you know how to make a command so if I change something in the config I can reload the config without reloading the entire server?
You separate your code from your onEnable and call it as you need from the command
Could you help me with that?
How do i detect if a player is whereing any 2 pieces of my custom armour set
But how would it see if it has 2 pieces would i have to do if boots and legs and stuff
you just loop the returned array and count the matches
Whenever i do
player.sendTitle();
It just puts a line over, anyone know why?
Spigot 1.8.8, JDK 8
what are you actually sending?
Well no matter what it is, it puts a line over.
a line over?
hover your mouse over it and you'll see why
"is deprecated"
use sendTitle("test", -1, -1, -1);
player.sendTitle
ye thats exactly what im doing
still putting a dash in
show
the code I showed you is the same as the javadoc.
no matter what i write, it puts those lines in front of sendtitle
it will only put lines if you are using the deprecated method or the method doesn;t exist
the single string method is deprecated. What error is it showing you with the code I provided?
@Deprecated
then you did not use the code I showed you
i copy paste lol
?paste to show your code
How do i send PacketPlayOutRespawn in 1.16?
what do i need in the constructor and how to get it...?
ok
package me.barry.commands;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class Equipcommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Β§7[ Β§cEQUIP Β§7] Β§fThis plugin's command, is only usable by a player!");
return true;
}
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("equip")) {
Inventory inv = player.getInventory();
inv.clear();
player.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
player.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
player.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
player.getInventory().setBoots(new ItemStack(Material.GOLD_BOOTS));
player.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD, 1));
player.getInventory().setItem(1, new ItemStack(Material.FISHING_ROD, 1));
player.getInventory().setItem(2, new ItemStack(Material.BOW, 1));
player.getInventory().setItem(8, new ItemStack(Material.ARROW, 32));
player.sendTitle("test", "", -1, -1, -1);
}
return true;
}
}
PacketPlayOutRespawn is NMS and you need to use spigot dependency instead of spigot-api
That is correct. its impossible for it to be showing a deprecated on it
hover over and check again
still is
basically, it's like this, it's title, subtitle, fade in duration, show duration, fade out duration. Those last 3 might be flipped around
^ litterally impossible for it to show as deprecated.
it does
screenshot
ok, what you are actually seeing is a no method error. You are on 1.8
It looks like 1.8 only has sendTitle(String title, String subtitle) and its deprecated
no you kept telling me it was deprecated. the method I gave you is not in 1.8 so its not deprecated its non extant
well i told you im 1.8.8 spigot jdk 8 in the first message (:
Yeah, no one supports 1.8 its half a decade old π¦
pvp servers
8%
and im on a danish minehut that only does 1.8
sooo
and im not gonna make my own server with no players
(:
however, your answer is, bad luck. its deprecated in 1.8. block the warning or ignore it.
minehut supports only most recent version
and does not support custom plugins I think
Where I can find metod to place block (by the player) in open source spigot?
"danish version of minehut"
to simulate a player placing a block is not easy
Guys I have this in my onEnable: https://paste.md-5.net/igolobafuh.cpp
And this config file: https://paste.md-5.net/jarobunefu.bash
I know have a command that does reloadConfig but it doesn't work
I want a command that reloads the config so whenever I change something in the config and I execute the command to reload the config it will reload the config file without reloading the entire server. How can I do this?
you could use nms to make the player play the block face animation while looking at where the block should be placed
and then you can do Block.setMaterial to whatever you want
or something like that
you just read all the values again
Im very new to java and making plugins and I dont know how to do this
what do you use the config for?
In the config you enable/disable recipes
Can you show the command you created
And when you use that, it'll send "reloaded"?
Yes
But if I set one to false in the config and use the command it still is craftable
I cant see my config file now
Oh my bad, didn't realize that's onEnable
Could you also show the command you mentioned here?
Hmm, I think I see the problem
It doesn't matter if you changed the boolean to false and reloaded the config, you already added the recipe in your onEnable
why is the config getStringList function not working
So when you reload, you'll need to go through the check again
This time, add an else statement for false. I'm not sure if there's a removeRecipe method though
Corals one question
yes?
I've not tested it, but you could try this```java
public boolean placeBlock(Player player, Location loc, Material type) {
Block block = loc.getBlock();
BlockData blockData = type.createBlockData();
BlockState replacedState = block.getState();
replacedState.setBlockData(blockData);
BlockPlaceEvent place = new BlockPlaceEvent(block, replacedState, block.getRelative(BlockFace.DOWN), new ItemStack(type), player, true, EquipmentSlot.HAND);
plugin.getServer().getPluginManager().callEvent(place);
if (place.isCancelled()) return false;
block.setType(type);
block.setBlockData(blockData);
return true;
}```
There is
so I just have to add else statements to the if statements in my onEnable?
with a remove recipe method
Hmm, better to create a method specifically for that
thanks but I want get this metod in spigot and modify this (disable physics)
so im using the config api getStringList method and its not working and its returning a empty List<String> and idk why the config.yml file has the String list in it getString method works tho ;-; does anyOne know how to fix
You want to intercept the place event and perform it without triggering physics?
private void checkArmor() {
if (this.getConfig().getBoolean("IronHorseArmor")) {
this.getServer().addRecipe(recipeIronHorseArmor);
}
if (this.getConfig().getBoolean("GoldenHorseArmor")) {
this.getServer().addRecipe(recipeGoldenHorseArmor);
}
if (this.getConfig().getBoolean("DiamondHorseArmor")) {
this.getServer().addRecipe(recipeDiamondHorseArmor);
}
if (this.getConfig().getBoolean("Saddle")) {
this.getServer().addRecipe(recipeSaddle);
}
}
public void onEnable() {
saveDefaultConfig();
checkArmor();
}
Something like that
Then add that method after the reloadConfig() as well
- an else statement that removes the recipe
anyone help?
Thats just block.setType(type, false)
You going to share the config? Or the code?
uh hang on
I dont really know where to start here, was hoping for some advice
Iβd like to change the texture of crop plants based on what carrot was used to plant the crop. For example, if the carrot was named Green or something, itβd be a different texture than the default carrot plant.
Is it possible to store a value inside the block and use that to change its texture?
config.yml```yaml
test:
- "test"
- "test2"
- "test3"
code ``List<String> test = getConfig().getStringList("test");``
No
I'm unsure, but try removing the indents. I got stringlists without indents and I got no problems with it
test:
- "test"
- "test2"
- "test3"
k i try
okay :D thanks
but how player set block I want disable physics
didnt work to
Does anyone know how to remove a custom recipe?
i tried now it doesnt work still
You cancel the BlockPlaceEvent do do it yourself
Did you save and reload your config
yes i did
k wait a sec
it prints all of the indexes
but idk why it isnt setting the list to it
What do you plan on doing with the list?
sending it to the player
Anyone knows how can we integrate Firebase for Minecraft Version 1.8. I have made it successfully on Server Version Paper 1.16.5.
[16:23:49 ERROR]: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V initializing AccountLinker v1.0 (Is it up to date?)
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
This is the error it gives
one by one? Are they all string?
Well since this worked, you could just do
getConfig().getStringList("path").forEach(player::sendMessage);
If sending the strings as messages is your goal
This works perfectly^
thats not what i want tho
i want to send in this send(player, getConfig().getString("help_prefix") + test3 + getConfig().getString("test_idk") + getConfig().getString("test_idk2_" + test2));
and i cant loop through the list cuz its empty
;-;
How would I set a players gamemode with a Listener. At the moment nothing is happening except the sendMessage part. I'm not great at this but I hope you guys can help!
Code:
package Listeners;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;
public class respawnListener implements Listener {
@EventHandler
public void onRespawn(PlayerRespawnEvent event){
Player p = event.getPlayer();
p.sendMessage(ChatColor.RED + "Oh no! You died.");
p.setGameMode(GameMode.SPECTATOR);
}
}
changing the gamemode in the respawn event has no effect
Would that work
but other plugin don't like how event cancel (worldguard itp)
Don't use plugins if they ignore the cancelled state of events.
Yea we gonna need more details than this
Or check your listener priority
no, it would not work either
also running commands through the console to do things is stupid
Would scheduler work with that?
probably the only course of action
Yes, delay it 1 tick
Hi! I got a weird issue with my plugin today and i can't seem to figure out what is wrong with it. It returns a negative number for the size of an linkedhashmap (wrapped around with String#valueOf()):
is there any reason for it to do this?
like that sounds like a very weird case to me...
have never seen maps having a negative number
you're probably seeing things
Maybe it would I will try that
uh
a user also saw that it went down to -4 for him
show the relevant bits of code
Bukkit.getScheduler().runTaskLater(yourPlugin, () -> p.setGameMode(GameMode.SPECTATOR), 1);
one sec. Would you prefer screenshots or pastes one by one?
just use runTask?
doesn't matter i guess
k
Forgot that exists
can u just tell me why its giving me a empty list but nOt at the same time?
How can I transfer players through Bungee servers from a Paper instance? If I'll run a command as player will BungeeCord catch that or will it be like running the command from console?
bungeecord listens to commands on the network
running a command on the server will not be seen by bungeecord
I'm willing to bet it's on the path names
what
use a messaging channel yeah
im on a bungeecoord and im using a normal plugin with command and it runs fine?
it doesn't
or do u mean transferring to servers
What about server's #dispatchCommand()?
bungee listens to commands on the network
as you can see here its just an ordinary linkedhashmap
bungee will only see the command if it is sent through bungee
that is, sent by the player
through bungee
to the server
executing a bungee command on the backend server will not be seen by bungee
i have a plugin on a server in a bungeecoord and the command works fine
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
when the plugin's command is used
^^^
but im just using the normal spigot api
sure but that's not how it works
using the commandmap
Hi, i just imported my project again and i get this on my pom
i don't know what you are doing, but bungee will not see you executing its commands on the backend server
did u import the repo
?
i did
im 5+ years old
go ask in paper and get assraped by them for asking in paper
you are trying to use the papermc artifact from the spigotmc repo
paper is not spigot
spigot is not paper
<version>1.16.5-R0.1-SNAPSHOT</version> or do this
ok im not asking for spigot
then why are you trying to use the fucking spigot repository
the paper api is not on the fucking spigot repository
he probs got confused since its called paperspigot
i mean why complain about this, your not helping anyone
i am
i'm telling you to use the correct repository
i'm literally telling you what's wrong
im not going to use 1.16
i'm not telling you to use 1.16
then you're on your own
so
u still have to use the paper repo
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>```
```<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>``` @lyric grove
yeah
show
i don't know if the old paper api artifacts are on that repo
they are
probably not lol
they might not be publicly available or they might be on a different repo
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class God implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
if(!player.hasPermission("god.use")) {
player.sendMessage(ChatColor.RED + "" + ChatColor.RED + ChatColor.BOLD +"You don't have permission to use" + ChatColor.GREEN + ChatColor.BOLD + " God" +
ChatColor.RED + ChatColor.BOLD + "!");
}
player.setInvulnerable(!player.isInvulnerable());
player.sendMessage(ChatColor.RED + "GOD" + "" + ChatColor.GREEN + "" + " mode on");
}
else {
System.out.println("Sorry console, but only player can enter invincible state :)");
}
return false;
}
}
So I made it (with help of few people from the server) that whenever I type /god, /g, /invincible, God mode toggles on/off after each time I type /god.. But same message always pops up, "God mode on".. Where should I add player.sendMessage("God mode off"); so that "God mode off" message pops up after turning god mode off? Thanks in advnace, I;m begginer in spigot coding
thats spigot api dumbass XD
player.isInvulnerable() ? "on" : "off" @paper falcon
i did not
.
no u Where using paper?
to begin with
lol
you were using paper
no 1.9.4 is there lol
i was using spigot to begin with
no u didnt
i bet they removed 1.8 on purpose
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>``` @lyric grove
sorry i included pLaceholder api in my project XD
I'm not exactly sure where to put it in
Hey ya'll, I was provided this snippet of code to use for running things 2 ticks after a client connects:
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
manager.addPlayer(player);
}
}, 2);
but for some reason, unless im just having a brainfart, i cannot actually access anything in org.bukkit.Bukkit lol.
I have org.bukkit.Bukkit imported as well, but just can't do anything with it
this is definitely correct, matched it up with the repo
works for me lol
reimport and clear caches and all that jazz
LMAO i dont think spigot support 1.8.8 to
cuz i changed mine to 1.8.8
it errored
your out of luck mate
u cant use 1.8.8
;-;
sorry
1.12.2 works tho
:)
what are you saying? i know loads of plugins that support it
well it must be a different repo
its obviously a project issue
Works for 1.8.8
idk
they have only 1.10 on here https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/
Yes lmao its the most used for version for servers
lol weird cuz it doesnt work for me xd and pengu
8% of servers run 1.8
@compact haven
my code looks like this now and works perfectly fine
package io.github.TunaJava;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class God implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
if(!player.hasPermission("god.use")) {
player.sendMessage(ChatColor.RED + "" + ChatColor.RED + ChatColor.BOLD +"You don't have permission to use" + ChatColor.GREEN + ChatColor.BOLD + " God" +
ChatColor.RED + ChatColor.BOLD + "!");
}
if(player.isInvulnerable()) {
player.sendMessage(ChatColor.GREEN + "GOD" + "" + ChatColor.RED + "" + " mode off");
player.setInvulnerable(false);
} else {
player.sendMessage(ChatColor.GREEN + "GOD" + "" + ChatColor.RED + "" + " mode on");
player.setInvulnerable(true);
}
}
else {
System.out.println("Sorry console, but only player can enter invincible state :)");
}
return false;
}
}
```
Where did you get that from?
1.8 is rubbish
thats unnecessary
every spigot and plugin statistic
?
but shrug
its the best version for performance
it's not
(excluding 1.7)
1.6 runs better
A lot of servers just use 1.8 for the pvp
no thats 1.12.2
It still only amounts to 8% of total servers
because 1.12.2 has alot of features that matter
yeah obviously but yeah after 1.8, performance went downhill
and its performant still
Total servers probably yes, but player wise 1.8 servers have more. Most of the top servers use 1.8
i mean i use 1.7 on my server
why
its a fork for hcf
1.12.2 is good ;-;
1.12 is literally the most useless version
even hypixel is moving forward
Well thats a statement that can;t be proven nor dis-proven as there are no player totals per version.
yeah
at least the autoclicker sweats that stick with 1.8 have an excuse
what's the point for 1.12
1.12 still gets performance tho ;-; and its got more features
well they use 1.7 still, just with added 1.8 - latest support
no they dont
The top servers use 1.8 and allow people to join 1.9+
unless you're running a 100+ player server there is little difference between 1.12 and 1.16
not true
many hypixel servers have moved up to 1.12.2
and some to 1.14.4
they use 1.12.2
they do
Yea thats what im saying
not really
very really
u can run 100+ on 1.12.2 smoothly
you can run 100+ on 1.16 smoothly as well
you can run 1000+ on 1.7 smoothly
no
Where did you get that from?
hypixel is on 1.12.2
never pvp π
even default 1.8 spigot can run 200+ if you dont have stupid plugins
Since when
you wouldnt see that on any 1.9+ spigot
for concrete mostly
since when did a shitty minigame server become the defacto standard for how a sandbox game server should be run
hypixel do use 1.7 as base
they use 1.7 wdym
who gives a shit about what hypixel uses
they DO USE 1.12.2
they have 1.8 pvp
build battle uses 1.12.2
move to #general, and they dont just use a free plugin from spigot π€£ they have devs
They use 1.8 as the core some mini games are 1.12+
pretty sure hypixel runs its own server implementation anyway xD
they dont its 1.12
they choose what features to have in there and which not
so I don't see the point of this
I said 1.12+
yes? they dont use 1.12 or any version, they use a fork with added features from newer versions
are you running a pvp server?
π€£ how did your life get so downhill so fast
but anyway i need my problem fixed lol
for some reason List<String> test = getConfig().getStringList("test"); doesnt work
its makes it empty
;-;
then its not a list
it is a list
show your config
test:
- "test1"
- "test2"
- "test3"```
thats all thats in your config?
ye