#help-development
1 messages · Page 12 of 1
well they are only null if its the first or second block
yeh the other day you said something different haha xD
well yes but I do you know how to do it if there is no players near a warden then do something, sorry if im asking too much im just new to spigot
im pretty sure i understand it rn, im making it avoid cliffs
thats basically what you need to do. just pass in a boolean with the default of true and set it in the loop to false if any entity is a player
can you help me with the code im not really sure how to do that
you could look at my impl. that should already avoid holes
maybe you can adjust it so they jump over little holes
WalkablePathfinderStrategy?
i wont spoonfeed you but i can give you the right direction:
get the wardens world, invoke https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/World.html#getNearbyEntities(org.bukkit.Location,double,double,double) on it, set the wardens location as the center, set the other 3 values as you need (its the radius as boundingbox) and loop over the return of that method.
the stream api might be useful https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html#stream--
yep
Question, since I can't make Location serializable, should I either A: make a seperate class for a location, which is serializable (Prettier) or B: seperately save x y z coordinates and world name (probably more efficient)?
depends, i would go with the OOP way and make a wrapper for the location
but for the most cases the latter will be enough
if you are saving to a database or web service i would go with a dto, otherwise just save the x,y,z and worldname
Imma try my own
and if it fails ill use that
got this written out rn
orange sand = previous
sandstone = current
I essentially dont think i need previouser atm, just current and previous, kind of just tried to visualize this in my head as
so if my code is correct, i assume it would flag false for a cliff
gonna ?tryandsee
uhm
my client froze?
ok
@opal juniper 
I AM BEING ATTACKED
think of a better name and pr
heh, my comment came from the depths of my heart
only long-time developers could create such shotty names
lul
do not worry I have refactored my own codebases several times to attempt and fix these poor names I have created
i mean it’s before previous, so previouser!!
that’s an IDE name lmao - i remember that
i’m not sure if y’all do it, but i like using the intellij “.var” autocomplete
tbh previouser sounds like some harry potter spell
hm it must be from an AI taking into consideration your previous variable names
wingardium previouser!
holy shit im levitating
i just looked it up and there is no word for before the previous
I do this whenever I've started typing the value of the variable. Typically I'm writing kotlin so I just need the keyword and the name, so the .var shorthand is quite unnecessary
(and well anything past the introduction of Java's var as well)
yuck
wots yuck
java var sucks - i know that paper use it to minimise the diff on their patches but still
ah
previousPrevious
why not just
Hey quick question if I have two location objects but I generated these two differently at different times will they ever happen to be equal to one another when comparing them with location1.equals(location2) ?
secondPrevious
beforePrevious
if the two locations are referring to the same location, then yes
really?
== then never, .equals() should be overridden for World or location to compare properly
of course
yep no problem
I think I’m going to code my own discord-Minecraft interface
please do not include any console input/output in any way shape or form
nor the ability to run unchecked commands, act as a superuser, etc etc
what do you mean? I’m going to be starting from (almost) scratch here using the pinned tutorials and my former knowledge from other languages
heh
that has nothing to do with coding
just keep it strictly chat communication, maybe rank sync from MC -> Discord (ensure ranks given have NO elevated perms), and perhaps a list command on the Discord
I just want people to be able to see what people in Minecraft are saying, and for Minecraft people to see what people in #minecraft are saying
ah so people can’t execute commands from discord?
I wasn’t planning on allowing that
should be simple as automatically removing “/“ from any message, right?
Don't even need to
as long as you just use the proper methods, it'd be impossible to run commands without you building in the ability to
sorta like how dynmap web users can’t run commands, but their usernames still show up in chat?
Not too familiar, but should be right
If you're not firing a slash command you're not firing a slash command.
basically if you send a chat message from within the Dynmap, it associates your IP with your username from the ip you use to connect to the server when playing, then prefixes “[WEB]”
what do you mean here?
I mean, it makes sense
But
Mike either you are I are confused
If you send a message with a bot. Unless you're sending a slash command you're not sending a slash command.
we're talking about using MC commands as a consoel user from discord

nothing to do with discord slash command interactions xd
nope who in the world uses discord commands from minecraft
can bots even fire slash commands
Yes
well.. considering the age of the version I’m using I might be better off using an IRC bot then an IRC to discord bridge
both of which are already made
literally does not matter
?
the version of mc you're using
it does, I don’t have to make something if it already exists
well then just use DiscordSRV
there’s no discord-Minecraft bridges for this version
CB 1.1-R6
(technically R5 but R6 stuff works with it)
wanted stuff like more advanced end, nether, apples from trees, etc..
just do it yourself then? 😄
also we decided we wanted the limitations of the older version. Pushes our creativity and forces us to think outside the box to solve problems, both inside the game and outside, as it seems to be going
I could but I suck at using eclipse and I could also just do it with Minecraft->IRC->discord
or just get all my members to start using irc 😈
Eclipse 👀
have fun getting people to join on 1.1 tho xd
it’s easy
JDA is the most popular java library for discord. it's quite easy to use and if you havent used it, then it's a good thing if you wanna learn sth new 😛
ehm
already got like 10 ppl so far
I feel like JDA is compiled with too new of a java for said craftbukkit
or am I just creating unnecessary problems
I’m fine with using older stuff
what version is CB 1.1 compiled on (JDK)
it runs fine on java 8. no idea what cb 1.1 is using
can anyone help me, I am working on a plugin where if a player is 6 blocks away from a player the warden starts healing, im not really sure how to do that, can anyone help?
you already have 2 open threads, why don't you ask there
almost my whole environment is Mac based and I’ve got PPC stuff if we need to go that old xD
they're all archived
you can revive them, no?
so uhhh help ples
okay so JDA is compiled with JDK 8, and CB is compiled with JDK 6
meaning no discord bridge without manually interacting with the Discord REST api
oh boy that sounds complicated
it definitely is
just because CB is compiled with java 6 doesn't mean it cannot be run using java 8
maybe I should get one of those SMS plugins lmao, just text everyone
I was gonna say something but I know nothing
too costly
money is no object, we will also install a bank account stealing plug-in
lovely
I wonder…
anyways Discord bridge should be fine
nah fuck entities
yeah okay but anyway, I need an idea on what to code, and not something that's already done 😄
still improvable
otherwise do some space ballons like big suns which explodes into a supernova which leads to a blackhole absorbing the whole world
it's me again, how do I get the old position? PlayerChangedWorldEvent doesn't send the old Location, and e.getPlayer().getLocation() already returns the new teleport location
give me a moment
you can't. Check whether PlayerTeleportEvent gets called, too. there you can get the old location
thanks, that works
java.lang.IllegalStateException: InventoryOpenEvent may only be triggered synchronously.
what causing this error ?
you've tried to open an inventory async
dont do that
i just did player.openinventory(inv);
where
in a another class
have you read it?
yep
if it says "may only be triggered synchronously", then you probably tried to use it asynchronously
ig i fixed error lemme test it
you gotta use the scheduler and schedule a synced task on the next tick
Bukkit.getScheduler().runTask(plugin, () -> { // yourCode
no
you do not need the scheduler to send an inventory
you need it only when you are doing stuff async
but we don't know what you're doing since you haven't sent any code
you're probably using the AsyncPlayerChatEvent to send an inventory, or similar
and the AsyncPlayerChatEvent obviously gets executed asynchronously, hence its called like that
oh yeah
thanks a lot it worked
F
Hate Oracle SQL
something like this ig
i guess you can make it async but idk if its worth or good
how to unregister plugin command when its disabling?
When the plugin is shutting down? You shouldn't need to unregister commands
in onDisable() method
But why would you need to do that?
to avoid this [15:10:47 ERROR]: null org.bukkit.command.CommandException: Cannot execute command 'cd' in plugin CustomDiscs v0.5-b72 - plugin is disabled.
Wack that you're disabling your plugin
yes, i know
Personally don't recommend it
just make a customdiscs on/off
and make everything depend on a boolean being true
💀
Not sure you can even remove command executors without reflection
Only has get and set
Can anyone tell me what is wrong with my code
I need help to understand the MapPalette's algorithms
Those functions are deprecated because the color indexes of minecraft palette are magic values, meaning that they are subject to change in future updates. On a side note though, I've been actively using the MapPalette since at least 1.16 (now we are in 1.19) and I never experienced any color changes.
private static double getDistance(@NotNull Color c1, @NotNull Color c2) {
double rmean = (c1.getRed() + c2.getRed()) / 2.0;
double r = c1.getRed() - c2.getRed();
double g = c1.getGreen() - c2.getGreen();
int b = c1.getBlue() - c2.getBlue();
double weightR = 2 + rmean / 256.0;
double weightG = 4.0;
double weightB = 2 + (255 - rmean) / 256.0;
return weightR * r * r + weightG * g * g + weightB * b * b;
}```
What I don't understand in this algorithm is how the weights are determined. Does it base of a well known algorithm or something? The return value is pretty logical, what doesn't make sense for me is that the weightG is fixed to 4 while weightR and weightB values may vary between 2.0 and 3.0 according to the mean value of the red channel.
Secondly, what if we wanted to consider the alpha channel as well. I suppose we'd add `+ weightA * a` in the return value but what would be the value of weightA?
can't really test rn, can someone tell me if looking north/south/east/west is determined by yaw? Or was it pitch?
ok thanks
I keep mixing those up
of course how could I ever forget that
okay I completly removed maps because why not, gonna see if this works
hey guys
learnjava moment here but
How can i make a float decimal place always .50
i just want to always get dead center location of a Vector is why
Is it going to be a string eventually or
String.format
no its always a float
or DecimalFormat
i think thats actually easiest

honestly, i dont feel the severity of the situation i dont think theres enough exclamation marks
Hello, i got this error on my plugin, how do figure out whats wrong? java.lang.NullPointerException: Cannot invoke "com.cradlenetwork.CradleAbilities.Main.getConfig()" because "com.cradlenetwork.CradleAbilities.Dranwen.DranwenEvents.plugin" is null"
The error stems from you calling getConfig while "plugin" is null 👍
(very useful ik)
yea 😄
Somehow compiling this today does not wrong
pom.xml
<repository>
<id>iridiumdevelopment</id>
<url>https://nexus.iridiumdevelopment.net/repository/maven-releases/</url>
</repository>
...
<dependency>
<groupId>com.iridium</groupId>
<artifactId>IridiumColorAPI</artifactId>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
console
Caused by: java.lang.ClassNotFoundException: com.iridium.iridiumcolorapi.IridiumColorAPI
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:151) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 12 more
do you know how to fix it?
not unless you show us the code
okay almost works
is that playeruuid as name of the file?
yeah, getUniqueId
Im guessing the problem is in this class https://pastebin.com/A4urWiGz
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.
and you're calling the constructor on onEnable?
no, how do i call it? is it just adding it into the onEnable
all of the methods in the class you sent above are non-static, so clearly you've made an instance somewhere
show me the code in the Main class
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.
do i need to include it in output in jar artifact?
what line is this from
Does this work as a singleton?
here is the whole console error, im not sure how to figure that out tbh https://pastebin.com/TfAiLE3M
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i used plugman this time to quickly get it again, but ive tried restarting the server aswell and it still doesnt work
why are you setting a static field in a constructor lol
well whatever
this.getConfig().options().copyDefaults(true);
before this line
try putting
new DranwenEvents(this);
oh my god it actually works
thats for the config to load. I didnt get that working before, so im not sure changing that is correct but i can try
How to get the opposite of a vector? Like I'm cancelling the push force of the moment you get damage
depend on where you mean with the static, but probably just because that how i was thought to do it
I also didn't see a getConfig method in ur class
so like I'm a little confused
although I've never done config files before but this.getConfig states that getConfig should be in the Main class?
I do have some, example on line 42
what
or did you get you wrong
i did
I mean ur calling getConfig from Main but I don't see a getConfig method
first of all you're doing "plugin.getConfig()"
that's bad because
- You never set plugin to anything, it's null
- there's no "getConfig" method in the Main class
never had that before, so thats interessting. Like i had the plugin working a few hours earlier and havent changed that
well unless that's how config methods work, idk I've never used config files but if you're doing plugin.getConfig() that means, literally, "call method getConfig from the plugin class"
plugin is supposed to be an instance of Main so
first of all just put a var of type DranwenEvents at the top of ur main class
in onEnable set it to new DranwenEvents(this)
that should fix the plugin field being null
but then again I have no idea why you didn't just make everything in the DranwenEvents class static
there's only one field iirc
nvm
there's not
I'm blind
move the initialization of DranwenTpCooldown to the constructor of DranwenEvents.
plugin isn't set yet so you're getting null for plugin.getConfig()
also that
so its that the Cooldown class doesnt have to plugin set? Have i understood it correctly then
in ur DranwenEvents class you have a variable at the top of type Main
it's called plugin
that variable is not set to anything by default
so naturally it's null, until you call the constructor which is
public DranwenEvents(Main main) {
plugin = main;
}
again, I don't know why ur using a constructor for this
yea
fair, just how i got thought. Is there a better way to do it, please tell me
although this is not the case here since you also need to move
DranwenTpCooldown TpCooldown = new DranwenTpCooldown(plugin.getConfig().getInt("Abilities.Dranwen.Teleport.cooldown"), TimeUnit.SECONDS);
to the constructor
which is not static
cuz ive understood that its not the best
in this case you can keep the constructor but normally if you're setting a static field only you shouldn't do it through a constructor cause then you're just making a new instance for nothing
do you have an example of how i should do it instead?
lemme try and explain how static vars work vs non-static
basically you should be familiar with the concept of classes by now so I'll skip that
when you make a new class, all of the stuff that is not static belongs to it
for example
public class Student{
int age;
int gpa;
String name;
}```
all of those belong to an instance
so to access them you first need to make a new instance of the class Student
to do that you need a constructor first, which is basically a special method that can be used to make a new instance of a class
public class Student{
int age;
int gpa;
String name;
public Student(int studentAge, int studentGPA, String studentName)
age = studentAge;
gpa = studentGPA;
name = studentName;
}
}
so there's the constructor
to make a new instance you'd do something like
Student student = new Student(15, 4, "George");
and then you can access its properties and methods by doing
student.age
student.gpa
student.name
same for methods, if you had a method you'd do <instance>.<method>()
but for static variables, they don't belong to an instance
they belong to the class itself
so basically
public class Student{
int age;
int gpa;
String name;
static String species = "Human";
public Student(int studentAge, int studentGPA, String studentName)
age = studentAge;
gpa = studentGPA;
name = studentName;
}
}```
to access species, you don't need to make an instance
you can just access it through the class itself
so, Student.species
in your case "plugin" is static, so setting it in the constructor doesn't make sense because you don't need to make a new instance of your class just to set a static field
instead you could make a method, such as
public static void setPlugin(Main plugin){
this.plugin = plugin; //I'm doing "this.plugin" here because the parameter and the variable have the same name, so this will help the program differentiate
}
and then on your onEnable method u can just do <class>.setPlugin(this)
no need to make a new instance
pro gaming
https://www.thoughtco.com/static-fields-2034338
idk this might help too
that makes sense, but you are still using a static in the setplugin? But i think i understand how im supposed to go about this
wdym
basically if you make a method static, you won't need to make a new instance of the class it belongs to in order to call it
u can just reference the class itself (not an instance of it)
so for example
DranwenEvents.setPlugin(this)
then i can just referance it in every other class, do i get it right then?
yes then u can reference it in every class instance
of DranwenEvents
and also other classes if the var is public ig
yaw is left/right. Just remember a cowbow who shouts yeeehaaaw and then throws his lasso. they always rotate it left/right before throwing it, lol
what lol
okay, ill try that and come back. Thanks, i have a lot to learn from people here i realise 😄
You remember it by a ship pitches up and down, rolls side to side, and the last one left is yaw
which is turns left and right
yes but if one cannot remember that, they could also think "the plane yaws up/down"
lmao what
I mean the term pitch is used often in literature for ships pitching up and down
how is one supposed to remember that if you cannnot remember what pitch and what yaw is
Because a ship doesn't yaw
lets say i have a custom implementation of the player class that contains like a second inventory and some stats
what would be the best way to efficiently store this?
yeah but how is one supposed to remember that lol
for example I am german, I dont even know what pitch or yaw means in german. Hence I for example cannot really remember which is which. that's why I came up with this weird yeeehaaaw thing lmao
serialize it lol
I mean you can read a book or you can listen to Barrett's Privateers on repeat for a few hours and memorize it
like, if someone knows that a ship yaws left/right, then they obviousoly already know what pitch and yaw is and dont have any problems rememering it, right?
I mean the point is that you can remember all of them by just learning how a boat works. Yeah, if you can't remember that how can you remember a cowboy lol
when i do "this.plugin" in a static it gives me an error
sorry don't do this.static
ye
this refers to the instance
it's hard coding without an IDE lmao
so what should i do instead do define the main?
obviously. "this" refers to the current class instance. static members are not related to any instance and hence there is no "this" in static context
because it screams yeeeehaaaaw. how could one forget that lol
Well if they have memory issues to the point they can't remember a ship pitching up and down.
I mean you can learn through a song just memorize the snippet from https://youtu.be/ZIwzRkjn86w?t=191

it wants the "Main plugin;" to be static still, is that correct?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
you mean the field? yeah
the var has to be the static if ur gonna be accessing it from a static context
shouldnt be using static for it pass by ref
I love how people fight against static instance getters, claiming it prevents unit testing, while mockbukkit exists since years now
PlayerJumpEvent is a paper event right?
yes
How would you use an event like that on Spigot?
You would not
like with PlayerMoveEvent?
shaudhausdhauidSDihudah+
you can check teh Y velocity. If its positive odds are you jumped
in PlayerMoveEvent?
yes
easy to test, just send a debug message any time event.getPlayer().getVelocity().getY() > 0
there is a constant value that one can check. I have a playerjumpevent somewhere in my maven repo I think
The problem is
that the PlayerMoveEvent is called actually when the player moves, but it can be fired even with another plugin.
0.42 is the default jumping velocity IIRC, and every level of jump boost adds another 0.1 or so
so since I want to cancel this event in a certain moment, maybe the push is made by another pl.
k
yes, but you are only interested with positive Y velocity
There is no 100% accurate way to detect jump
Player can be pushed even in positive
In paperMC is accured?
Like it gets the packet?
My server is in papermc, but I should change the project in Paper.
other plugins can do it
well fine
as in other plugins can cause a positive Y velocity
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerStatisticIncrementEvent.html
Statistic.JUMP
declaration: package: org.bukkit.event.player, class: PlayerStatisticIncrementEvent
Yes, however not accurately timed enough to prevent a jump
doesn't it get called in the same tick?
I don't believe so
I thought the statistics were quite lazy
I'll check though as you have me wondering now
oh wait multiverse inventories exists right
"|||"?
i'm too lazy to learn how to do json stuff so I just parse it like this txt something|||foo|||bar idk|||stuff
Lol it works```java
@EventHandler
public void onJump(PlayerStatisticIncrementEvent event) {
if (event.getStatistic() == Statistic.JUMP) {
Bukkit.broadcastMessage("Jumped!");
event.getPlayer().setVelocity(event.getPlayer().getVelocity().setY(0));
}
}```
how do i make my first plugin?
Which is yoru favorite IDE?
ide?
program used to code
the eclipes
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@vast raven ^
i recommend you know java first tho, (very similiar to javascript)
lol
so i code in java? or what
yes
any links?
^^ and probably a youtube tutorial @bitter path
ok
anyways does anyone know whats a better way to fix this abstract database class and an abstract storage type? https://github.com/FourteenBrush/xKingdoms/tree/master/src/main/java/me/fourteendoggo/xkingdoms/storage/database
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
here are many links
ok thanks
ah yes
it's the same ofc
ikr exactly the same
java is to javascript as car is to carpet
i mean all the languages I know feel almost the same to me
yes i did all steps
no you didn;t
yes i did
Ok, its all working fine then?
Then you didn;t do all the steps
You downloaded Buildtools?
you ran this specific command?java -jar BuildTools.jar --rev 1.18.2 --remapped
You included specialsource plugin in your pom?
yes
you added a pom dependency with <classifier>remapped-mojang</classifier>
yes
?paste your pom
How can i share a variable between a command and an event listener?
whats the variable
depends on the context
use intellij idea
it's an hashmap
line 82
ok
if its common between the two have some sort of manager class
what's the difference between intellij idea community and intellij idea btw im literally so confused
the community edition is free but if u have github pro then u have the ultimate
license
bruh still not working
yeah basically a command puts some values into the hashmap and then the event listener needs to access it whenever
community just gets less stuff, like profiler etc
oh lmao, they felt exactly the same tbh
oh, nothing its just the version like it have an ultimate edition and a community edition the com. is. free the ult. is not
basically SQL stuff
the ultimate have database and more configurable
yeah most things you dont really use unless you are doing massive projects anyway
I have the ultimate version and it's really not different at all unless you do database stuff
i was thinking about something this night :/ might it be a good idea to implement the /reload command of my plugin my implementing Reloadable interfaces for all the components that needs to be reloaded and register all those components in the main class or smth and on reload just do reloadableStuff.forEach(Reloadable::reload)?
I do db things so i needed the ultimate for the comfort
Wierd, discord won;t let me respond to a message
I tried to reply to you and discord blocks it
test
Clyde: Your message could not be delivered. This is usually because you don't share a server with the recipient or the recipient is only accepting direct messages from friends. You can see the full list of reasons here: https://support.discord.com/hc/en-gb/articles/360060145013```
lol
it happend to me a few days ago
XD
test
try replying to biscuit1307
works for me lol
Asd
ok, thats super wierd
chicken nugget
chicken wings > chicken nuggets
someone ban this mofo
@drowsy helm can't i just declare the hashmap as public static?
😳
if it works it works 👍
Everyone will bitch at you if you do
any solutions?
did you fix that error in your pom?
yes
run mvn clean package -U
where to run? in terminal? sorry if i sound stupid im kinda new
are you using intellij?
ofc
in my pom I add the spigot version as a property so its only one line to edit.<project.spigotVersion>1.19-R0.1-SNAPSHOT</project.spigotVersion>
im not a loser
who said that? 😆
maven tab click the M
I don;t use IJ but in teh Maven tab there shoudl be a code execution section
How did u screenshot on mac pls
cmd+shift+3, 4 or 5
still getting the error
cmd+shift+3 is the whole screen I think, cmd+shift+4 lets you choose, cmd+shift+5 is for recording or sth
I usually do cmd+shift+4
did your buildtools run finish without errors?
?paste your pom.xml
Yeah, im on a vacation so i brought my macbook and its still new for me sorry 😆
np lol
WTF
XD
oh
are you 100% sure that you ran java -jar BuildTools.jar --rev 1.19 --remapped ?
yes
go to C:\Users\Yourname\.m2
Bruh
then check if spigot remapped is actually there
whats this? just a jump event with a bc msg?
Is that all?
i wish that i could know hebrew language
is this a proper reload method for a fileconfig?
i could show yhe whole thing if youd like
It was a test to see if statistics could be used to detect/prevent jumps
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class YamlStorage {
private static final Logger LOGGER = LogManager.getLogger("PrivateMessages");
private static File file;
private static FileConfiguration customFile;
public static void setup() {
file = new File(Bukkit.getServer().getPluginManager().getPlugin("PrivateMessages").getDataFolder(), "config.yml");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
customFile = YamlConfiguration.loadConfiguration(file);
}
public static FileConfiguration get() {
return customFile;
}
public static void save() {
try {
customFile.save(file);
} catch (IOException e) {
LOGGER.info("ERROR");
e.printStackTrace();
}
}
public static void reload() {
customFile = YamlConfiguration.loadConfiguration(file);
}
}
Don't trust that too much
that looks like teh lastUpdated file, not teh jar
i smell static abuuse
The code for the jump statistic isn't the best
so what should i do?
ok
haha
brb
that hebrew confuse me so much
sorry
oh no its okay :d
I always do custom configs like this
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/data/Config.java
its just "desk top"
😂
oh ye extending yamlconfig makes you dont have to delegate all the get methods?
yep
I just call load in the constructor
so it's just new Config("custom.yml")
it also reads the default included custom.yml file
smh
breaks my stuff most of the time
xd
The one thing I've always hated about multi dev projects
well but thats not so good for configs, etc 😄
havent tested
imma do my reload impl like this
if your save, reload, and load method isnt named reload
You have definitely come a long way since last year.
hehe thanks 
i took a few month break and mans is cranking 90s in intellij
always appreciate it
Can anyone tell me whats wrong with my code?
how does the plugin work?
#1001384149246038048 is the best thread no cap
well there is none yet
I need to generate a world extremely quickly (No terrain generation, just the world but it's completely blank), and it's taking so long I am getting server timeout errors (Server hasn't responded in 15 seconds), how can I just make it generate the very basics for a world?
is it ok for you if i just use that in the future ? xD makes many things much easier
I fucking hate floating points
sure
the whole lib is in a maven repo and also has some NMS stuff, but also works without enabling NMS things
i wish java had db api as easy as php does
imma change my config class to extends yamlconfig
yeah
that looks like i move i would make
i copy pasted exactly what you wrote into my ide without changing anything or understanding the code and it doesnt work :(((
oh nooo
run buildtools
--rev 1.4.6
How do i import vault to my plugin?
are you using maven?
yes
its on that readme
k
oh yes, sorry, my bad
you should rather use that illegal website and download an outdated version there
Gotta make one of those that's just a jar filled with fluff and when run starts sending the bee movie script
then the users server gets termianted because the host only allows mc servers to run on theyre containers 
Oh true. I should add a Bitcoin miner
Yay! Finally got it working. on paper it uses paper's jump event, on spigot it uses weird math
just check async
smh
new Thread()
god
in all seriousness though
why tf is there no PlayerJumpEvent??
just restart the server if they try and jump
there is only in paper
ez
yeh, i feel like spigot should have that tho
btw it triggers me how you keep using theyre instead of their and "should of" instead of "should have" lmao. okay actually i dont care, I just find it amazing that native english speakers have more problems with this than people who learnt it as second language 😄
yeah sorry I also don't care, I just wanted to point out that native speakers have more problems with this 😄
Mostly because most native speakers learned by actually talking since the age of 12ish months
While most non-natives learned it in a classroom for many years
yeah that makes sense
so its more engrained to properly use it all the time
when I was young, I couldnt pronounce the "sch" sound... erm... let me try to find an english word that contains it
shrek
I couldnt pronounce it and pronouned it as "sadow"
it was horrible lol
I went to some "language doctor" and all we did was playing board games and then some day I could properly talk, lmao
no idea how she did that
what ?? shadow is much better then the "th" in mother or smth xD
yeah well that was way before I learnt english
with TH i never had probblems
i still hate it xD
many german people just use an "s" or "z" sound instead of th
btw... isnt there a method like Location#getChunk ?
oh i hate this
declaration: package: org.bukkit, class: Location
nah i was thinking of it because mfnalex used something way more complex to find out if the chunk is loaded
Hey, how on earth do people make a system what loads external addons for plugins? 🤔
Chuink#isLoaded
fwoo
sec
like BentoBox right
How do i make a custom baltop?
wait
your the guy who dmd me
on spigot ahaha
about this
hiya. i want to add an enchantment to an itemstack. however, i need to make it so that the player cannot add protection (or other unsafe enchants) onto a sword BUT can apply unsafe LEVELS of safe enchantments (like sharpness 7) onto a sword
your him right?
more than likely yes 🥲
any idea how i can do that?
in case anyone cares, here's the complete cancellable jumpevent https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/events/PlayerJumpEvent.java
mhm, that's me aha!
i responded to you a while back
not sure if you saw it
someone I talk to knows how to do it but his big ego can't be hurt enough to explain how
i explained it in there
with links to my code that does it
Its a little complicated bc it uses a fuck ton of reflection
oh wait. i think ill use itemmeta for it
ahh, my bad
but, overally its halfway simple
harest part is opening up the jars and getting files you need
how you getting on with the lib by the way
am I?
but CLoudliteCoreLoader has it all
Where?
why not use the stat event and just tp the player down
i dont think ill add the jar loader to the lib sadly
its hard to abstract it
because I'd rather cancel the original event instead of TPing them again
seems like a weird wrapper but ok 👍
maybe I'll add another event. CancellableJumpEvent, for the current stuff, andd a normal JumpEvent that just listens to the statistic thing
You seems to have forgotten about Attributes.
oh shoot i see you made the coreloader thing
dont tell me there's a jump attribute too D:
I believe so...sec
LocationUtils ... dont know if this is a reasonable process to find out stuff like that
uuugh
ive had that code for years now haha
i have a few different forks of it
but that one has all the needed stuff
how would you do it? it just calls World#isChunkLoaded ?
and you can make it more advanced like a gui that lists all your addons
i feel dumb not knowing how to do these simple things 😦
you could honestly just fork CloudliteCoreLoader and change code you need
its no way simple dw
the ChunkCoordiantes is useless i guess ... you can just use getChunk
no. if you get the chunk, you load it
most of the code is actually copy paste from stack overflow
For the jar reading
I mean, I've only just got into java coding like full on not long ago if that makes sense?
ah ok
I learnt this the hard way lol
getChunk#isChunkLoaded == true
This is likely something i couldnt do again if i had to rewrite from scratch if im being honest
and ive been at this for years
I never really learnt "java" but I went head on and got my ass in gear and learn how to do it fully
as said - getChunk WILL load the chunk
Seems only horse jump, but player speed may affect teh jump velocity
I'll try it out
This class is most of the complex stuff
I hope this doesn't come out wrong, but this makes me feel a lot better
but anyway, almost noone uses plain spigot - so even if it works only half-assed, that's better than nothing 😄
codes outdated so it likely could of been done better
yep
if anyone in here knew how to do all that off the top of theyre head without help or code referances ide be deadass surprised
Took me a few days to get the system working the first time
there's so many things that I wish had more examples
nope.. i can still add protection 4 to swords. anyone know how this can be fixed? i am taking stored enchantments from enchanted books and slapping them onto the mainhand item. as i said before, i want to make it so that unsafe levels can be applied but unsafe enchantments can't.
I would advise not slapping enchants on, maybe try placing them?
lol
enchants have feelings too 😔
you can only have both or no unsafes iirc
oh i also need to prevent this from happening
youll have to handle that yourself i think
hmm ok no biggie. ill just tell the players
there might be some method somewhere that can check this
but it might be hidden in NMS
making your own would be too hard, just have a set list of enchants you want to allow on tools/armor
NMS got so simple recently
1.17+ right?
Once we have full Mojang mappings it will be really nice
I think what's hardest is there's no tutorials on how to do it
currently its a mix of Mojang and spigot
maven uh oh
?spigotremappings
er
why not?
seeing this worries me lol
light mode warning
Mojang Remappings are named nicer and more is remapped iirc
No clue, I use darkreader plugin
what's that
gn 2pm sleeper
just google "jeff media blog" or "jeff media blog mojang mappings"
public static class SpigotListener implements Listener {
@EventHandler
public void onJump(PlayerStatisticIncrementEvent statsEvent) {
if(statsEvent.getStatistic() != Statistic.JUMP) return;
Player player = statsEvent.getPlayer();
Location from = player.getLocation();
Location to = player.getLocation().add(player.getVelocity().add(new Vector(0, 0.42, 0)));
PlayerJumpEvent ownEvent = new PlayerJumpEvent(statsEvent.getPlayer(), from, to);
Bukkit.getPluginManager().callEvent(ownEvent);
if(ownEvent.isCancelled()) {
statsEvent.setCancelled(true);
player.teleport(from);
}
}
I fear that when doing it like this, the "to" location isn't accurate
perhaps i can add the level AFTERWARDS if the enchantment has been added properly using "addenchantment" (safe)
i find the “to” location a bit misleading but i’m not sure
I'd likely just zero out teh Y so as to not stop a player moving forwards
tho i have no idea how i can check if inHand.addEnchantment(itemEnchantments, levels); ended up working or not
#ItemStack.hasEnchantment(foo)?
hmm yeah
could also retrieve the level
is this to correct? surely you should just be setting the velocity? i can’t remember what it returns
why? it's the same as in PlayerMoveEvent
yeah :/
but I dont care because when cancelling paper's jump event, the velocity is also reset
I'm trying to have some persistant data be stored onto an itemstack without using the lore, is there an easy way to achieve that or do i have to consistently track every itemstack i wanna attach data to?
you can just use the ItemMeta's PersistentDataContainer
wait
that's basically just a hashmap
@tender shard i love you thank you very much
wdym
i had a try catch so it would tell the player that the enchantment isnt compatible. if a level ends up being too high, it will end up sending the exception message instead of setting the levels and enchantments.
np lol
here it is. https://bin.birdflop.com/dawerizuxu.typescript i am aware that its not good code but rn i just need it to work lol
the bruhs were just for debug
its just a data storage for objects under string keys, like a hashmap
i had no idea this was a thing
yep, that's true
You can even abuse it to store stuff like lists, maps, collections etc
https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/ @rare flicker
yeah it was added in 1.14.1 but somehow, most people didnt notice
I also only learnt about it in 1.16 IIRC
soo.. any idea to make the exception catcher only run AFTER the if statement?
I think PDC was quite an odd design pattern back then, It was difficult for some to get their heads around, me included
well it works exactly like a Map<NamespacedKey,T>
Yep, but Spigot/MC and NamespacedKeys was fairly new too
I was so happy when I discovered that it existedd
everyone thank @eternal night for this awesome thing
well in the end, a namespacedkey is just pluginname + key name 😄
any1?
i dont really understand the question
line 7 can throw an NPE if your hand is empty
you could do stuff like
boolean failed = false;
// ...
try {
// something
} catch (Exception e) {
failed = true;
}
// ...
if(failed) {
// Do stuff when it failed
}
if thats your question
finally block
yeah im aware
hmm ok
@tender shard is there an option to disable the automatic code suggestions and trigger them by pressing a specific key? -> github copilot
no idea, sorry
seems possible
there's a shortcut to "show completions" and there's a setting to hide them in the editor
press shift twice, enter copilot, and then you see all options regarding that that are available
i never want to code without it again
i mean it somehow even completed my todo messages
yeah it's scary how accurate it sometimes is
I tried tabnine and code4me too but they only suggested shit all the time
copilot is so much superior
well copilot has the advantage of 10000000 repos
but im not sure how its so fast
with different solutions which all makes sense
even codebased things
probably not. but I dont really care why copilot is better, I am just happy that it is, lol
like on the huge project at my work
but sometimes i get the same suggestion 4 times and can never press tab because otherwise it autocompletes it
thats not how it works
or if there already is code it still suggest something
and idk why you are still shitting on code4me for a task it is not supposed to do
we were talking about copilot and I said that I tried other AI completions and that copilot is better. That's not "shitting on" anything, it's merely describing my true experiences
I am just happy that it is, lol
i call this shitting on
fyi copilot is 100x bigger than what code4me uses
when I say "I am happy that Copilot works flawlessly", that's considered shitting on code4me?
trained on a billion more repos too
And that's why it's better
no but i just searched back and you're shitting on a project of mine without any knowledge of the research or what it is about
why do you take everything personally lol
Copilot is just better and I don't regret saying that
I don't care why it is better, I just wanna use a tool that works fine
you made it personal after using the research out of context and not for the original purpose
then proceeding to shit on it left and right
sorry but I don't really understand this sentence
for every mention of copilot you have to include code4me, just dont
what is the original purpose of it? I thought it was to get AI code completions
that is not true
AI code completions for the python language, with in mind that it only has access to your current opened document
you were (1) expecting it to work for the bukkit api and (2) in the java language
yeah, that's what people expect from "AI" - that it learns to use other APIs too
although sometimes it suggests some shit, i’m like “damm that would have been better api design”
and copilot does it differently, that's why it's better. Can we stop talking about this now, please?
it is not comparable to copilot, because it is not meant to be a replacement for it, it is an evaluation study with the aforementioned points in mind
Sounds like a #general discussion
no
Yes
copilot is much better than other code suggestor like code4me
its not
until there is a question we can talk about what we want
also if you claim "its only meant for python", maybe you should mention that on the website, ebcause the word "python" doesn't appear there at all, so how is one supposed to know that?
There arent any questions here as far as I can read
how is a conversation about a coding tool a general discussion
Yes, but this channel is intended for questions mostly
lets just move to general, I mean who cares
doesnt hurt anyone if we go to #general
Well you guys are just debating back and forth now
aha! apparently this thingy doesnt check if the enchantment level is too high
hence it’s unsafe
only levels, not enchantment ids.
quick q if I have a version in plugin.yml is there any point in also having a version in build.gradle if I am not generating the plugin with build numbers?
hi
why doesn't that work?
Bukkit.getBanList(BanList.Type.NAME).addBan(p.getName(), ChatColor.GOLD + "...", new Date(System.currentTimeMillis()+ 60L*60*9999999), "...");
ohhhhh, thanks
doesn't gradle require you to specify a version?
not 100% sure
I just don't want to keep updating both plugin.yml and gradle at the same time, is there a way to get one to read the other?
Map<Enchantment, Integer> enchants = meta.getStoredEnchants();
for (Enchantment itemEnchantments : enchants.keySet()) {
int levels = meta.getStoredEnchantLevel(itemEnchantments);
enchants.get(1);
Would enchants.get(1); get the first/second enchantment name or no?
^
you can convert the map to a Set using Map#entrySet() and then wrap using new ArrayList(entrySet), then do enchList.get(0) to get the first enchantment
because im pretty sure that minecraft stores the enchantments in order



