#help-development
1 messages ยท Page 2050 of 1
1.7 :kekw:
what should i test exactly?
If it works the cuboid class
ur wasting resources
Im still thinking if the Cuboid#contains() will work
mhm
How can i check if any location its inside a cuboid?
Even a better reason to listen to what I said
and sometimes slow af while coding and minecraft at the same time
Well
check the xyz of each point
and check if its inside them
e.g 100, 100, 100 & 10, 10, 10
20, 20, 20 would be inside that
well i dont see why this wouldnt work
thats some very weird constructor
i would do two args
Location, Location
or 6 doubles
I cannot pass 2 locations, because i will work with 1 location
return ((biggerPoint.getX() > containArg.getX() && biggerPoint.getY() > containArg.getY() && biggerPoint.getZ() > containArg.getZ()) && (smallerPoint.getX() > containArg.getX() && smallerPoint.getY() > containArg.getY() && smallerPoint.getZ() > containArg.getZ()) ```
__biggerPoint__ should be the point that has each of its (x, y, z) coordinates maxed with the other point coordiantes, with Math#max.
e.g:
```java
Location firstLoc = new Location(world, x, y, z);
Location secondLoc = new Location(world, a, b, c);
So:
Location biggerPoint = new Location(Math.max(x, a), Math.max(y, b), Math.max(z, c));
Location smallerPoint = new Location(Math.max(x, a), Math.max(y, b), Math.max(z, c));
I have to based on protection block location, calculate the 2 corners
return should be like that
Hex?
I explain, my idea is to work with 1 location (protection block), and based on that location get 2 corners (a = negative, b = postiive)
And them i dont know how to check if the location im pasing its inside the 2 corners
o
eitherway i showed u
how to check if a block is inside 2 locations
another example
Woudnt the return with all that math cause lag problem?
Because i dont the radiuos of protection and the amount of them
unless you're running a pentium 4
it will do fine
well computers are way faster than you think
Allright
if you're doing those checks
then java's compiler will understand that and make more optimized assembly code
so don't worry about min and max checking
how can i give player dyed leather armour cuz its not on the item list
You can run billions of checks every second
Hex your paste link its down
It's part of the meta
ohh
What are you trying to do?
.
ohh
Location: x=230, y=71, z=258
Radius: 5
Corner 1: x=225, y=66, z=253
Corner 2: x=235. y=235, z=263
Do you think they are correct?
Im trying to calculate 2 corners based from 1 location
I dont think the corners are correct
Ah sorry i forget stm
in the info
Already updated, i forget the radius
Because im calculating 2 corners from a block and a radius
Im trying to apply the plugin protection (but using a block) logic
@sterile tokeni mean
a cuboid usually have 2 locations
so i would make it so
then you calculatet your 2 locations yourself
which is ur own logic
or make a RadiusCuboid class
What number?
that implements Cuboid
Hello everyone making a ChestGUI class
and
And this is my class:
public class Cuboid {
private final Location a;
private final Location b;
public Cuboid(Location location, Integer radius) {
this.a = new Location(location.getWorld(), location.getX() - radius, location.getY() - radius, location.getZ() - radius);
this.b = new Location(location.getWorld(), location.getX() + radius, location.getY() + radius, location.getZ() + radius);
}
public Location getLocationA() { return this.a; }
public Location getLocationB() { return this.b; }
}
Can anyone help with Consumer<InventoryClickEvent>?
I have a sample
Do you wait it?
how can i open gui with bungeecord plugin ?
i mean that seems like bad design imo
Its done from Spigot side
Allright i dont so god
Send me please
Allright give 1 sec
public void setItem(int x, int y, ItemStack item, Consumer<InventoryClickEvent> event) {
if (allowed) {
if (x < 1 || x > 9 || y < 1 || y > row) {
throw new IllegalArgumentException("The location of the item is entered incorrectly");
} else {
inventory.setItem(9 * (x - 1) + (y - 1), item);
this.event = event;
}
}
}
Hex i never worked with Cuboid before that why im so noob
I will send my complete menu library so its easy for you
private Consumer<InventoryClickEvent> event;
I will when the player sends bungee cmd Open the GUI
the interface should be:
Cuboid<T>
T getFirstPoint();
T getSecondPoint();
where the class should implement
Cuboid<Location>
Okay, thanks
and n the RadiusCuboid class
u should calculate radius and stuff
since not every cuboid works like that
I've already looked through the libraries, and it's hard for me to understand it
in fact most of the times it works with providing 2 corners
not one corner that you get the one from
So how i would do it?
Im so confused and looking so freaking noob
well what i told u was design tips
So can u make a sample
Hello.
Anybody got any idea on how to prevent big dripleaf from tilting?
i told u what to do
unpopular opinion: you cannot
dont we have boundingbox or sth
kek
how do i define defaults in the configuration here?
config.getInt("my.int", 3)
I am not able to get to use dyed lether armour as it is not in list
i meant the other part
'if a default has been identified in the root Configuration'
i know what parameters are
the issue i have is that there's a path that essentially is *.visual.*.int where * can be any kind of string
basically
for every declared name there's a field visual under which there's a list of effects
the name of the effect doesnt matter since the loop is for(String s : ConfigurationSection.getKeys(false))
but i do wish to define default values to reduce the size of the config
in need of library ideas
non resource intensive player jump detector
translatable messages with separate language files BUT it should also be able to update existing lang files when new messages get added
I'd definitely use it
seriously why the fuck is there no onJump event
it's so easy to detect
PlayerMoveEvent
nah
way easier
PlayerIncrementScoreEvent
check if score == Score.JUMP
or whatever
wow that's genius
yea
but if you wanna use cough paper cough this exists https://papermc.io/javadocs/paper/1.13/com/destroystokyo/paper/event/player/PlayerJumpEvent.html
not my idea, found it in the forums some time ago ๐
reason i use spigot/bukkit is so my stuff runs on everything
yes that's good
although paper API has so much useful stuff, I wouldn't use it myself until absolutely needed
Yeah making a non insane language library would be cool
Especially if items worked in it
yes we need a proper language file lib
my configs currently look like this
whoops same screenshot twice, sry
Is the principle of Enchantments#getByKey the same as Material#valueOf?
query
so yeah the translations are 900 lines out of a 1800 line config file
why not use english only
so basically a lang.yml automator
yeah but as said, imagine this:
i have an enum for all my language things
en.yml:
message1: Some text
message2: Some other text
german.yml:
so the path in the config and a default value
message1: Irgendein Text
Ic
note that message 2 was not translated yet, so it has to use the default of en.yml
but now imagine a third message gets added
it automatically would have to add the new translation to all existing files, keeping the changes that were already done
that doesnt seem too complicated
it would however also have to add untranslated messages as comment
so people know what messages aren't translated yet in each lang file
yeah it's not complicated at all, just a bit tedious
how do you think the usage should be like
and people would then just do
LangLib.getMessage("message1")
or maybe even provide a player and use that player's client language but I personally wouldn't need that
yeah more like this:
LangLib.getMessage("message1",player);
if player uses English, get english.yml
if they are german, use german.yml
that actually sounds super easy
Launching IntelliJ
How can I get the real names of the methods?
You could go a step further and make it so that custom items could have translations
nah thats logic for the user to do
use remapped spigot
I provide the essentials with a library, the user has to implement logic
yeah as said, imagine you have an existing file
message1: "Message 1"
and in german:
message1: "Nachricht 1"
Now you update your plugin and it also has a message2. obviously you don'T know german so the default german file can'T get updated. it should howeer now look like this automatically:
message1: "Nachricht 1"
### The following messages weren't translated yet. Translate them them uncomment them yourself pls
#message2: "Message 2"
How?
i think theres a spigot post about that
Thanks
(it's for maven only)
good enough
imagine not using maven
gradle
sure, but it also has to add the "default" message to the existing translated files
Hex, someone told me this yesterday:
Vector bp = protection lbock location
Integer radious = 10;
Cuboid cuboid = new Cuboid(
new Vector(bp.x - r, bp.y - r, bp.z - r),
new Vector(bp.x + r, bp.y + r, bp.z + r)
);```
Maven: easy to use, can do almost anything
Gradle: harder to use, can do almost anything + a tiny bit more but most people don't need that "tiny bit more"
maths aah
yea that generates a cube length 20 with the point in the middle being bp
if you translate that into blocks it's 21 blocks tho
thanks to how coordinates work
So that would be a cube of 21 block inside?
and now imagine that your "message2" translation in german gets added in a next update. you want to add to the existing lang file that already has the "default" translation inside
you count coords from block corners
so yeah it's not as easy as it sounds
So using that class method i can create a plugin protection based on a block?
what's the best way to do damage knockback reductions?
just multiply velocity one tick later?
alright then ill make it look like this:
LangLib lang = LangLib.create(this);
lang.createLang(Language.ENGLISH, Level.DEFAULT_LANG);
lang.createLang(Language.GERMAN);
// or lang.createLang(Language.GERMAN, Level.SECONDARY);
lang.addMessage(Language.ENGLISH, "name", "Jack");
lang.getMessage(Language.GERMAN, "name"); // returns Jack
lang.addMessage(Language.FRENCH, Language.GERMAN, "name", "Duke");
lang.getMessage(Language.GERMAN, "name"); // returns Duke
noo noo noo
it should do all of that automatically
Yeah, my idea is the next: You place a custom item and them in radius of x blocks you cannot be able to break, place, etc
it should only require resources/lang/de.yml etc files
de?
de = german
it should not require anything besides TransLib.init() or TransLib.load() and of course TransLib.getMessage("...")
oh yea
yes de = german
o
but how am i supposed to know the language
Simple: you don't
or similar
Player#getLocale?
yeah so it just creates files
.?
and updates existing files
The specification behind the locale strings is really bad imo
with the default english message, if no translation is provided, or with the new translation if one is provided
I'd rather use the ISO3 strings instead of the ISO2 ones
?paste
bruh so it just copies the default lang into the language u specify, then u havee to manually write them
anyone here good at math and particles wanna help me
yes no yes
*yes no maybe
https://paste.md-5.net/xigehuhovi.shell
Imagine I now decide to add a new message "message-something". obviously I can add that message to the english config but I don't know azerbaijan turkish, so azerbaijan file should automatically get the default english message added. But when now I have someone contributed a translation in azerbaijan for "message-something" it should automatically replace the default message with the new translated one
and I'm not trying to learn math lmao
uh
??
how are particles supposed to rotate entities
I dont even know what "damage knockback reductions" means
i mean you can project an image and rotate that and copy the rotation onto an entity
but that's about the onyl idea i have
changing the knockback caused by a player being damaged, sorry
@sterile token why do you need the center of the claim?
hm sorry I have no idea
i can do math but my math never works -.-
lmao
like i put the 0 in the wrong place
anyone else got an idea?
effect duration stayed the same
but i only got blinking particles appearing for a few frames
weren't you the person who said you liked my voice? if so, I am happy to announce that I was booked to record an audio book for "fan man" by william kotzwinkle lol
bruh mans got a job
lmao
I have like 30 jobs but none of those is a proper one lol
ah that makes more sense
do u know math
sure, but
1+1 yes
my school was 10 years ago
get the derivative from x^-x
xD
no
I studied law which is basically "math in language"
breh
there's a ton of forums posts about this
a whole library just for you to copy paste a file to another
does it look like I want to learn math?
if you don't wanna do it, i'll do it myself
i feel like im misunderstanding it
you basically need to know how sin/cosinus works, then get a scheduled timer and done
like tf is a unit circle
Is it really just a copy paster from a file to another until u can change it urself?
Hey !
I'm thinking about it since I need something like it for the server I'm working on.
Ok I did that, but now things like the WorldServer are missing
well wanna teach me lol
I never copy paste code. it's either in a library available in a public repo, or I'll do it myself
thats not what i mean
I can't, sin/cos is where my math knowledge has ended lmao
a copy paste from file (.yml) to another (.yml)
I know how it works but I can't explain how to do it
idk how it works lmao
as said, it's 10 years ago that I had to do it lol
Does a Set do anything to it's values once one is added?
Instead of adding the english line to the azerbaijan language file, why not just make the plugin fallback to english if no translation is available?
no
well
yes
what Set?
HashSet for example calls every object's hashCode() method when you add a new object
I'm storing a data struct (yes, in kotlin) with 2 props, data and item
Where item is an ItemStack
what Set are you using? HashSet?
BTW MFN
MutableSet
does your custom class ("struct", or whatever) override hashCode()?
if i make an object and override its hashCode method
nope
with some really intensive spammy code
then it will not do anything to existing objects
Can I send some screenshots of the values I logged?
if your stuff doesn't override hashCode, the set will basically just do this:
for(Struct struct : yourSet) {
if(struct == myNewObject) {
return;
}
}
add(myNewObject)
why
why did you show only 7% of the stacktrace?
final boolean headshot = entity instanceof LivingEntity && isHeadshot(intercept.pos, (LivingEntity) entity);
discord down?
you cannot cast an NMS entity to a bukkit one
hi uh is there example plugins with comments so that i can reverse engineer it to know how and why it worked?
no, discord high as fuck
is there a forum I can ctrl c ctrl v from?
Yes but why
wait
oh wait i might have found the cause
i want it as an example
https://github.com/JEFF-Media-GbR/ChestSort just check out open source plugins?
are enchantments and item meta related?
yes
thanks
ItemMeta.getEnchantments() or whatever
so if i set the meta after adding an enchant, it will override the enchants, correct?
just skip every N'ths frame
Hello, i was asking, do you know how you can add a data in a block the first time he is broken, if it's the first time, you have something and if it's replaced then rebroken it do nothing (sorry for my bad english)
what kind of data?
or interpolate if you don't want to speed it by 2x,4x, etc
just yes or no for exemple
I don't really understand
add data to a block that gets broken? that makes no sense, why would you add data to something that will be removed anyway
imagine you are in a cave and you break a iron ore
yes, explain it with examples pls ๐
I have done this before, once a block gets broken, add a tag to it in it's persistent data container, and once it's placed, check if that tag exists on the pdc and set specific block data tag so it can detect if it has been broken before
yep
?pdc
Blocks do not have any PDC though. I wrote a library to allow it though: https://github.com/JEFF-Media-GbR/CustomBlockData
that looks weird lol :c
what
the guns
I don't 100% remember how i did it, but i'll check
ok
tbh this looks like the first cracked version of Counterstrike I ever used when I was like 10 years old
purple textures, "missing texture" texture, etc lmao
but yeah this looks awesome
I set it on the block metadata
i making the backend system first
don't ever use that
the block's metadata will reset on server restart
it is NOT persistent
o h
if you want to store information in a block that's consistent, use my lib: https://github.com/JEFF-Media-GbR/CustomBlockData
yeah well
if you wanna speed it up by exactly 50%, then yes
if you wanna go for 33%, you'll have to interpolate
Which event should i use to check if player is wearing a specific armor?
I have a library for "players equipping new armor"
to just check the armor they already wear, obviously there is no event for that
events are called when things are CHANGING
they are not called to check a non-changing thing
I will make a if condition for that
Asking about your attempted solution rather than your actual problem
not every block has a pdc only the one with a tilestate right?
exactly
that's why I made my CustomBlockData lib
I am saying that I will create a if condition to check player for a specific armour but for that i need to use a event and so i am asking which event should i use
and your "if condition" does what exactly?
does that allow blocks to have its own pdc or what?
yes
are you saving the data on the chunk instead? ๐
yes
aha
I have created a custom armor so my if condition will check for that armour
thats what i did in my protection plugin
you give way too less information about what you are trying to achieve, so I'll stop wasting my time on this. I have asked like 3 times what you actually wanna do and you never really answered to that. good luck though, maybe someone else can help you
there is basically two approahces to "speed up" videos. Imagine ABC etc are frames.
Normal video:
ABCDEFG
Sped up 50%:
ACDF
Sped up 33% though, it gets tough. You can either do this;
ABDFG (which will look weird)
or do this:
A [mixture of B/C] D [mixture of E/F] G
I have created a custom armor which has certain enchants and when player wear it how can i give that player some effects like slowness and remove that effect so can anyone give me suggetion related to it ?
ah, now I get it
use the ArmorEquipEvent ( https://github.com/JEFF-Media-GbR/ArmorEquipEvent ). when a player equips the armor, apply them an "unulimted" potion effect (duration = Integer.MAX_VALUE, that's about 4 years so more than enough) and when they unequip it ( same event will be called ), remove the potion effect again
yes, you either have to add it as dependency and shade it ( it's expalined in the README file) or copy/paste all the code
ok thx
np
sorry for irritating you
good luck, ping me if you got questions ๐
no problem at all, I just wanted to be sure what you actually wanna do because otherwise noone can really help ๐
sure tysm for helping
actually the first one is sped up by
43%
not without dirty hacks
why would you want to do it?
pls explain why you need to load the same world more than once
you could clone it
<groupId>com.jeff_media</groupId>
<artifactId>ArmorEquipEvent</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>```
when I pasted this part of code it throws error for some reason in pom.xml
did you also add the repository?
repository?
my server crashes i dont understand error codes
yah
show the full error message pls
minigame plugin, have a map, when a game is created the plugin would make an instance of the map, put the players there, the minigame would happen, then the plugin would just simply delete the instance
?paste
ok
that
sorry I can't help with that
I mean
of course you can just copy the world folder
but that seems like a dirty hack
for what? just track the changes and revert them after the game
maybe they want to allow two consecutive games
Dependency 'com.jeff_media:ArmorEquipEvent:1.0.0' not found , Dependency 'com.jeff_media:ArmorEquipEvent:1.0.0' not found , Dependency 'com.jeff_media:ArmorEquipEvent:1.0.0' not found
like an arena mode?
I don't any better way than doing this:
- Copy "myminigameworld" folder to "myminigameworld1"
- Start the game in the new copied world
- if you want to start another game, copy "myminigameworld" to "myminigameworld2"
- etc etc
this is a dirty hack but I don't see a better way
or you have several arenas at one world
?paste your pom.xml pls
ok
and hide all of the other arenas and players if they are not necessary for the current fight
thats another alternative
but
how do i hide arenas lol
packets
i only know about hiding players
Hi I need help with rtp so when they do the command they don't land in water don't get it to work, tag me
this is my code
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.Random;
public class Rtpmere {
public static HashSet<Material> bad_blocks = new HashSet<>();
static {
bad_blocks.add(Material.LAVA);
bad_blocks.add(Material.WATER);
bad_blocks.add(Material.FIRE);
}
public static Location generateLocation(Player player){
Random random = new Random();
int x = 0;
int y = 0;
int z = 0;
int borderSize = (int) player.getWorld().getWorldBorder().getSize()/2;
int min = borderSize-borderSize*2;
x = random.nextInt(borderSize + 1 - min) + min;
y = 150;
z = random.nextInt(borderSize + 1 - min) + min;
Location randomLocation = new Location(player.getWorld(), x, y, z);
y = randomLocation.getWorld().getHighestBlockYAt(randomLocation);
randomLocation.setY(y);
while (isLocationSafe(randomLocation)){
randomLocation = generateLocation(player);
}
randomLocation.setX(randomLocation.getX()+ 0.5);
randomLocation.setY(randomLocation.getY()+ 1);
randomLocation.setZ(randomLocation.getZ()+ 0.5);
return randomLocation;
}
public static boolean isLocationSafe(Location location){
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
Block block = location.getWorld().getBlockAt(x, y, z);
Block below = location.getWorld().getBlockAt(x, y - 1, z);
Block above = location.getWorld().getBlockAt(x, y + 1, z);
return !(bad_blocks.contains(below.getType()) || (block.getType().isSolid() || (above.getType().isSolid())));
}
}
weird, that looks 100% correct to me
try to run this command pls:
mvn clean package -U
then its a good exercise
where?
if i use packets, can i just put all the players into the same arena but hide blocks/arrows/players/everything from other arenas to the player in a certain arena?
click the button I marked in red, then enter the mentione command
see screenshot above. first click on the thing I marked in red, then enter mvn clean package -U
sure you could, but idk if it would be good
there probably would happen some weird things
ok it executed
but still the error
i just checked org.bukkit.commands.default and /clone is not there, is there a function to clone regions within a world or do i have to maek myself
i can still complile my plugin
show the full error message again pls
.
pls dont write 'pls'
i am the one asking help
I am very sorry for trying to be friendly
as alternative: clone my github repo ( the one with the ArmorEquipEvent) in IntelliJ, then just do "maven install" on that one
now you'll have it
ok
bind f "use weapon_flashbang;"
can some of you help me at #help-server
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
they already did, my guess is they are using a totally outdated world data pack
did it help?
i am doing it currently
Because in the center it will be the protection block
when i tried cloning it says permission denied
and what is the protection block?
Its a beacon block
And i have to get the block corners by the location and a radius
i used git bash
git clone <repo url>
yah
you must be doing sth wrong, it's a public repository
ok i did it
send the url you are cloning
its late now but tommorrow i will make the plugin and report it to you
That why im doing it in that way
Hi I need help with rtp so when they do the command they don't land in water don't get it to work, tag me
this is my code
https://paste.md-5.net/raguleluva.java
?paste the code
thx
well
what ur doing will crash the serve
server
but slowly probably
its a never ending loop
EnumSet.of(Material.FIRE, Material.WATER, Material.LAVA);
or MutableSet.of(...)
or
Set<Material> disallowedTypes = new HashSet<>(Arrays.asList(Material.FIRE, Material.WATER, Material.LAVA));
or Sets.newHashSet(Material.FIRE, Material.WATER, Material.LAVA);
this needs guava but its included with spigot
i have somthing else that do that so don't wory
is something wrong here?
WorldCreator wc = new WorldCreator("ctest1");
wc.environment(World.Environment.NORMAL);
wc.type(WorldType.FLAT);
wc.generatorSettings("2;0;1;");
wc.createWorld();
error: https://pastecord.com/ogomaqagef.properties
from https://www.spigotmc.org/threads/create-a-new-world.384473/
im trying this now
WorldCreator wc = new WorldCreator("world name");
wc.environment(World.Environment.NORMAL);
wc.type(WorldType.NORMAL);
wc.createWorld()
and i think its working
So I've created this Custom Recipe, but it doesn't appear in the workbench. I tried for debugging see what the result would be, and it prints the correct result. Any idea why?
https://cdn.discordapp.com/attachments/741875863271899136/954387630940913704/unknown.png
yea normal world works, but the superflat one doesnt
anyone knows why?
what is you recipe?
Hiiii
hey there. on my server, invulnerable entities are getting damaged by explosions. how do i fix this?
header:
- "&c&lHandoria"
- "&7&l>> %animation:Welcome%&3 &l&9&l%player%&7&l! &7&l<<"
- "&a&lGracze Online: &r&a%online%"
- "&6&lAdministracja Online: &r&e%staffonline%"
how to make %online% with custom players?
what do you mean custom players
I want to increase the cost of an item for each level, like multiply the level by 2 and the level maxes out a 5. I could do a switch statement for each level but that's not the best way to do it, how would I do something like that?
List<Player> staffs = new ArrayList();
Bukkit.getOnlinePlayers().forEach(player -> {
if (!player.hasPermission("staff.perm")) return;
staffs.add(player) ;
});
why I get that error: Cannot resolve symbol 'Arena' in:
Prob arena doesnt exists?
It means you haven't created the class or you havent imported it
Oh thanks lmao, that was easier then i made it out to be
oh thx
What do you think? I have refactored my cuboid class:
public class CircleCuboid implements Cuboid<Vector> {
private final Vector first;
private final Vector second;
public CircleCuboid(Vector location, Integer radius) {
this.first = new Vector(location.getX() - radius, location.getY() - radius, location.getZ() - radius);
this.second = new Vector(location.getX() + radius, location.getY() + radius, location.getZ() + radius);
}
@Override
public Vector getFirstPoint() { return this.first; }
@Override
public Vector getSecondPoint() { return this.second;}
}
Because i need to calculate 2 corners from a block in the middle
Yeah
The area i get its lcoation
So it come with x, y z
?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.
I explain why, on place event i get the location.toVector() of the placed block. And them using a radius (how much blocks will protect around) i calculate the 2 corners
Prob will have to do a model on mc how it will looks so its better to understand
yeah this
Uh Um
you cant have a circlecuboid
i would name it
RadiusCuboid
Nah he just had some naming problems ig
btw just wanted to say
declaration: package: org.bukkit.event.player, class: PlayerLevelChangeEvent
is amazing
i wouldve suffered without it
u can use
declaration: package: org.bukkit.event.player, class: PlayerExpChangeEvent
to setAmount(0);
hey is it possible to make a player run a command/chat message, but bypassing needed permissions?
player#dispatchCommand() and player#chat() both work, but permission is needed
i could give them the permission and then remove it right after but idk
If i were you I would try to send the command through console command sender than use the player name as an arg if possible
if you have to run it as the player giving them the permission and revoking it will be your best option
well what type of command are you executing?
temp op is scarry lol idk how else I would do it though
the essentials one
user.getBase().chat("/" + command);
nvm thats their own user
i'd trace that back
dispatchCommand is a hacky workaround in most cases. Why not access the plugin the command is from?
wdym
What do you need dispatchCommand for?
i'm not using dispatchcommand currently, i just said it worked. I'm using player#chat()
it works for both command and messag
im making a sudo plugin
its just meant to bypass all permissions whne you sudo a player, but im not sure how to do so without temp-opping
meant to run the command as if the player WAS an operator (or had "*" permissions)
Ah i see. For safety i would use their PDC or ScoreboardTags to tag them and listen in the PlayerJoinEvent for this tag. Just in case.
but not actually make them an op
what is a situation where you would use sudo to have a player send a command they wouldn't have perms to?
sudo <player> gmc
or sudo <player> tp <location>
idk the normal stuff
bad examples, but
You could also use the player metadata api. It might actually be more preferable in this case since he wants a temp permission check.
just in general there are some times where the command doesnt have an optional player arg
that i can use
But if the server crashes then he wants persistent data.
I think you can dispatch commands through Bukkit but iirc it's really not recommended lol
Was that mentioned somewhere?
how?
Oh and actually would still require permissions, since it uses a specific sender
oof
If it was, I missed it, but based on the context of the command and what they have described. It wouldn't really be necessary to have it persistent since it will be removed right afterwards.
You better be careful with something like temp permissions though.
The PDC could work as well, it's just that the metadata api has that perk of not being persistent.
yeah
i dont know how i would find the permission for the exact command though, so it would have the be temp op
since permissions are not directly linked to commands
One sec
also apparently the 1.13 /execute as <player> run <command> bypasses permissions
the vanilla thing
Does getPluginCommand allow you to get any command?
not sure
If so, then you can check the permission via getPluginCommand(name).getPermission().
I would say this is 99.9% safe:
public static final String OP_TAG = "__OP__";
public void sudoChatOp(Player player, String message) {
boolean originalOpState = player.isOp();
try {
player.getScoreboardTags().add(OP_TAG);
player.saveData();
player.setOp(true);
player.chat(message);
} catch (Exception exception) {
exception.printStackTrace();
} finally {
player.setOp(originalOpState);
player.getScoreboardTags().remove(OP_TAG);
player.saveData();
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (player.getScoreboardTags().contains(OP_TAG)) {
player.setOp(false);
player.getScoreboardTags().remove(OP_TAG);
}
}
in event of exception I would remove op status too
hm thanks
i like spoonfeed lmao
finally will be called either way
That's what finally does
Honestly... not quite sure why finally exists sometimes.
i always forget about it
I usually just close streams with it
which I'm pretty sure is why it exists
Closing resources with exceptions being thrown in the catch block i guess.
Ah, okay so it just makes sure code is always called even in the event of exception. I honestly didn't know that bit.
It exists to execute any additional code after your try statement completes. It's usually used for closing resources.
Well it's used for closing resources pre-try-with-resources
Which was uh... Java 7, iirc
could i use pdc or metadata/nbt instead?
of scoreboard tags
Yes
pdc -> yes
metadata -> no
o ok whats wrong with metadata
not persistent
and?
Referring to the source language here. When compiled, it's still effectively a finally block.
What would it matter if it's not persistent?
Heya, I'm trying to understand how to add MySQL usage to my plugin. I'm using Gradle and this is my build.gradle:
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'java'
}
group 'xyz.gekoplugin'
version '1.0.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
// maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://papermc.io/repo/repository/maven-public/' }
}
dependencies {
implementation 'com.zaxxer:HikariCP:5.0.1'
implementation 'mysql:mysql-connector-java:8.0.28'
compileOnly 'io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT'
compileOnly 'net.luckperms:api:5.4'
}
shadowJar {
project.configurations.implementation.canBeResolved = true
configurations = [project.configurations.implementation]
shadowJar.minimize()
}
There aren't many resources out there utilizing Gradle, couldn't figure it out. When I run shadowJar task and use the created .jar I'm getting java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource exception.
but whats wrong with not persistant
It's a temporary permission check anyways.
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (player.getScoreboardTags().contains(OP_TAG)) {
player.setOp(false);
player.getScoreboardTags().remove(OP_TAG);
}
}
You're missing the point.
I don't believe you need to import the MySQL connector in Spigot, unless you're using an older version of Spigot which imports an outdated connector.
You don't even need to use setOp() when you can just do an alternative check to the standard permission check.
Using latest papermc, if there's any difference
is paper packaged with mysql?
Well Paper's built off Spigot so they probably retain the connector
Unless they don't
spigot and paper already have the mysql driver included. No need to shadow it.
The driver I'm trying to load is the following: dataSource.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); (dataSource being Hikari)
Paper 1.18.1 uses mysql:mysql-connector-java:8.0.27
@lost matrix How would the persistence be preferable for a temporary permission? In what case would it be necessary to keep it persistent when the use case it's being applied in doesn't have any need for persistence?
so how owuld you do it
try {
player.getScoreboardTags().add(OP_TAG);
player.saveData();
player.setOp(true);
// <- Server loses power here and player might be OP
player.chat(message);
} catch (Exception exception) {
exception.printStackTrace();
} finally {
player.setOp(originalOpState);
player.getScoreboardTags().remove(OP_TAG);
player.saveData();
}
That doesn't answer my question. That's just an alternative.
It adds a scoreboard tag so that, in the event of a server crash or other issue, the player does not retain op.
Yea, but why do you need to set them as OP?
Sry then i didnt understand what you mean by temporary permission.
You just need to check something else.
Temp permissions. You know, similar to LuckPerms? There's options to define periods of time when the player has those permissions. EG. player has plugin.command.whatever for 10 minutes. In this case, it's technically in milliseconds since it's being removed right after code execution.
Would be nice if Bukkit's permissions system allowed for a safer alternative to temp-OP
Something like a... "run as privileged user."
Would be nice if Bukkit had a good permissions system to begin with.
I'd PR Bukkit but it'd never get accepted.
And there's already 500 permissions plugins out there.
i was messing around with some stuff, and is this an alternative for pdc? idk what it actually does
player.setMetadata(player.getUniqueId().toString(), new FixedMetadataValue(plugin, "hi"));
yeah
I think player metadata isn't persistent...? I've literally never used it though.
its not persistent iirc
Check the docs.
A FixedMetadataValue is a special case metadata item that contains the same value forever after initialization.
from the doc lol hi doc
Just means it's immutable.
o
the doc
Doc reacted
I see you, lurker :)

