#help-development
1 messages · Page 1772 of 1
this is probably a dumbo question but how could i reload the variables?
so im tryna make a cylindrical vector function but am having trouble with the rotation part. how can i rotate the vector so it spawns the armor stand in a circle rather than just spinning the armor stands around?
public void sheepRod(Location loc) {
Vector newlocation = new Vector(1.5, -0.75, 0);
newlocation.rotateAroundX(loc.getPitch()+180);
Location manipulatedLocation = loc.add(newlocation);
manipulatedLocation.setPitch(loc.getYaw()+50);
LivingEntity rodDummy = (LivingEntity) Bukkit.getWorld("ul_plex").spawnEntity(manipulatedLocation, EntityType.ARMOR_STAND);```
You can override the reloadConfig event and set them there
Or just read from the config instance each time
how would I see if a block was placed by a player?
Any block?
And are you seeing if it's placed by a specific player or any player
It would be better if I could check what kind of block it is, and same for checking what player, but I'll take what I can get
i dont think that is possible without caching or smth
if your version is +1.14 you can set a special PDC value
in that case if you want to know which player placed it map, so yes
what
just nevermind and use pdc
public class Events implements Listener {
private boolean doubleOres = false;
public boolean getDoubleOres() {
return doubleOres;
}
public void setDoubleOres(boolean doubleOres) {
this.doubleOres = doubleOres;
}
}
public class DoubleOreEvent implements Listener {
Events events;
public DoubleOreEvent(Events events) {
this.events = events;
}
@EventHandler
public void doubleOreEvent(BlockBreakEvent event) {
if (!events.getDoubleOres()) return;
}
}
Why does the doubleOreEvent always say that events.getDoubleOres() is false even if it's true?
what's pdc (I'm new)
persistentdatacontainer
how do I use that
?pdc
Also chunk pdc is newer than 1.14
oh, and thanks!
I think it’s 1.16
I'm using 1.16.5
Correct
?
But you can use the chunk pdc, although if you are doing it on any large scale you probably want a database
Look into SQLite or MySQL
also, right now I'm just saving a list to a text file, but I feel like that's spageti code
does that cost money?
or you can host one for yourself
thats better
is there a way to not use sql?
Technically json is an option too, but a database is better for a large scale
how would I use json
so I just save it normally? (it being in a jar doesn't affect anything?)
Why would it be in a jar
when I compile my plugin it turns into a jar
do I have to specifie it when I save the array?
Specify what
why it is a bad idea to use chunk's pdc in this case?
he is just going to store the player's name i guess
Chunk pdc isn’t the best idea if you are going to be storing a lot of blocks
folder name?
no
I mean path by like /home/users/plugin/datafolder
Starts to make the world data bulky, the nice thing about external storage is that you can easily remove it if you want to remove the plugin
It returns a file instance
which I can access the path from, right?
I need the path to write to the file
No you don’t
?
Look at the constructors for File
i see, thanks
wait, so there's a method/class in the spigot api to write a json file?
how do I write a json file using the spigot api
I just sent you the documentation
You still import the same thing
The spigot server shades gson
Actually I’m pretty sure the vanilla server also shades json
so I add
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>```
and import com.google.gson.Gson, right?
I just import com.google.gson.Gson?
Actually you might still need it if you are only depending on the spigot API and not the entire server
?
dont think the spigot import has gson aswell
?
But the API is probably just the API
yes but that doesn't mean the api will have gson
api means the spigot dependency I added, right?
I already said the API alone probably doesn’t have it
do I or do I not add the dependency
Have you tried importing it without the dependency?
not yet
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); how can i get the current time using this format?
Can’t you pass in System.currentTimeMills
yeah i got it ty
JAR creation failed. See details for additional information.
io/github/NightTerror04 [in TerrorGames] is not on its project's build path
help
ok closing the files fixed it wtf
Isn’t it an enum
that's what I thought xd
not very reliable though it would probably be safer to use else if statements to check the type
I mean getName is consistent
java should add custom switches
they kind of already did for strings
dunno why they couldnt just reuse that for all objects
https://hastebin.de/zupacaviwo.lua
Right now I am creating a new inventory every time someone opens the inv, is there a smarter & more optimized way of creating the same inventory for multiple different players?
How to implement monsters not attacking players in java code
I just want to temporarily close
Cancel the target event
EntityTargetLivingEntityEvent iirc
Will this affect all players?
It will effect all living entities
I didn't event think of using a loop LOL
I just want to temporarily disable survival damage, because GeyserMC users are often killed by monsters during the loading phase
thats so genius
Is there any way to solve this problem, without affecting other players
What is setNoDamageTicks mean
Thanks
Is playerjoinevent equal to the completion of the player's terrain loaded?
you cant tell when the player has loaded all their terrain, that depends on their system
So I basically added it so shulkers spawn around in the end (replaced enderman at a very low/rare rate)
I did color them. However I did add the #setRemoveWhenFarAway(true) to them. yet they dont seem to despawn even with that on.
Try setPersistent(false)
Just pre make a inventory and then just open it on the players
public class CustomInventory implements InventoryHolder
And inside that use
Bukkit.createInventory(this, 9, "Epic Inventory") ;
Player. sendtitle does that takes a time?
it takes the parameters: title, subtitle, fade in, stay, and fade out
Uhh tells me nothing
yes it does lmao
Probably need a runnable or something to keep it on the screen
stay is the duration it stays for in ticks
Ah
any help Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_16_R3.command.ColouredConsoleSender incompatible with org.bukkit.entity.Player?
code?
Craftbukkit
oh god
well, are ya runnin' it on 1.16?
you are performing a blind cast
shall i switch to Java 8?
java 8 is better for plugin development imo
if you wanna support pre-1.16 (right?), Java 8
ok thansk!
any idea on how to do this? maow?
I want. java 16.
use java 16
I was thinking a runnable but I'm not sure how efficient that would be on a server where 200+ people could be using it
why do people always ask me?
You seem like a genius
owo thankies
xd
anyway I prefer Java 8
if I wanted Java 16's features, I'd just use Kotlin :)
@tranquil viper couldn't you just use Bukkit's scheduler to keep a 0 fade-out title on screen every second?
tbh I've never experimented with permanent titles
ye it seems like people suggest using scheduler tasks
player chat event in @event Listners?
then y'know just listen to player chat and do shit when chat happens
hmm
Yes but again I'm not sure how efficient that would be with 200+ using it at once
yk
would be the async player chat event
ye
Would it be worth to use an async runnable?
well, if you can make it work properly, I don't see why you shouldn't
its already async
he means for the title setter
also i was wondering if getting player look position & summoning pigs in the look direction was possible i will retexture pigs to wb as a welcome back message
a command?
GodCipher read the chat :p
meh
yes that is possible just spawn a pig at the look location xd
"how to do"
"do it"
yeah how do i get the look position?
dont use an async runnable
not even a bit worth it and not sure if it would survive, probably not
well ty
on player join event in @event Listners right?
into any of your listener classes
It's called PlayerJoinEvent
ik
If you can't find it somethings wrong
oof
how do I play a sound to just one player?
Is there any way to let me know that the player is ready
The player has a playSound method
I try to use ping!=0
yes but it plays at a location to everyone near
That is the world method
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#playSound(org.bukkit.Location,org.bukkit.Sound,org.bukkit.SoundCategory,float,float) states it is played for the specific player
declaration: package: org.bukkit.entity, interface: Player
Caused by: java.lang.IllegalStateException: InventoryOpenEvent cannot be triggered asynchronously from another thread.
anyone know how to get around this?
I'm opening an inv when a message is received
Schedule it on the scheduler as a task
how do i know what location a player is looking at what i found was Get targetBlock = target block not N,E,S,W & geteyelocation = where player is standing
also how do i add player in event listner? bcs (Player)sender wont work
you'll have to send it back to the main thread since the chat event is async
What it is saying is that the returned "true" or "false" of the bool function is not used anywhere by you.
pog
The code executed inside of the function is executed either way
so in that instance just ignore it
for some reason my files also dont save
Please post your saveConfig method
?paste
Correct me if i am wring
wrong*
but would it not be easier to just have one class made for handling all configs?
that's one class no?
aka, you type in the file name and all methods for loading it, saving it, and everything
Yea, but from what i can see it seems that you have to add code to every section just to make one new config.
yea
Ok, you said the file just doesnt save period or?
when you make changes it does not load changes
it doesnt save things
but it seems like it does because i'm reading directly from the file, which works and when i open it there's nothing inside
When do you run the "saveConfig()" method?
hello, i found a multiversion actionbar method with reflections in spigot threads in linux, and now im on windows and i cant find it. if you have the link can you give please ?
Are completable futures safe to use with spigot? I'm unsure since spigoy has it's own multithreading stuff
what does os have to do with actionbars?
browser history
so i can find the link
should be
isn't there a thing for it
like
starting from version x there's a method without nms
a thread was made for it
there was a method
i copied it and i used it
but now i cant find my code
what browser do you primarily use
if you're logged into google, go to https://myactivity.google.com
hmm
wait
it was in another account
found it
ah yes
noice
I am making a lifesteal plugin for 1.12.2. Which events and stuff should i use for this. I'm new to this
EntityDamageByEntityEvent should be the only event you need really
okay!
thank you!
Also I want to make it such that if a new player(joined less than an hour ago) is killed, he will not loose hearts
what do you mean not lose hearts?
Like other players cant steal the new player's hearts
oh as in they can't lifesteal off of new players?
you'll have to keep a record of the new players who joined and have a timer, then in your EntityDamageByEntityEvent check if they are on that list
it's a bit more complex
ohk
is there anything else i can do to keep new players safe when they start?
other than timing
not that i can think of tbh
can i use a timer plugin along side this plugin?
some timer plugin which is already made
is there somethinglike that?
a timer for what?
1 hour timer which starts when the player joins
oh spigot already has an inbuilt timer system with bukkit schedulers
no need to use another plugin
ohh
then what about this?
ohhhhh
i get it now
ohh
okay
yeah
thank you!
but you have to make the decision whether you want to make an individual timer per player
or have a larger timer that checks every 10 or so seconds to see whether their 1 hour timer is over
yes it would work
what i mean is have a list of players
new players
and that timer that goes every 10 seconds would go through each player and see what time they joined, and if their time is over an hour, remove them from that list
is it fine to use an array of ItemStack if I want to save a list of "special items" like weapons created by the crackshot plugin? or will the items lose their properties? like coloured names and the ability to shoot
yes you could
just be sure to clone them when giving it to a player
the better alternative if you're using custom items is to have a handler class but that still works
hmmm thx
now I need to figure out how to save that array to a file xd and load it back
itemstack already has a yml serializer if you're using that
if not binary blob or base64
cant save any data in my plugin
wdym
i dunno nothing gets saved
as in to a yml?
yes
like tomorrow
yes
and i'm getting values directly from config which works but the config is empty :/
means your config isn't loading correctly then
✨adventure✨
i dunno
uhm the message was sent like 40 minutes after
never hasnt
How do I stop a person from taking books from lectern? Let him read the book but not take it
Which event is responsible for this?
idr
thanks
Machine learning is possible
what does this matter?
machine learning has many "difficulties". you can set up a simple one or get very complex
So ik this isn't necessarily a Spigot question... But it has some relation as far as how plugins are loaded. Anyone able to help me with a bit of reflection?.. https://i.imgur.com/1g7qXsz.png
Config question, how do I access the list of levels here? I am going nuts trying to access this! 🙃
enabled: true
levels:
- 1:
xp: 64
blocks:
- stone
- 2:
xp: 128
blocks:
- iron_ore
- 3:
xp: 256
blocks:
- diamond_ore
Where am I going wrong here?
File configFile = new File(Main.plugin.getDataFolder(), "levels.yml");
config = YamlConfiguration.loadConfiguration(configFile);
Utils.debug("enabled? " + config.getBoolean("enabled") ); // works fine!
List<String> lvls = config.getStringList("levels"); // empty
for (String l : lvls) {
Utils.debug("l? " + l);
}
List<String> lvlstring = config.getString("levels"); // contains data
Utils.debug("lvlstring len? " + lvlstring.length());
Can a config stringList not contain objects?
levels is not a StringLIst
levels:
- 0
- 1
- 2
works okay as a string list
yes, that IS a StringList
levels:
- 0:
... stuff
- 1:
... stuff
- 2:
... stuff
fails
that is NOT a StringLIst
levels is a MemorySection
ohhhh
Hmmm so what's a better way to tackle this?
I feel like I'm going about this the wrong way
just load levels correctly as a MemorySection and loop its maps
I don't see anything about that here: https://bukkit.fandom.com/wiki/Configuration_API_Reference#Paths
kinda surprised I'm not seeing more examples of this
section.getKeys() — rad!
or you could just for (String key: section.getKeys(false)) {
Anyone willing/able to help?...
jaunt is not in yoru final project, from the error
you can't use teh Exception of the jar you are about to load
Well I did. But my problem is for some reason it's not loading the class...
The important part in that code is the user agent.
Your error is a NoClassDefFoundError
Yes.
Not a ClassNotFound, so you are looking for a class thats nto there
But I load the class above?...
What's the difference?
URLClassLoader cl = new URLClassLoader(new URL[]{jar.toURI().toURL()}, this.getClass().getClassLoader());
Class jauntException = cl.loadClass("com.jaunt.JauntException");```
NoClassDefFoundError means he's tried to find/load a Class that doesn't exist for the provided parameters.
ClassNotFoundError means the whole class doesn;t exist.
Oh
is it definately the loadClass that is throwing the error?
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL("https://jaunt-api.com/download.htm").openStream(), "UTF-8"))){
String loc;
while ((loc = reader.readLine()) != null)
if (loc.contains("location")) break;
loc = loc.split("\"")[1];
File appData = OS.getDataFolder();
if (!appData.exists()) appData.mkdir();
return new File(appData, loc.substring(0, loc.length()-4)+".jar");
}catch (Exception e){
e.printStackTrace();
}
return null;
}```
I got it working, thanks for the help!
import java.io.File;
public enum OS{
MAC(System.getProperty("user.home")+"/Library/Application Support"), LINUX(System.getenv("XDG_DATA_HOME")), WINDOWS(System.getenv("LOCALAPPDATA"));
private static final String DATA_FOLDER = "WebScraper";
private static OS os;
private String appData;
private Boolean isARM;
private int arch;
OS(String appData){
this.appData = appData;
}
public boolean isARM(){
return (isARM != null) ? isARM : (isARM = System.getProperty("os.arch").contains("aarch"));
}
public int getArch(){
return (this.arch > 0) ? this.arch : (this.arch = (System.getProperty("os.arch").contains("64") ? 64 : 32));
}
public File getDataFolder(){
return new File(appData+((this == WINDOWS) ? "\\" : "/")+DATA_FOLDER);
}
public static OS getOS(){
if (os == null) {
String OS = System.getProperty("os.name").toLowerCase();
os = OS.contains("win") ? WINDOWS : (OS.contains("mac") ? MAC : LINUX);
os.getArch();
}
return os;
}
@Override
public String toString(){
return name() + " (x" + arch + ((isARM) ? "-ARM)" : ") | AppData: " + appData);
}
}
What is the preffered Java SDK version for developing plugins?
I'm currently using version 16
Unless it’s a private plugin in which case use whatever you want
Then java 16 is the highest you can count on
What is the lowest server version you want to run on/support?
1.13
Oh
Huh ?
Minecraft 1.16.5 still ran using java 8
If you are planning on releasing a plugin for 1.13 you can use java 16
Cant
if you want it to run on MC 1.13 then build with java 16 and compile for java 8
Alright, thanks guys
set both target and source as java 8
How can i do that?
use maven
I guess you mean this?
yes
You don;t seem to understand what void means
what event?
ok, what are you currently doing and what do you want to do instead?
No it's not
If you mean the interactive messages in chat
Yep
You can't unfortunately
I know what you mean tho
But you cannot
I was looking for the same thing yesterday
A workaround is to make a command, that will be run by that textconponent
All the plugins do it like this
If you need any more help. Feel free to ask
how do i get a player if the player is a piggy version of an enderman?
How would I send it back to the main thread?
just like lynx said
Ok
Well if its a player, you can just use the Player class
but its a piggy version of an enderman
make an internal command with arguments which will tell the server what to do
and then run it
ok
oh ye
jezus im late
Never heard about that before so i cannot help you buddy
How can i separate this per player but without storing it?
yep
well just have a getPlayer or something
what
in teh event
hmm
idk really what you mean
Could you be a little more obvious ?
Does anyone know how to code it so if you fall in void and have a certian item on you, you dont die but teleport to spawn
certain
i mean you could probably use the player move event but that seems inefficient
maybe a runnable
check the y cord of the player
if < 0 then check inv
Listening to the damage event and checking if it's void damage might be a lot cheaper
/kill is also void damage I believe
Yep, it is. Thats why you always get the "Fell out of the world" death message
Hello! I'm trying to make a custom pathfindergoal using the nms (1.17.1) and it doesn't work (the zombie just stay and look at me). I want the zombie to follow and attack me when I sprint (<= 80 blocks of distance), when I walk (<= 40 blocks of distance) and when I sneak (>= 10 blocks of distance). My class: https://pastebin.com/D8bHnMq7
Location blockloc = player.getLocation().add(0, 27, -176);
if ( blockloc.getBlock().getType().equals(Material.RAW_GOLD_BLOCK)) {
blockloc.getBlock().setType(Material.AIR);
}
return false;
}
}
}``` does anyone know why this isnt working?
either the command isn't being run or the block at the location isn't a RAW_GOLD_BLOCK
Also he's IDE indexing it's epic seems 
I have double checked both
?paste
dont talk about the mess and it all bein in one class im just not bothered to make individual classes for now: https://paste.md-5.net/aqotudaxom.java
getting cannot set to an empty path error? not sure what's the syntax
other than that, I can;t tell if your code path is ok as your indents are all over teh place
you have a . on teh end of the path
oh so i use '.' only in conjunction?
i mean between the two things
i dont know terminology
i did that and i still get nothing.
add sysout to yoru code to see if its getting to that section of code
hello ! I begin in java and I created a maintenance plugin and it works but now I wanna save the list of player to the list to keep it when I reload the server I already do that but it's not working if you could help me it would be amazing I give you the code
class main: https://pastebin.com/WrBAPv6t
class command: https://pastebin.com/43a1TZ9a
why are you using wrapper Boolean instead of primitive type? also please be specific what is not working exactly, do you get any errors? if yes, please show logs
also: in command class ur checking if argument count is more or equal to 1 and trying to access 2nd argument
greetings, bretheren
I come to thee in mine time of need
aside from drowned and zombification does the entity transform event apply to anything else?
Sorry I didn't precise there ils no error but config is set but when I reload list disappeared from config
i think problem is that in every load you don't load maintanceList from current configs but creating new one, and when you set your config to maintanceList all previous things disappear
oh that's a possibility
instead of assigning it to new ArrayList get it from config like main.getConfig().getList("Liste"). And change arraylist to List
thx I try
how do i turn target into a public variable?
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 1){
for (Player target : Bukkit.getOnlinePlayers()){
if (args[0] == target.getName()) {
...
}```
wdym? like last value of target? also start class name with uppercase character
pass the value to where it needs to go
i just want this: if i use /report <player name> it opens a gui with the different reasons. if i for example click on the reason "hacking", it makes the player execute the command /report <player that i used before> <reason>
so i need to save for the player what name he wrote last time
use Bukkit.getPlayer(playerName or uuid) instead of looping through all online players
can you give me an example/send me the whole code? im new to spigot coding 🙂
what you want is to create a new class which will potentially instantiate objects for your GUI
that class will take the player in its constructor
i think yes
uhh, im in a whole phase where i have no idea, what to do, reload method is called in onenable, while save method is in ondisable method, you can ask me for other stuff if you want, thing is that it doesnt work
ping me if you dont like smth
I tried to do main.getConfig().getList("Liste"); and after main.getConfig().set("Liste", maintenancelist);
main.saveConfig();
there is an error
@gentle laurel
public class ReportCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (args.length == 1) {
Player playerToReport = Bukkit.getPlayer(args[0]);
// GUI code... from what we get reason
String newArgs = Arrays.copyOf(args, 2);
newArgs[1] = reason;
onCommand(sender, command, alias, newArgs);
} else if (args.length == 2) {
// Do some stuff with reason recievd as args[1] and player nick recived as args[0]
}
}
}
}
something like this
show logs please
also cuz UUIDs are stored as strings use getStringList. AND you should check if it is null because it may be plugin's firs load and if yes then assign it to empty list
ohhhh right
so I did if(CommandMaintenance.maintenancelist == null){
if(CommandMaintenance.maintenancelist.isEmpty()){
is it good ?
oh yes I do
you are setting Players to the uuid every single time you loop over one
so instead of becoming
Players: # list
- 321389172837182638
- 123981293712983789
- #etc..
``` (which i suppose you want) it will become
```yaml
Players: 23123123123123 # last UUID in the list, one value
i think you can actually just use ```java
Main.instance.config.set("Players", playerList);
yeah well i havent tested that yet but you have a point
oh
but when i convert uuid to string it always comes with !!java.util.UUID in front of it
yes bc i think that is not applicable for the uuid.fromstring method
yeah but then you can just use
playerList = (List<UUID>)Main.instance.config.get("Players");
i dont even know if the cast is necessary
i think getStringList is better cuz uuid is stored like string in config
at least
yeah it possible like that too
I'm not sure about what must I do, should I create a new empty list ?
Players: !!java.util.UUID '9fef0449-7993-4a16-9875-4b095d67d65d'
thats all in config.yml
but it empties out during server on
are you sure that you arent just saving one UUID
because that doesnt look like a list to me
if you're trying to get list from config and it appears to be null, just create an empty one
its a list with only single element
oh wait UUID doesnt have a constructor with a string
okay I try what you said
i can try to get two people on
nah wont work
so like what to do?
/* Saving */
List<String> uuidStrings = playerList.stream().map(UUID::toString).collect(Collectors.toList());
/* Loading */
List<UUID> uuids = Main.instance.config.getStringList("Players").stream().map(UUID::fromString).collect(Collectors.toList());
basically an alternate way of doing something like
/* Saving */
List<String> strings = new ArrayList<>();
for (UUID u : playerList) {
strings.add(u.toString());
}
Main.instance.config.set("Players", strings);
is it like that or I'm totally far if(CommandMaintenance.maintenancelist != null){ this.getConfig().getList("Liste", CommandMaintenance.maintenancelist); }else{ ArrayList<String> List = new ArrayList<String>();
oh sorry I didn't know
Nah
ah xD
I'll send right code in few minutes
oh thx so much
hmm thanks
thx I replaced it
how do you setup build.gradle to build the plaugin? with its dependencies and files like the config?
Is it possible to compile a project that depend on discordsrv with jda relocated and another module for bungee that shades jda (discordsrv doesn't support bungee) and it compiled as new package
(With gradle)
ah yes
🔨
thank you intellij
damn you really used the wrong capture of ?
damn it
lmao
hate when that happens
intelliJ never forgiving you for that one
sadge
How do i fit another class into Main in plugin.yml
You dont
Then how do i make it work
public class Main {
public static class Internal {
}
}
ok ty
make different java files
for different classes
^ this is good advice
Get an understanding of what class is
theres so many people in here with zero understanding of java
well, thats unavoidable
yeah
they don't see a point of doing this i think
I believe its just so many people who want to make their own plugins with no prior experience in coding... the thing is when you have the very basics down you can learn java using plugins. thats what I did and its going good
i cant blame them from wanting to have fun
with coding
but youre going to lose interest very quickly if you dont know the basics
and you dont get spoon fed code
yeah
First of all: if you don't want to lose all players in 'Liste' each time server is reloading, you should load it's previous value to maintance list. To do so:
public static List<UUID> maintancelist;
static {
if (Main.getConfig().getStringList("Liste") == null) {
maintancelist = new ArrayList<>();
} else {
maintancelist = Main.getConfig().getStringList("Liste").stream().map(UUID::fromString).collect(Collectors.toList());
}
Then just use set method like you used in your original code. @dreamy canopy
Thx so much I'll try
welp the loading method only seems to be returning only the first value
well actually it worked
so sorry for ping
😄
Also what methods can i use to not keep reloading the whole server, but only the plugin
or anything that would speed up the start up
:blinking:
im trying save all the chunk that are in a forest, im using ChunkSnapshot#getBiome. The problem is that some chunk aren't in a forest.
Code:
for (int count = 0; count < 1000 && loading; count++) {
x = x + 16;
if (z > 5000) {
return;
}
if (x >= 5000) {
x = 0;
z = z + 16;
continue;
}
ChunkSnapshot chunkSnapshot = world.getEmptyChunkSnapshot(x,z, true, false);
if (chunkSnapshot.getBiome(7, 40, 7) == Biome.FOREST) { //coordinates where there is 100% a block
int xCoord = chunkSnapshot.getX();
int zCoord = chunkSnapshot.getZ();
String coords = xCoord + "/" + zCoord;
PerPlayerBorder.plugin.setChunk(coords);
}
}
hello, how to check if server is running 1.13 higher or lower
is there any simple method or i should check for all versions
ok nvm i will check
Bukkit.getVersion()
i found it
If you wanna use api from New versions, just check its existance with reflection
I just wanted a skull string
To use the right material
Thanks
For multiversion support
e.g
boolean supportsPdc = false
try {
Class.forName("PersistentDataHolder")
supportsPdc = true
catch(ClassNotFoundException ex)
ah
And btw in 1.13 and higher
Is it named player head
Player_head
But caps
And lower
SKULL_ITEM
Right ?
yeah, and you create itemstacks differently
On old versions you also have to specificy data
Ik
And what happens to the data
In 1.13
Will it be ignored ?
i guess so
Thanks for your help
is there an event for when the time changes
or do i just have to have a runnable check the time
btw i mean like day, night, etc.
there s no event
WorldTimeChangeEvent I think
I think lol. Could be wrong
What's the difference between Material.matchMaterial(String) and Material.getMaterial(String)
getMaterial needs the exact name. matchMaterial will look for matches.
Maybe. I'm just reading the java doc
pretty certain that it is simply a better alternative to valueOf. It allows namespaces, spaces are replaced with _ and it allows for legacy name checking
does bukkit.getworld(string)
additionally, you won't get an exception if the material isn't found but rather just null
load a world if it isnt loaded
does that mean ill have to do some worldcreator stuff then
yea
During
matchMaterial is less strict iirc
Think it calls getMaterial at some point
so if i got the player's location in the event, it would return the place they died at?
I think there is to and from in the event isn't there?
Oh looks like the players location would return their death location during the event.
cause there is only getRespawnLocation/setRespawnLocation
I need java version 16 to run 1.17 and then I will need java 17 to run 1.18, why in the past few updates java version was always the same?
Honestly it’s quite a mystery
But the plan was to migrate from java 8 to Java 11 since 11 is also long term support
But then mojang decided to go all the way up to 16
Idk if mojang is considering java 17, but probably since it’s also long term support
Didnt java 11 was in paper plans only
theyre more than considering it, it's required for the new pre-release
Ah good
ok, thanks! Then when I'll switch from 1.17 to 1.18 I will switch my java version to 17 ig
(my server), clients have build-in java runtime I think
how would i set permissions so the /plugin command can not be accessed by everyone
use a permissions API like luckperms or use built in bukkit permissions, there are tutorials everywhere
yep i have luckperms
is this linter warning solvable while still using Bukkit.getLogger()?
whenever i run a luck perms command it just says [LP] Running LuckPerms v5.3.74
use their API
say on command, if user doesnt have this group or role, return false, else, continue logic
yea but im confused how to set it to server commands and not plugin commands
do i just create a command with the same name and set permissions to that or?
1.18 prerelease is in j17
I mean, someone did already tell him that :p
my dc glitches sometimes i cant see long message history for a few tens of seconds
This is moreso a java related question, but if I was to create a child of another plugin's class, and override one of the methods therein, would the original plugin use my method, or it's original method wherever it is called?
Depends
With the assumption that you passed an instance of your subclass, then your overridden method would be used, else not
anyone know if it's possible to summon a beacon beam without the base resource blocks?
I want to use it to highlight the location of any item
How can I block a name change for a specific entity?
No
just not possible?
rippp
Yuh there’s an argument for that
hello i need help with reloading values in my config.yml reloadConfig(); does not work
My Command Class:
String noPerms = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("NoPermissionsMessage"));
String reloadMessage = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("ReloadMessage"));
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
if(p.hasPermission("combatloggz.reload")){
p.sendMessage(reloadMessage);
plugin.reloadConfig();
}else {
p.sendMessage(noPerms);
}
return true;
}```
Well
You are caching the values from the config before reloading
(caching -> storing them)
so do i reload before i store my values?
Ideally you should just update
I already told you why it wasn’t working, and how you could get around it
i could not figure out what to do
when you reload, you’ll have to use smtng like
this.plugin.reloadConfig();
this.noPerm = this.plugin.getConfig().getString("path");
ok
To store the newly obtained value from the configuration reload
alright
You see, values of variables aren’t updated by themselves. Someone has to set a new value to a variable manually.
ok i completely missed that.
can i also do this with ints and booleans?
Yes
ok thanks!
A variable of any primitive data type can be manipulated the same way all other variables can.
symbol: variable Material
location: class Counters
Counters.java:204: error: cannot find symbol
mat == Material.Fire)) {
^
symbol: variable Material
location: class Counters
Getting this error when compiling
Anyone know why?
the whole thing?
Yuh
Also
I’d appreciate if you got it formatted, just in case you don’t, as it would be significantly easier to find the syntax error here
ok
Yeah none of those lower case enum constants are valid
Your IDE should be yelling at you
even as uppercase it still has the same error
wow I am an idiot
I think I firgured it out now
and nevermind
Hey so im making a custom world generator, however only 1 chunk actually used it and all other chunks are just air, any idea why?
public GridWorld(String worldName) {
this.worldName = worldName;
this.worldCreator = new WorldCreator(worldName);
this.worldCreator.generator(new ShipWorldGenerator());
}
as you can see I set the generator to my custom generator but it doesn't actually use it past the first chunk
here's the chunk generator
@Override
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
ChunkData chunkData = createChunkData(world);
// fill bottom layer with barrier
chunkData.setRegion(
chunkX * 16,
0,
chunkZ * 16,
(chunkX * 16) + 15,
0,
(chunkZ * 16) + 15,
Material.BARRIER);
// fill up to y60 with water
chunkData.setRegion(
chunkX * 16,
1,
chunkZ * 16,
(chunkX * 16) + 15,
60,
(chunkZ * 16) + 15,
Material.WATER);
return chunkData;
}
ok so i do have more values that arent like used in my command class, but i still want to reload them in my command class. but there not reloading, the ones that reload are the ones that are being used in the command class.
hey, someone I know is using an invsee plugin (I assume since it has this problem it's not the essentials invsee command, I'll ask which he's using.) and it's eating items sometimes when you view modify someone's inventory, like completely deleting them. I don't know if this is specific to this plugin, or if it's due to confliction with something else, and was wondering if I make a invsee plugin for them (should they not want to use the essentials one for whatever reason), what's likely to be the cause of something like this, and what would be the best way to implement such a feature safely?
Losing items would most likely be down to incorrectly opening the players inventory for both the player and the viewer. It (kinda) works but the inventory is not designed to do that. Both can modify it and items will be lost
A good invsee should clone the inventory and replace it when finished
apparently they're using essentials one, but I don't think this issue is likely down to essentials? they have lots of smaller custom plugins, could they conflict and cause such a thing? e.g if they had a plugin to save a players inventory every x seconds via a runnable, and someone was invseeing and had an item in their hand and not in the inventory?
I would suggest telling the plugin maker about it.
going to have to try diagnose whether it's essentials itself or something custom they have being the reason
yes, anything that messes with the inventory will potentially break invsee.
gotcha, thank you -- I'll have a read over their plugins and see if I can pick anything out
[01:18:22] [Server thread/WARN]: [Yu-Craft] Loaded class net.milkbowl.vault.economy.Economy from Vault v1.7.3-b131 which is not a depend, softdepend or loadbefore of this plugin.
[01:18:22] [Server thread/ERROR]: [Yu-Craft] - Disabled due to no Vault dependency found!```
how can I fix this error?
I have vault installed on the server
do you have an eco plugin?
you need Vault
My custom Yu-Craft plugin is the only economy plugin I intend to use
is your plugin registering with vault as an eco provider?
Yeah that's why I'm trying to change my custom currency system to vault
Elgarl , he needs vault
he has vault
Disabled due to no Vault dependency found!
Yeah that's what I'm trying to figure out how to do
What vault version do you have?
I have vault, just trying to register it to my economy plugin
he doesn;t have an eco registered with vault is his issue
I have Vault v1.7.3-b131 according to /vault-info
right chat, its his plugin he's tryign to register
I have Vault v1.7.3-b131 according to /vault-info
show code where you are registering yrou eco with vault?
?paste
also you need to do your ... hold on I'm waiting for intellij
if (!setupEconomy() ) {
Bukkit.getLogger().severe(("[Yu-Craft] - Disabled due to no Vault dependency found!"));
getServer().getPluginManager().disablePlugin(this);
return;
}```
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
this.economy = rsp.getProvider();
return true;
}```
I already have a static instance of the main class, so I decided not to make this.economy static as the api says
No, that is getting a provider. Where do you regsiter yoru economy?
Bukkit.getLogger().severe(("[Yu-Craft] - Disabled due to no Vault dependency found!"));
why is it servere ? just wondering
that's copied and pasted/slightly modified from the api
It's pretty severe to be fair
Your plugin has to regsiter an RSP with bukkit
Not sure how to
eg, this is how iConomy registers java final ServicesManager sm = Server.getServicesManager(); sm.register(Economy.class, new VaultConnector(this), this, ServicePriority.Highest); log.info("[iConomy] Registered Vault interface.");
I can implement that into my plugin, now I'm wondering how it will fix my issue, how it will impact the plugin, and what I could use those instances for?
you create a vault connector (google), register it with Bukkkit and vault will see it when you ask for an eco
Okay I see, so it's just something to help Vault understand that "Yu-Craft" is using it
right?
its telling Bukkit that your plugins is an Economy provider
Vault simply looks for any providers and gives access to plugins
?paste
https://paste.md-5.net/keparufile.java This is teh full regsitering method in iConomy
Decided to get rid of my custom economy system because there's way too much support with public plugins via vault
thank you very much
I think there's something severely with how I've attempted adding Vault to my plugin.
When doing so, I downloaded the latest version of Vault, went to Project Structure, Modules, Dependencies, then added the latest Vault.jar there, and changed scope to "provided". Not sure how to properly do it :/
do you not use maven or any build tool?
attempting to do this gave a lot of dependency errors
I use Maven but I barely know what that is.
Every time I attempt to add a dependency there, it appears red
if you use maven you should not be manually adding dependencies
How could I automate it?
all dependencies should be listed in your pom
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>```
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>```
and add a repository xml <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository>
when I add ```
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>```to my dependencies, it appears red
add the repository
repository gives no errors. I don't need the dependency?
you need both
teh repository tells it where to look, the dependency tells it what to look for
?paste
intellij
there shoudl be a button to refresh or something
top left or bottom right
I don;t use intelij
I'm looking around for it, what is it called in your IDE?
Eclipse doesn;t have one, it auto does it
Every time I've ever attempted to add a dependency in Maven, it always appears as red
ah
I know others who use intelij say there is an update/refresh button when you have the pom open
my bad, yeah it says 1.7
I right-clicked my pom.xml and clicked "reload from disk" nothing is red now!
I'll give it a try
Keeps giving this error
https://imgur.com/a/S3nHv8U
same as before
you have to create that class
I think it extends Economy else it implements
that class will contain the access methods Vault needs to use your eco
Really confusing because the VaultAPI doesn't have any of this https://github.com/MilkBowl/VaultAPI
none of that is to register a new economy, only USE an existing one
Ah I see, what methods should I incorperate in the VaultConnector class
okay cool thanks! I'll give it a shot
public class VaultConnector implements Economy {
Mhm that's all good and working. Do I need to do anything further after implementing the methods?
hook them to your eco to get and set data
It provides this: java @Override public boolean hasAccount(OfflinePlayer offlinePlayer) { return false; }so I would need to code each of these methods?
yep
My goal is to transfer my custom currency system into a more a universal currency system so I don't need to re-invent the wheel so-to-speak. There are dozens of auction, marketplace, player shop plugins already out there so I thought: Why code them myself when people have already done them so many times?
Should I be actually doing all of this to achieve this goal? Is there a simplier solution? I just feel a bit confused by this right now.
if you want others to use your plugin you best support vault
Oh, this project is completely for personal use.
then why bother with vault at all?
I thought it may make it easier to have a universal currency to hook into all of these plugins
Don’t you need to use vault to interface with said existing plugins
What would you recommend instead? When I add some public plugin, how can I allow that plugin to use the same currency as my plugin?
as I said, if you want plugins written by OTHER people to use your eco you need to implement vault
you can;t force other plugins to use your plugin
not unless you implement a vault connector so they can see it
Alright so I should just continue with the implemented methods from public class VaultConnector implements Economy {
I really appreciate the help, I'm just a bit slow with it because it's all new to me
Would anyone have an idea as to how I should detect players placing items in inventories? InventoryClickEvent doesn't get called, so I'm not sure what to use instead.
click or drag events will fire
What do you mean? When I tested it, when you have an item held on your cursor, InventoryClickEvents wont fire..
Sorry, let me revise this
it will fire when you let go
Ok, update , I've refined the problem to checking if the grindstone slots are full. Since the only way to differentiate them is by checking the slot type (differentiate the quickbar/grindstone inventories) how would I check whether specifically the grindstone inventory is full, as i can't specify a slot type? Perhaps inventoryholders?
is there a better way for making restart persistent timers than just saving the time remaining onDisable?
because in a crash, if the plugins are foreced to close, it might not call, right?
I mean you can save regularly
https://gyazo.com/a83752ea6b157d1247a7b3a8064b7dc4 anyone know why this is happening when I try and making a rolling animation?
public void rollMachine(UUID uuid) {
if(rollingMachine.contains(uuid)) return;
Player player = Bukkit.getPlayer(uuid);
Inventory inv = getInvOfPlayer(uuid);
int fiftyFifty = new Random().nextInt(50) + 1;
int bet = getBetAmountOfPlayer(uuid);
boolean win;
if(isEven(fiftyFifty)) {
plugin.econ.depositPlayer(Bukkit.getOfflinePlayer(uuid), bet);
win = true;
} else {
Roulette.econ.withdrawPlayer(Bukkit.getOfflinePlayer(uuid), bet);
win = false;
}
int rolling = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
for(int i = 36; i < 45; i++) {
flip(inv, player, i);
}
}
}, 0L, 5L);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getScheduler().cancelTask(rolling);
if(win) {
player.sendMessage(format("&aYou won."));
} else {
player.sendMessage(format("&cYou lost."));
}
}
}, 400L);
}
private void flip(Inventory inv, Player player, int slot) {
ItemStack lostMoney = newItem(Material.BLACK_CONCRETE, "&cLost your money", null);
ItemStack doubleMoney = newItem(Material.RED_CONCRETE, "&aDouble your money", null);
if(isEven(slot)) {
for (int i = 36; i < 45; i++) {
if (isEven(i)) {
inv.setItem(i, lostMoney);
} else {
inv.setItem(i, doubleMoney);
}
}
} else {
for (int i = 36; i < 45; i++) {
if (isEven(i)) {
inv.setItem(i, doubleMoney);
} else {
inv.setItem(i, lostMoney);
}
}
}
player.updateInventory();
}
If it's hard to see, it flickers a change in the inventory but doesn't actually change
Why do you generate an int for 50/50
random.nextBoolean
because I only want it to flip specific items
oh
wait
i see that
its cause I copied code from earlier whoops
Don’t believe you need to call updateInventory either
ok
Heyoo, I'm having issues with comparing 2 Inventories. Trying to get the InventoryClickEvent to cancel to stop the GUI from being modified but during the comparison check, it fails to check if they (the GUI and the event inventory) are the same.
[ScreenManager.java]
public void display(Player player) {
// Displays the current stack GUI to the player.
player.openInventory(gui);
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
if (e.getInventory().equals(this.gui)) {
Bukkit.getLogger().warning("Blocked");
e.setCancelled(true);
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Bukkit.getLogger().severe("--- Event Inventory");
Bukkit.getLogger().warning(e.getInventory().toString());
Bukkit.getLogger().severe("--- Class Inventory");
Bukkit.getLogger().warning(gui.toString());
if (e.getInventory().equals(gui)) {
Bukkit.getLogger().warning("Blocked");
e.setCancelled(true);
}
}
It's like both inventories are somehow different, even though im using the same local variable gui as the way to open and manipulate.
Please ping me when you have the chance to help with me because I'm most likely trying to play around with it or digging up some open sourced GUI plugins
for me, I store the players UUID that is using the inventory with it's own inventory then check if the players inventory is the same as the clicked one
If that makes sense xd
Store the view returned by openInventory
Wouldn't this also trigger other "InventoryGUI" like crafting tables, cartography tables and anvils if I'm comparing between UUID of the player's inventory vs my custom inventory gui?
Oh yeah ima check that part out, that seems like a good path
I create a custom inventory and then store that in a hashmap with the uuid of the player, haven't had any issues with it
I just worded it weirdly
Ahh interesting, I'm still new to the SpigotAPI and with all these new library/vars like hashmaps, NMS and other cool things i can play around with. I'll probs check that out after I run down through Coll's solution
oke :)
if you're interested, what I do is:
private final HashMap<UUID, Inventory> bettingInventories = new HashMap<>();
//on command do this
Inventory rouletteInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "Roulette");
bettingInventories.put(player.getUniqueId(), rouletteInv);
//on click do this
if(event.getClickedInventory() != getInvOfPlayer(uuid)) return;
then I can just use the uuid to get the desired inventory and check if its the
Yeah you can just store the view in a set and use contains
anyone know how to achieve the drum roll sound effect?
are the spigot/bukkit mappings for all versions indexed somewhere or published to a maven? I found https://hub.spigotmc.org/stash/projects/SPIGOT/repos/builddata/browse/mappings but I really don't want to hard-code a bunch of at=longhash's
I'm trying to add them to https://wagyourtail.xyz/Projects/MinecraftMappingViewer/App
is there at least a json of hashes for each version, even if it's embeded in a jar somewhere?
is that doable with client-sided only js.
the site uses bitbucket right? where's the api endpoint I can't find the root for where I'm supposed to put
/repositories/{workspace}/{repo_slug}/commits/
o that's only bitbucket cloud with an api, not self-hosted as far as I can see
o wait. old 1.0 api works https://hub.spigotmc.org/stash/rest/api/1.0/projects/SPIGOT/repos
I think I can figure it out from here
https://docs.atlassian.com/bitbucket-server/rest/4.4.1/bitbucket-rest.html#personal-repositories
but this is so much more jank than every other mapping provider. at least they give me maven pom's (or a json in yarn's case)
yeah. so i dug into buildtools, found their hashes are all here: https://hub.spigotmc.org/versions/
why wasn't that the response to my question...
Math.random() < 0.0001 is 1 in 1000 percent chance right ?
should i use a scheduler or a thread when sending packets to all players constantly?
i think so yeah
always use the scheduler
ok
or well actually Math.random() <= 0.0001
Heyo again haha, I'm wondering why does <ItemEnchantEvent>.getOffers() return 3 things instead of an array of things?
Had a for loop constructed like
for (EnchantmentOffer eo : e.getOffers() ) {
eo.getEnchantment().getKey(); // Somewhere had String.valueOf()
}
This even applies to iterated loops like:
for (int i = 0; i < eo.getOffers().length; i++) {
eo.getOffers[i].getEnchantment().getKey(); // Somewhere had String.valueOf()
}
And for some reason it spat out 9 entries, repeating the 3 offers 3 times. Am I interpreting this wrong?
Ohhhh, i was able to trim it down to the cause.
Seems the event was booted 3 times, I'm kinda unsure how to proceed after this (As in make it run once)?
So the event get executed 3 times?
yeah
return 3 things instead of an array of things?
as you can see it returns an array of 3 things.
Which event? The world save?
Added a top level logger and it got booted 3 times
Uhhh
declaration: package: org.bukkit.event.enchantment, class: PrepareItemEnchantEvent
can you send us more code?
Oh yeah i got that, but it shot out 3 of the same items
yeah sure
sounds for me like 1 time for every row
how do you guys build your plugins? I've just switched to gradle but when I build it, it gives me a jar without the dependencies and without the config file in it
So i assume you only want it to be executed once right?
so the event fires once for each offer?
Maven is preffered
package xyz.nekonii.hexcraft.VanillaEnchantOverride.listeners;
import org.bukkit.enchantments.EnchantmentOffer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
import org.bukkit.plugin.Plugin;
import java.util.Arrays;
public class EnchantingTable implements Listener {
Plugin plugin;
public EnchantingTable(Plugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void PrepareItemEnchant(PrepareItemEnchantEvent e) {
this.plugin.getLogger().info("Launched test");
for (EnchantmentOffer eo : e.getOffers()) {
this.plugin.getLogger().info(String.valueOf(eo.getEnchantment().getKey()));
}
}
}
iirc, yeah
so at least if smth changes
@steady rapids When creating a new artifact. Choose jar > From modules with dependencies
Hmmmm that kinda feels awkward to work with
And it wouldn't make sense because it doesn't return each individual offer
Go to File > Project structure > Artifacts > Jar > + > From modules with dependencies