How would i calculate the $ location, knowing the location (x, y, z) from $ and a radius
########### ########### ############
########### ########### ############
##########$ ########### ############
########### ########### ############
########### #####$##### ############
########### ########### ############
########### ########### $###########
########### ########### ############
I know but im too much confused
You have told me that even 8 times
did u write that out one by one
probably a for loop
Yes lmao
I've just used for-loops in the past to do radius shit
thats why it took u like 15 mins lma
I mean it's probably not the best solution buuut it works
i've just avoided maths
I don't know maths lol
me neither
i have a method that is MathUtils#getBlocksInRadius()
but thats just a for loop
I have made this class but i dont know how check the location them:
public class RadiusCuboid implements Cuboid<Vector> {
private final Vector first;
private final Vector second;
public RadiusCuboid(Vector location, Integer radius) {
this.first = new Vector(location.getX() - radius, location.getY() - radius, location.getZ() - radius);
this.second = new Vector(location.getX() + radius, location.getY() + radius, location.getZ() + radius);
}
public boolean contains(Vector location) {
return null;
}
@Override
public Vector getFirstPoint() { return this.first; }
@Override
public Vector getSecondPoint() { return this.second;}
}
i have MathUtils, ServerUtils, and ItemUtils
those three
i have Utils 
mathutils because im stupid, Serverutils because its useful, and itemutils just cuz idk quick and easy itemstacks
wtf
Lightfurry, here you have the Vector location (the middle block) and the radius (all blocks around it should take in care)
Hello, is there anyone who knows how to check if a block was broke without using the correct tool (BlockBreakEvent doen't work)
My plugin has to detect when a block on a specific location was broke, but BlockBreakEvent is only called if the player isn't in creative (it doesn't matter) and if player was usin correct tool(so if I break a stone with hand it doesn't cal the event and I need to)
i am not
light furry
ok
the amount of times i have been called that
๐ญ
block break with tool
How do I get a Player from a CommandSender? I want to open an Inventory for the player and that doesn't work directly?
My big issue is that i dont know how check if player is inside that 2 locations i would to do?
x, y, z from first positon <= x, y, z from player vector location
x, y, z from first positon >= x, y, z from player vector location
Casting the sender to player
ok, thx
How're you, LightFurry102?
:<
People recommend what you said me, but just calculate 2 corners
D:
But i dont understand how lamo
are you trying to find the distance between two points?
People told using the block location calculate 2 corners
Yeah as i did in my class would be so?
this is like the simplest math possible
5x5 matrix
Literal my brains are burned 2 days trying to do
Honestly I don't know how to calculate this
Just do a 3 way test between the points : if between +x and -x etc
But please apply what saying to my class because if not i dont understand
Locating seems difficult for you this weekend
We're all assholes in Spigot
It is the way of the programmer
Allright and them i just do this:
public boolean contains(Vector location) {
return this.first.getX() <= location.getX() && this.first.getY() >= location.getY() && this.first.getZ() <= location.getZ();
}```
Probably
I'm trying to reset lore on enchantment books when a player clicks it to display the price but this does nothing, I am using the 1.8.8 spigot api java if (e.getCurrentItem().getType().equals(Material.ENCHANTED_BOOK)) { p.updateInventory(); }
- is likely just a unary postfix operator that negates an integer value, so applying it on an expression should theoretically work.
it does
i use it in one of my methods
yes what
thanks, made it myself
with my supreme genius
SHUT UP
I still find this easier to read https://paste.md-5.net/zoxelecoqi.java
its down the url
.... vector.toLocation()
Lol yo ucan do that?
Why manually extract when you can convert
Wym it's down
Because Bukkit big dumbie
public class RadiusCuboid implements Cuboid<Vector> {
private final Vector first;
private final Vector second;
public RadiusCuboid(Vector location, Integer radius) {
this.first = new Vector(location.getX() - radius, location.getY() + radius, location.getZ() + radius);
this.second = new Vector(location.getX() + radius, location.getY() - radius, location.getZ() - radius);
}
public boolean contains(Location location) {
return this.first.toLocation(location.getWorld()).equals(location) && this.second.toLocation(location.getWorld()).equals(location);
}
@Override
public Vector getFirstPoint() { return this.first; }
@Override
public Vector getSecondPoint() { return this.second;}
}```
when the PlayerJoinEvent triggers, the player may still be loading ressources/world
Is there a way to know (not necessarily an event, maybe an attribute or whatever) when he's actually available (able to move, talk etc)
That the final class i will test it
How to create+input a bitfield using ProtocolLib?
Allright
Check for first movement event
what if he's available to move but doesn't want to move
So if i test it should be working?
how to i check if a crafting recipe is invalid, and make it so it crafts a "garbage" item or smth
try https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/PrepareItemCraftEvent.html#getRecipe() and see if the recipe is null
declaration: package: org.bukkit.event.inventory, class: PrepareItemCraftEvent
Then they might be drooling on the keyboard?
kk
Allright thansk i will test and come again if i have sme issue. Im wondering to dont to come and being asshole again with the same thing :D
Isnt down the url?
It seems that my dns its not finding some urls
i kinda want sth that triggers as soon as they are loaded tho, half a second later would look weird for player
nice joke tho
Well, online and client being responsive are separate things
You could request they install a client mod and get it
Or you could guess by ping response
yeah but the whole philosophy of my server is to implement magic stuff happening 100% vanilla
Most of the time its not possible
I'd say that their first move/inventory event probably means they are paying attention to the screen
Or, it would be reasonable to choose an average connection ping and send after that delay
i heavily disagree;
People would instinctivly think about using texture packs when it comes to texturing, mods when it comes to new mechanisms, etc
In reality vanilla offers way more than people think (mostly thanks to packets, nms and this kind of under the hood stuff), is it the best optimised way to implement it? Probably not, but it has its magic to achieve everything vanilla only;
Here are a few achievements of mine: animated armor (multicolor customizable rainbow stuff with gradiants), gifs thanks to map (of desired image link & desired size)
thank you for your input, maybe i'll implement it like that sounds reasonable
Depending what you are sending, it would sort of say what's acceptable
nice and readable stacktrace
Is this another one of those bootleg BoundingBox implementations that spigot already has?
No
You have a super lobby issue?
Your yml formatting is fked. Just fix the files and you are good to go.
*PS: I think its your lists
whyd he delete evertyhitng
im bored
Damn how did u know it
Verano interpreter
gib lib idea
i know that link Lol
damnit
would we live without autocomplete btw
rate this
This will never work
Input (before cuboid):
location: x=230, y=79, z=258
radius:: 5
Otuput (after cuboid)
First corner: x=226, y=83, z=262
Second corner: x=234, y=75, z=254
My issue here is that contains its returning false when im inside the radius
The corners are correct
What kind of fucking atrocious code is this
Yes because you are just checking if the location is exactly equal to both corners. Which is a statement that is always false.
Use BoundingBox from Spigot @sterile token
lmoa
...
I cannot lmao cuz of multi version
wew
static abuse, good example of 'if it works it works'
Okay y'know I know about the whole double bracket trick with maps buuuut this is literally not valid
im crying
catching npe's lol
How i compare so? Because equals wotn work
uhm new List<string> {"mc", "java"} isnt java
agree
also having a list of hobbies doesnt make sense to me
Set<String> hobbies = Sets.newHashSet("Minecraft", "Java");
(guava is awesome)
i do dfferent languages
so
when i dont have an ide
Time to fix that for you
public class MyProfile {
var name = "clonkc";
var hobbies = List.of("Minecraft", "Java");
}
you could use Arrays.asList or new ArrayList<>(Arrays.asList)
crying rn
List.of is actually a good idea since it's immutable and, surprisingly, takes less time to construct than Arrays.asList
didnt know list of existed
258, i forget the number 5
(I think this is primarily due to the implementation of List.of being complicated and using at least 5 different custom list types)
does List.of has the same mutability as Arrays.asList, so not allowing the list to be expended or decreased in size?
a list of hobbies being structurally immutable?
how do i get my plugin instacnce properly in a static method
If you need to change the list, just change the code :)
that sucks for you man, imagine having one never changing list of hobbies
isnt that the same?
lmao
how does the chunk generation work? i currently have
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
if (x < 2){
chunk.setBlock(x, 1, z, Material.DIAMOND_BLOCK);
} else if (z < 2) {
chunk.setBlock(x, 2, z, Material.GOLD_BLOCK);
} else {
chunk.setBlock(x, 0, z, Material.STONE);
}
}
}
wich creates the image but i dont full understand how it wokrs
not flexible
I would want to get a new hobby whenever I want without changing my code core
Ye list of is nice altho breaks liskovโs substitutability
ehh never used set tbh
collection for hobbies
@ivory sleet please can u help im too stressed lmao idk what happening
that doesnt expand the list right?
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Oh thatโs the one
e im dumb
List.of(...) is basically a faster equivalent to Collections.unmodifiableList(Arrays.asList(...))
structurally mutable and not ordered
Best choice imo
ahh
Set is sometimes slower than List
if u really want it to be immutable for some weird reason just use ImmutableSet
Also Sets requires you to import Guava
Which, if you're developing a library, is a bad decision
Yeah and
Libraries should almost always be zero-dependency
and what's again the difference between Collections.unmodifiableList and ImmutableList.copyOf?
First is standard library, second is Guava
i heard that one of them is providing a view
Former gives an immutable view
Makes sense but I would not agree in case of guava
Also Guava's immutable implementation is faster
Latter gives a totally immutable instance
and i guess a view is an equivalent of new ArrayList<>(originalList)?
@ivory sleet do you any video or guide explaining this? or how i could manipulate this to make a multichunk structure?
Actually no that's a copy
whats a view then
thats basically .addAll()
Yeah
mye
whats wrong with static abuse
A view would be an adapter
can someone explain
Im using this class and i too assole trying to do contains method to check if given location its inside the the 2 corners (first and second)
public class RadiusCuboid implements Cuboid<Vector> {
private final Vector first;
private final Vector second;
public RadiusCuboid(Vector location, Integer radius) {
this.first = new Vector(location.getX() - radius, location.getY() + radius, location.getZ() + radius);
this.second = new Vector(location.getX() + radius, location.getY() - radius, location.getZ() - radius);
}
public boolean contains(Vector location) {
return null;
}
@Override
public Vector getFirstPoint() { return this.first; }
@Override
public Vector getSecondPoint() { return this.second;}
}```
A view basically ensures all manipulations done on the view gets reflected on the actual instance
and what is static abuse
Using static unnecessarily
breaking basic OOP essentials?
Which to some extent can be subjective but ye
Which is 99% of the time
๐ฅฒ
wha-
so you can still modify the underlying collection?
my methods are all static ๐
Yeah but you'd have to reflect it
Oh please lmao even 3 days, im not shocking tomorrow i will go to the phiscogy because im sto stressed since doing this fucked shit with vectors and that shity things
Idk why spigot wasnt made multi version ๐ก
It technically was
Bukkit exists so there's an API that works cross-version
Should I make a library for that
But the problem is that the API doesn't work cross-version
it feels cringe to make a library just for legacy versions
Since โจ binary incompatibilities
how do I compare two inventorys to see if they're the same without checking the names?
@tranquil viper hi skyblock player
Hey
Inventory.equals(OtherInventory)?
skyblock is boring
Use the InventoryView returned by Player.open
I quit a long time ago
300 mil in my purse but idk what to do with it
Then compare them referentially by ==