#help-development
1 messages · Page 500 of 1
Only true for negatives
If we are dealing with positives the larger number is east
So really you need to see if you have negatives and positives first. So you know which way in terms of 0 you are testing
could just use this
and max
seems like they don't look at the absolute value
anyways this all helps a lot
tysm for the help
Only problem with this is if you have 0
oh true
Negative 0 is smaller then positive 0
oh i forgot ints also have a negative zero
So if you encounter 0 the check is actually easier
Only need to look at one number
If that one number is negative or positive. Of its negative its west positive its east and that is all you have to check if you encounter a side that has 0
Personally i would use bitshifting for this
well there's this if it helps
declaration: package: org.bukkit.inventory, interface: Recipe
check all of the implementing classes listed at the top
register with Server#addRecipe
no problem
going to bed soon but others here can help if you have questions
if you're using a crafting table you're either looking for ShapedRecipe or ShapelessRecipe
other blocks use the other types
and you want them to be able to craft it?
if you have an itemstack of your custom golden apple with whatever custom meta
you can just make a new ShapedRecipe or ShapelessRecipe
and then add ingredients
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataContainer.html Then with your items item meta you can utilise this class to hold info with the item
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
do you have spigot as a dependency?
spigot-api specifically
ItemStack should be easy to import
might just be your IDE playing tricks on you
?paste
Ok on lunch now
Incoming sudo code. May take me a minute as i am on phone. Time to explain the loopy thingy
Hey so I have the plug-in geyser installed and it won’t let me connect to the server so I have to go to geyser connect is there anything I have to change so i can just put the server ip and not geyser connect so i can just go straight to the server
int locationsperholo = (20^3)*holos;
ConcurrentHashMap<Location, Hologram> hololocations = new ConcurrentHashMap<>(locationsperholo)
Location start = player.getLocation();
List<Hologram> foundHolos = new ArrayList<>();
for(int y = 0; y < 20; y++){
for (int z = 0; z < 20; z++){
for(int x = 0; x < 0; x++){
foundHolos.add(holoLocations.get(start.add(x,y,z));
foundHolos.add(holoLocations.get(start.sub(x,y,z));
}
}
}
@regal scaffold
Does this make sense?
As you can see we dont iterate the map. We are only looping for the math only
And then we add what we find to the array
Cool thing about arrays is they cant contain duplicates including null so instead what happens is that if duplicate is found it is updated with new value instead
So we dont have to bother checking for null returned or duplicates however this means the array could contain at least 1 null
That's very interesting though
Because one wouldn't think it's faster
But I guess there's a lot of stuff going on behind a hashmap
??
Well the map could contain 1k locations. Where as the math for around the player we only checked cubed 20 around player
Also hashmap uses hashes
So it finds the hash of a given key instead of interating
Hashmaps have buckets and therefore makes it easy to find which bucket contains what hash
The use of concurrenthashmap is the hashmap that is threadsafe
Meaning you can safely use that hashmap between several threads. Since we didnt make any api calls except in the beginning we simply transformed the location which is thread safe to do
I see now
And voila you can do this check per player per thread or what is recomended is use a thread pool
Alright that makes more sense
While we’re on this topic of performance
The new display entities
Is there any benefit at all from using packets to display them
Im talking again, like 1000 per world
Im working on efficiency, so sometimes I need to hide/update just some of them
Probably not but i havent quite looked at them thoroughly. As far as i know they are not ticked or not ticked as often as armor stands. Part of the reason for using packets
They are indeed not ticket but they can be updated obviously so I’m thinking maybe skipping the api later will help a bit when there’s a lot of them
Since they are entities you should be able to use the api to hide them per player
That is true also
I guess the only difference would be server load on creation or update no?
Not while they are placed
As i said part of the reason for packets on armor stands was because the server ticked them often
It would be the same load if they were fake. The only difference is that instead of being in memory mostly they will auto save to the world files
I don’t think they do save
Ay all
At all
If you restart the server they are gone
Display entities are indeed saved
They shouldnt be unless you have world saving disabled or didnt allow the server to save
But again i havent looked at them extensively yet
Oh really? I might’ve confused myself then
Then packets are still better
For dynamic stuff
So nobody is going to help me ??
I am at work
How is this a development problem?
And my lunch is over
Just be patient the others will be here eventually
Well be patient. This isn't a staff discord or anything. We are volunteers and hobbiests
and also don't go into other channels just so people see it
Frost I know this is the wrong cord but
Do you know how to convert a MiniMessage component to NMS Component
To use inside a display entity
No. I dont use minimessage
So i dont know if you could cast at all or if minimessage has a nms conversion method
Best to ask minidigger he should be up right about now
I think I have the conversion right
I just have these weird section characters and it doesn't like that
It's just a link to the entire docs
Look at the adventure docs
I have lol
I'm just confused why &
Is getting converted into section
Like if I was using ChatColor.translateColorCodes
Because & doesnt require special characters for the user and typically that is the character to substitute the section symbol
Have no idea. I dont use a lot of these third party apis
Checking the code just wondering if you know of top of your head
I typically just use the spigot api and make my own stuff lol
I dont rely on other plugins for anything if i dont have to because i typically run into problems that are outside of my control to fix leaving me with dumb hack solutions instead or none at all
Anyways back to work for me though
Driver awaits me to change a tire lol
After a bunch of looking around PAPI
I did not find it
So.... I'm thinking on what to do
Hmm?
Oh
translate alt codes after minimessage
Really?
Like
MiniMessage.miniMessage().deserialize(t, resolver)
And translate then?
yeah
You can just use minimessage formatting for color codes.
Yeah but this was already written
It's just weird how & is now section
How do I even translate a TextComponents color codes
Screw it I'll just use actual mm formatting
TextComponent.fromLegacyText() if you have a string but need the component
Hello, which of these 2 methods is better to check if a server is online?
ServerInfo#ping() //then check the throwable
Socket#connect(ServerInfo#getSocketAddress(), TIME_OUT); //then check if able to connect
ping
But ping take more time than or not?
of course not
both send a single packet and get a response
ping/pong or in the case of connect the response is probably an ACK
OK thank you
Is it possible to create a local database in the server
One that comes with a spigot plugin
Technically yes, if you use h2 or sqllite or something that the spigot plugin creates. Otherwise if you want something like MySQL you'd need to host it outside of the mc server
And I can use sqlite just like normal?
OK thanks
prob stupid question but can i pack a dll directly inside the jar under resources?
since a jar is basically a zipped archive idk if a binary is treated the same
.dll and .so for OS independency
Even I added this to maven pom
My plugin is still told me that it is not included
You need to shade it
yeah, just gotta remember to load it somehow
(System.loadLibrary, iirc, but u might need to "extract" the DLL from the jar to either a temp or perm location)
shade and relocate
Light ide💀
I am trying to make slimes always spawn with a size of 5 and make them smaller when they die so that they split into smaller slimes and not into 2 slimes with a size of 5.
For some reason when they die, they become glitched like in the image and they are unhittable.
This is the code, do you know why it's happening?
public void StrongSlime(EntitySpawnEvent event){
if (event.getEntityType() == EntityType.SLIME){
Slime slime = (Slime) event.getEntity();
slime.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(10);
slime.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(3);
slime.setSize(5);
} else if (event.getEntityType() == EntityType.MAGMA_CUBE){
MagmaCube magmaCube = (MagmaCube) event.getEntity();
magmaCube.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(10);
magmaCube.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(3);
magmaCube.setSize(5);
}
}
@EventHandler
public void SlimeDeath(EntityDeathEvent event)
{
if (event.getEntity() instanceof Slime)
{
Slime slime = (Slime) event.getEntity();
slime.setSize(slime.getSize()-1);
} else if (event.getEntity() instanceof MagmaCube) {
MagmaCube magmaCube = (MagmaCube) event.getEntity();
magmaCube.setSize(magmaCube.getSize()-1);
}
}```
i think you need to cancel death event if current size is more than 0
but then the slimes will never die
it will die only when it is minimum size(0)
there is not method for canceling this event
oh okay
ill send something
later
i think this should work
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event){
if(event.getEntity() instanceof Slime slime) {
slime.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(10);
slime.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(3);
slime.setSize(5);
}
}
@EventHandler
public void onEntityDeath(EntityDeathEvent event)
{
Entity entity = event.getEntity();
if(entity instanceof Slime deadSlime) {
int size = deadSlime.getSize();
if(size > 0) {
Slime newSlime = (Slime) deadSlime.getWorld().spawnEntity(entity.getLocation(), entity.getType());
newSlime.setSize(size - 1);
}
}
}
@harsh totem
btw you dont need to check is it instance of MagmaCube or not cuz MagmaCube is subinterface of Slime
hey quick heads up
what the Fuck is a logoutivator
use World#spawn(Location, Class<T extends Entity>, Consumer<T>) to edit properties before the entity is spawned (to avoid flashes)
Thank you, it did resolve the bug that they are half dead half alive but they now split into 4 instead of 2
slime split into 1 slime smaller than the one that was killed and 3 slimes with the exact same size as the one who died
Just spawn multiple
it spawns, then entityspawnevent changes its size and only then death event changes size to deadslime's size - 1
You can set a metadata key on the entity iirc to avoid running the spawn event
okay
Yeah something like
Slime spawned = deadSlime.getWorld().spawn(entity.getLocation(), entity.getType() == EntityType.MAGMA_CUBE ? MagmaCube.class : Slime.class, slime -> {
slime.setMetadata("changeSize", new FixedMetadataValue(plugin, null));
slime.setSize(size - 1);
});
And use hasMetadata in the entity spawn
bruh, I thought minimum size is 0 but it is 1
Does anybody know how to change this message using the SpigotAPI? ServerListPingEvent might be it but i don't know to go from there
Thank you
it looks a bit weird but you can change slime's size to 1 in death event
as a result, we have this:
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if(event.getEntity() instanceof Slime slime) {
slime.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(10);
slime.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(3);
if(!slime.hasMetadata("resized")) slime.setSize(5);
}
}
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
if(event.getEntity() instanceof Slime slime) {
int size = slime.getSize();
if(size > 1) {
slime.setSize(1);
slime.getWorld().spawn(slime.getLocation(), slime.getClass(), newOne -> {
newOne.setMetadata("resized", new FixedMetadataValue(this, null));
newOne.setSize(size - 1);
});
}
}
}
How do I get the block face using block break event? I had this function but before I added the hashset, it was not mining in a 7x7 due to water between the blocks Set<Material> ignoreMaterials = new HashSet<Material>(); ignoreMaterials.add(Material.WATER); ignoreMaterials.add(Material.LAVA); List<Block> blocks = player.getLastTwoTargetBlocks(ignoreMaterials, 10); BlockFace face = blocks.get(1).getFace(blocks.get(0));
i got a new task to do
Im passing 13 tests, but getting TL on test 14
basically you have an array of N elements [1, 2, 3, 4]
there is a dist() method, which basically does this:
public static int dist(int base, Set<Integer> set) {
int result = 0;
for (int elem : set) {
result += Math.abs(base - elem);
}
return result;
}```
so the dist() returns an integer, which we can call distance.
the integer set has fixed size K(from the input) and can contain any K elements of the array(except the one which is a base element for the dist method)
so basically for every element of the array [1, 2, 3, 4]
i need to find the most optimal Set of two ints, which gives the lowest dist() result
my current approach was to sort the array ascending
then take the element and go for binary search
ArrayDeque<Integer> set = new ArrayDeque<Integer>();
int leftPointer = i - 1;
int rightPointer = i + 1;
while (set.size() < k) {
if (leftPointer < 0) {
set.add(a[rightPointer]);
rightPointer++;
} else if (rightPointer == n) {
set.add(a[leftPointer]);
leftPointer--;
} else {
int left = a[leftPointer];
int right = a[rightPointer];
if (Math.abs(base - left) < Math.abs(base - right)) {
set.add(left);
leftPointer--;
} else {
set.add(right);
rightPointer++;
}
}
}```
the cases for K == 1 or K == n - 1 are in the beginning of my code and i don't care about them
Where from did you get this task
so the only problem is when i need to add elements to the set by searching the closest possible element
so well my binary search and sort are doing great
but fail by time on test 14
i'm 100% that's sorting slowing me down
Can you explain what "Set of two ints means"?
new Set<Integer>(anyInt, anyAnotherInt); or Set.of(anyInt, anyAnotherInt);
basically it can be any collection which i can get and remove elements from
i don't want to use array cuz i can't use remove(Object o)
so i stopped on ArrayDeque
But you said that set's size is K, not 2
for example i typed above it's 2
Okay
[1, 2, 3, 4](N = 4), K = 2
[3, 2, 1, 101, 102, 103](N = 6), K = 2
[3, 2, 5, 1, 2](N = 5), K = 3
i basically found out
that to get the lowest dist() result
you need to make a set of the closest K elements
to the given number
so in example with 6 numbers, the inputs to the dist() would look like this:
3, {1, 2}
2, {3, 1}
1, {2, 3}
101, {102, 103}
102, {101, 103}
103, {102, 101}
and the dist would return 6 answers:
3
2
3
3
2
3
the dist method.
Is there a way to find out if the player pressed F?
What is the maximum possible value of N, K and numbers in array?
And how much is memory and time limit?
2 sec limit
512 mb memory
max n = 300k
k is from 1 to n-1
i made two separate algorithms for cases when k = 1 and k = n -1
is there a way to get a player at a location?
so i'm only working with values between
world.getNearbyEntities(x, y, z, e -> e instanceof Player()).get(0);
splendid
Okay, what is the maximum value of ints in an array?
will it work if player doesn't have item in hand?
Well, sorting a 300k array is definitely too long
if (k == n - 1) {
if (k == 1) {
int dist = Math.abs(a[0] - a[1]);
System.out.println(dist + " " + dist);
return;
}
for (int i = 0; i < n; i++) {
ArrayDeque<Integer> copy = new ArrayDeque<Integer>(n - 1);
for (int j = 0; j < n; j++) {
if (j == i) continue;
copy.add(a[j]);
}
System.out.println((i == 0 ? "" : " ") + dist(a[i], copy));
}
return;
}```
yup
and also has bad consequences
cuz when array is sorted, the elements are in a different position
and when i print the answer
my values are misplaces
so instead of output 3 2 2 3
i get 3 3 2 2
or smth similar
w hy are you creating n copies
they are not actually full copies
yes you're skipping 1 element in each ocpy
in this case they all exclude 1 element and their size is -1 from the original
You could just create a single copy and skip that one element
cuz i need to pass some kind of set to the dist() method
true actually
i spent 1 day on this trying different solutions
went to sleep todays morning
gonna change the thing
wdym by that
reattach
if (k == n - 1) {
if (k == 1) {
int dist = Math.abs(a[0] - a[1]);
System.out.print(dist + " " + dist);
return;
}
ArrayList<Integer> copy = new ArrayList<Integer>(n);
for (int j = 0; j < n; j++) {
copy.add(a[j]);
}
for (int i = 0; i < n; i++) {
System.out.print((i == 0 ? "" : " ") + dist(i, copy));
}
return;
}```
skip when i count, not on creation ig
cuz i need to loop through each element elem of array and use dist() on elem and copy skipping the elem inside copy
this thing above uses arraylist so i can just loop from 0 to size and compare i to position of the element, and if they match just skip value
private static int dist(int pos, ArrayList<Integer> elems) {
int result = 0;
int base = elems.get(pos);
for (int i = 0; i < elems.size(); i++) {
if (i == pos) continue;
result += Math.abs(base - elems.get(i));
}
return result;
}```
but what do i do with the second part of the task
where (K <= n - 2)
i can't just make a copy and skip one element again
i need a searching algorithm which works on unsorted array
so i avoid instantiating my int wrapper for every small int with an originalPosition field
and also don't waste my 2000ms on sorting 300k-long int array
also if i would use collection, i would need 300k Integers(wrappers)
there should be an array solution
what's the difference between
System.out.print(stringBuilder);
and
System.out.print(stringBuilder.toString());
i mean it will anyways print the string
but do i really need to type .toString() to save time
or for a string it will additionally call String#toString()
why are you setting the slime's size to 1
it's dead anyways
If size isn't 1 it spawns 3 new slimes
spigot api
How to know if no one is looking at an Entity?
rayTraceEntities
Nvm, arrays.sort does it in less than 100ms
yes, I used it, but in order to get the item that the player is looking at, but how to reverse the process?
you need to find the most optimal set for each number in given array?
or for specified by index number from array?
by index
cuz values might be same
on different indexes
as i said parts of code where (k == 1) and (k == n -1) and (k == n -1 && k == 1) are done
now i need different stuff
where k <= n -2
can you send example input and output?
4 2
1 2 3 4
returns
3 2 2 3
Null safety
toString()
thanks
I think at least
The other one calls String::valueOf, and then toString()
Idk if PrintStream#print(String) does that
how would i run World#getNearbyEntities asynchronously?
how would i do like &d in a chatcolor
and tghen it converts itself
I want to create custom physics objects
Is there any good way to access the games physics engine through spigot
Or is it possible to get the collision mesh for a chunk/world and pass that into an external physics engine
Hello I have this error :
java.lang.IllegalArgumentException: Channel must contain : separator (attempted to use BungueeCord)
@Override
public void onEnable() {
Bukkit.getConsoleSender().sendMessage(prefix+"Plugin Opérationnel !");
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungueeCord");
INSTANCE = this;
getCommand("play").setExecutor(new CommandPlay(this));
Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
Bukkit.getPluginManager().registerEvents(new ServersListener(this), this);
}
learnbungee
channel should be "Text:Text"
BungueeCord:BungueeCord ?
No, The bungeecord channel string should just be "BungeeCord" whether it be for incoming or outgoing.
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/
thx
With packets, you can use worldborder.transitionSizeBetween. Is there a way to do this without packets using the player#setWorldBorder one?
it was definitely changed in newer versions
So I have an error ;(
.
The wiki was updated 2 months ago. How is it still wrong then?
idk lol
i used to code plugin messaging plugin like in 2021
and the error was already present
here you go
So that's gonna be
"MyPluginsEcoSystem:CringeChannel"
1.13 update
seems like this one works:
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
int[] a = randomArray(n);
//int[] a = new int[n];
//for(int i = 0; i < n; i++) a[i] = in.nextInt();
int[] b = a.clone();
Arrays.sort(b);
Map<Integer, Long> map = new HashMap<>();
int p = 0;
long d = 0;
for(int j = 1; j <= k; j++) {
d += Math.abs(b[j + p] - b[0]);
}
for(int i = 0; i < b.length; i++) {
while(p < i && p + k < b.length - 1) {
int t = Math.abs(b[p] - b[i]) - Math.abs(b[p + k + 1] - b[i]);
if(t <= 0 && p + k != i) break;
d -= t;
p++;
}
map.put(b[i], d);
if(i != b.length - 1) {
d += (long) (i + i - p - p - k + 1) * (b[i + 1] - b[i]);
}
}
for(int i : a) {
System.out.println(map.get(i));
}
}
private static int[] randomArray(int length) {
Random random = new Random();
int[] arr = new int[length];
for(int i = 0; i < length; i++) {
arr[i] = Math.abs(random.nextInt());
}
return arr;
}
i think it can give wrong answers if there is more duplications of 1 number than K
Shit's weird. It should work regardless.
i mean, there are probably a lot of bugs here, but in general, this algorithm is fast enough to solve the task
random array is for input right?
i think this solution is what is commonly called dynamic programming
Huh, guess it did get updated at some point. Looks like the wiki needs to be updated as well, but I still don't quite get how they would get an error if they used the specific channel.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/messaging/Messenger.html#registerOutgoingPluginChannel(org.bukkit.plugin.Plugin,java.lang.String)
sadly broke on third test
6 2
3 2 1 101 102 103
output should be 3 2 3 3 2 3
and yours is 99 2 3 3 2 3
first answer is dead for some reason
ask md_5
🙂
my plugin is not showing up
(its my first problem ever so if i dont give enough info which will be the case lmk)
Bukkit#getOfflinePlayer(String name)
deprecated
It's only deprecated because of the transition to UUIDs.
hmm
It's not going away
doesnt mean you cant use it
It has valid usecases
its deprecated by a stupid reason
It was only marked as deprecated because of people abusing player names for storage and then complaining about how their stuff wasn't working.
Refresh your pom
yeah i kinda have a valid usecase (players use name as argument in command)
use it then lol
alr
because you dont have it downloaded yet
so it cant find this specific version in your files
just reload your maven or clean install fresh
your java version is too low
?paste your entire pom
fixed:
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
//int[] a = randomArray(n);
int[] a = new int[n];
for(int i = 0; i < n; i++) a[i] = in.nextInt();
long start = System.currentTimeMillis();
int[] b = a.clone();
Arrays.sort(b);
Map<Integer, Long> map = new HashMap<>();
int p = 0;
long d = 0;
for(int j = 1; j <= k; j++) {
d += Math.abs(b[j + p] - b[0]);
}
for(int i = 0; i < b.length; i++) {
while(p < i && p + k < b.length - 1) {
int t = Math.abs(b[p] - b[i]) - Math.abs(b[p + k + 1] - b[i]);
if(t <= 0) break;
d -= t;
p++;
}
map.put(b[i], d);
if(i != b.length - 1) {
if(p + k == i) {
d -= Math.abs(b[p] - b[i]) - Math.abs(b[p + k + 1] - b[i]);
p++;
}
d += (long) (i + i - p - p - k + 1) * (b[i + 1] - b[i]);
}
}
for(int i : a) {
System.out.println(map.get(i));
}
}
private static int[] randomArray(int length) {
Random random = new Random();
int[] arr = new int[length];
for(int i = 0; i < length; i++) {
arr[i] = Math.abs(random.nextInt());
}
return arr;
}
i put if(p + k == i) after putting dist in map here
<configuration>
<source>9</source>
<target>9</target>
</configuration>
your source is j17, but you compile with j9
This feels like a mathematician tried implementing some equation in Java
still the same issue
im actually a mathematician 💀
Makes sense on the unreadable side of things, ya'll got a thing for that or...?
Hi everyone! What is formula for calculating speed in percent? I know that default speed attribute value is 0.2 (100% speed), but attribute value 0.4 much faster than 200% speed
testin
i hope itll pass at least test 5
Unsupported class file major version 61```
still this issue
java version
what are N and K on test 14?
the problem is
i don't know
all of my solutions fucked up on test 14
and yours also
oh, you are russian too
any other ideas
wtf man why are you asking for help in spigot development chat?
I mean it's common
and it's fine tbh
idk, tests on my pc with N = 300k and K = 1, 10k, 75k, 150k, 299999 runs in less than 300ms
can you choose java 17 compiler?
maybe java 15 has slower sorting or slower hashmap?
i don't think they were touched since added
which processor is on the testing system
help @@
Intel(R) Xeon(R) CPU E5-2660 @ 2.20GHz, 20480KB cache, virtualizаtion on 1 core, 4GB RAM, used OS Linux
java version
I got java 17 ...
mismatch
of server and plugin or maven version and actual version
where do you get this error?
oh, maybe N limit isn't 300k, but 3m?
maven-shade-plugin ?
show
Show your pom
?paste
make sure the shade plugin is up to date
300k
Use 3.4.1
oh lol k is starting from 2
i need to remove some obsolete code from my old solution
same issue
sorting takes 50% of time when N is 300k, but i see no different solution
Could you show what Java you've selected in project settings
Check your IDE project SDK and language level.
1 second?
Since you're using modules make sure the issue isn't in one of the other modules
total time on my pc - 300ms, sorting time - 160ms
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e){
Player p = e.getPlayer();
String message = e.getMessage();
PermissionAttachment attachment = p.addAttachment(plugin);
YamlConfiguration data = getPlayerData(p);
if(message.contains("kick")) {
attachment.setPermission("minecraft.command.kick", false);
data.set("hasKickPermission", false);
saveData(p, data);
}
now, even though the player has permissions before running the command, when they press enter, the message that shows up is as if they didn't have permissions in the first place
It looks to me that you are setting the permission to false. Therefore, they don't have it.
that work tks
hmm, i want the command to execute, and then the permission is set to false
how can I do that?
I tried to relcated and shadded the jar
but still got this error
java.lang.NoClassDefFoundError: com/ziwoxyt/summitcosmetics/mclibs/inventory/SimpleInventory
Show all of your poms
Use the scheduler to set the permission node 2 ticks later.
try putting if(map.containsKey(b[i])) continue; in the beginning of the for(int i = 0; i < b.length; i++) loop
good idea
thanks
there
and can you dm me with full problem description?
maybe there is something important that im missing
Hey, does anyone know a way to make an arena reset for a 1v1 system? So that the arena is at the end of the fight so before the fight reseted.
There are many ways
You can for example store all the block changes and revert them
or just disable world saving and reloading the world
The problem is, when I save all mined and placed blocks in a list, unplaced water or lava, for example, are reset.
save it all in a HashMap (location,before state) -> only put it in if there is no location at it exist
Yes
anyone know how to set the block orientation when adding a block to the world?
Someone here a couple days ago was saying "Spigot does not have any direct downloads of the server or javadoc files. They have to be built with BuildTools."
Idr who it was, but I am here to officially tell you that you are, in fact, incorrect.
https://hub.spigotmc.org/nexus/content/groups/public/org/spigotmc/spigot-api/1.19.4-R0.1-SNAPSHOT/
That is api
Just interfaces with no implementation
You can't download spigot jar, he was, in fact, correct
how can i get information whether no one is looking at the item?
As I understand it, I need to use RayTraceResult, but how exactly?
You need to provide more information
you want to tell when No one is looking at a specific item?
What item?
https://www.spigotmc.org/threads/convert-png-file-to-skin-vice-versa.602779/
someone can help me here?
I have an item that drops from a block. I'm adding it to the list of items. I need to make a pickup system, when a player looks at an item, it is highlighted, and a title appears, and there is an opportunity to pick up an item on F.
Giving a glow to the object the player is looking at is not a problem. But to remove the glow is another
so add to it's PDC the player who is looking that triggered the glow (could be more than one)
then tick the item until no one is looking anymore
rather add the players UUID
I deleted the code
You seemed to lose interest
however
there is a simpler way to do the duping
how do I listen for all the advancements in the game being completed?
if you only want to dupe like that when it goes through an end porta
then detect it in the teleport event
it will have the velocity
however you don;t really need it
you are only doing it on sand and you always want 4 thrown in each direction
I thought you were duping?
if a block comes in from the east and gets thrown west when it exits, thats not a dupe
I thought the point was when a block enters the portal it produces 4 the other side
one thrown in each direction
so there is no actual duping
to dupe mean you make a duplicate, so you end up with more than you started
controling the direction it is thrown is not a dupe
seems so
Isn't there just a config in the paper.yml file?
Try if the EntityPortalEnterEvent works with falling blocks. If so, you might be able to check if the entity is of type falling sand and then manually load the end platform, spawn a falling sand and give it the velocity the one in the overworld has.
anyone know a way to catch an event when a bedrock user hold-clicks, i believe that may be right clicking on java? like when hold to talk to aa villager?
Look into your geysar api or whatever
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
this is how mineskin works: mineskin api -> mineskin server -> alt accounts -> update skins -> get mojang-generated signature and value
you should do the same thing, but there's two problems: skin-set ratelimit, count of alts
Mineskin uses the https://wiki.vg/Mojang_API#Upload_Skin, i suppose?
i think that will not be a problem if i bought some servers
thank you anyway!
but there's a better workaround for this
just use mineskin client api
@EventHandler
public void onInventoryClick(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();
UUID uuid = player.getUniqueId();
if(e.getView().getTitle().equals(ChatColor.DARK_AQUA + "Trails")){
e.setCancelled(true);``` ```public class TrailMenu {
public TrailMenu(Player player){
Inventory inv = Bukkit.createInventory(player, 27, ChatColor.DARK_AQUA + "Trails");``` my inventory click doesnt get cancelled
yes, but im not sure if you need that account to being registered or not (EDIT: yes it does, the page loaded up now, it needs an access token to do that)
have you registered the listener?
I need an original account then?
If i upload two skins, the first one will still be valid?
well i don't know, but why you don't just use mineskin api to do this?
I'll create my own because i need millions of requests per day
will buy some servers (vps or dedicated) to do these requests without ratelimit
hahah thanks xD
Has someone used ebcm recently?
sounds like icbm
Idk ecbm its like easy bukkit command manager
Or smth like that
Hello, I have a quick question. I want to send to the player CLOUD particle packet, but when I am setting the** getParticles** value to EnumWrappers.Particle.Cloud I get this strange particles.
WHEN I RUN A COMMAND EVERYTHING LOOKS FINE SO IT IS NOT MY RESOURCE PACK OR SHADERS FAULT!
CODE:
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
PacketContainer packet = pm.createPacket(PacketType.Play.Server.WORLD_PARTICLES);
packet.getModifier().writeDefaults();
packet.getParticles().write(0, EnumWrappers.Particle.CLOUD);
packet.getDoubles().write(0, -(border/2)).write(1, p.getLocation().getY()).
write(2, z);
packet.getFloat().write(0, 0.1f).write(1, 10f).
write(2, 10f).write(3, 0.001f);
packet.getIntegers().write(0, 10000);
pm.sendServerPacket(p, packet);
I also tried EnumWrappers.Particle.getById(5) where 5 is a CLOUD particle id and I tried it with different EnumWrappers.Particle like EnumWrappers.Particle.FLAME or EnumWrappers.Particle.REDSTONE.
Please help.
Would it be difficult to update a plugin myself that was only tested until 1.15.2? It disables itself on server startup. I have no idea how this would be done.
Why TF are you using packets for particles
Totally depends on the plugin
It's called RegionUnstuck
I tried decompiling it but I don't really know what makes it out of date
How do I do that thing to get a link to a place to put error messages?
You mean like the API has always allowed?
Because i want to display particles only for specific player
?paste
Look at the particle methods in Player...
Looks like it has a broken metrics/updater. Nothing to do with server version. Is there something in the config to disable this?
settings:
update-checker: false
Thanks, I forgot about that function.
I'll try that
Might fix it, otherwise someone will need to decompile it and see
Hi, I'm looking at improving my ability. I notice in well built plugins the built-in events aren't used so much, or the structure and use of Listeners and Events are different. Sorry if I'm not being very clear, but if you do understand what I mean can you please send me some suggestions on how to better structure events with custom events etc, or by sending open source plugins I can look at for inspiration
No, luck. Same error except it didn't check to see that is was the most up to date version
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
There is no longer spigot for 1.19.4? Only spigot-api works...
?bt there never was a Spigot, only Spigot-api. run Buildtools
Was spigot and had NMS support
On 1.19.3 worked that
There has never been a Spigot hosted in a legal repository, run buildtools
how did you do it so fast
I have fast PC :p
He didn't, unless he's running a super computer.
Ok well all you need to do is delete the logging code mentioned in the stack trace you sent
ive been thinking about a problem for a while now and im stuck, i have custom enchants each is an enum and each has a max level. Each enchant also has a tier which stores a percentage change for that tier to happen.
i want to have a method that will return a random enchant based on each tiers percentage chance. the problem im having is that enchant cant be higher than the enchants max level. So when i do that check it will just return nothing
what i want is to be given a random enchant and if that enchant is already maxed out then it will give me a different one
I see a logUtil in the Main class. Do you think removing this could fix it?
Remove maxed out enchants from the list you are randomly selected from
Yep. Hopefully there's no unrelated code there
that would work fine if it didnt also have the tier check, becuase i only add enchants that rolled the correct tier. but if there are no enchants left then i just have nothing instead of enchants in other tiers
Just run the random again with different tiers in that case?
How do i have a right click event
check for action in PlayerInteractEvent
theres right click for air and for block
this is what i came up with and it looks disgusting and doesnt work lmao
thanks; wait does that work if I have a bucket and right click with the bucket? like if I were to try and place a axolotl from the bucket
Then do your tier loop, but remove max enchants before passing to pickRandom
ended up with this and it is working kind of
it will return an enchant successfully but for some reason when i try to add it with this method it cant find any of the method inside of the enchant
even tho it is outputting EFFICIENCY with the first sout
Joining things, though it hasn't existed as that name in forever
It's just google guava
1.7 lol
hey
should i replace it with: org.apache.commons.io.IOUtils?
ig its the same lol
it worked, so
dont bother answering
this is the error im getting
this is the method
the sout(enchant.name) prints efficiency
the sout(enchant.getname) is null
but its an enum??
how would it be null
im setting the velocity of an itemdisplay but its not moving
do i need to make an armorstand and have it constantly teleporting to it or something
Does it have gravity?
oh no
Idk if this is true for itendisplay but u know for armor stands it’ll ignore velocity
If no gravity
Guessing it’s the same
Since inherited from entity
okay ill test it
Display entities don’t tick
is there any way to translate the enchant name to the display name? for example "vanishing_curse" to " Curse of Vanishing"
So velocity doesn’t work
Display entities also always have no gravity because they don’t tick
It’s not vanilla enchants they’re my own
I just kept the name efficiency
im not answering you
im making my own question
is there a way to do that
in vanilla?
Oooh
I don’t know if there’s a specific method for it but you could loop through all the enchants
And check the name
best i found is this
https://www.spigotmc.org/threads/looking-for-the-in-game-enchant-names.290133/
which is a long ass switch
There’s a Enchantment.getbykey method
1,7? who hurt you
No one did lol
I was trying to compile 1.7 plugins like for 1.19.4 with maven
(Terrible idea)
Just a why not lol
anyone know why this is happening?
How can I enchant an item that can't normally be enchanted? I tried using this
item.addUnsafeEnchantment(Enchantment.LUCK, 1);
but with no luck.
get the itemmeta and do addenchant(enchant, level, true)
cheers
so I'm creating a zip file at runtime
how can I hash that zip file for client side comparison
also running into a strange issue
if the player rides an itemdisplay then it can't move
Typically you would grab the bytes of the zip and hash that
ah
amplifier goes 0 = 1 in game? or 1 = 1 in game?
k
bro im so confused
only thing i can think is cuz its storing tier and im accessing it from tier its a self reference?
but wouldnt that give me an error in the ide
idk
that was not the problem,
so for some reason whenever I teleport something that has a rider
it just won't move
I don't understand
when I remove the rider it moves just fine
does anyone know what could cause this
idk how smooth this would look but
try removing the rider
teleporting
then setting the rider back
oh I see I just googled and someone suggested the same thing
and then someone else suggested nms
which I might do tbh
It appears you need to have a range clamp
When I send my Intelij project to a jar, it doesn't include my plugin.yml or my config.yml in the jar... how do I fix this?
Since statics are not null the only thing that could be null is their value
Well pretty sure that applies to enums too
What is a range clamp
Means you dont allow it to go below or above certain values
Ah
There isnt 100 enums for tiers for example
So having a random number of 100 makes no sense
But yeah getting a returned value of null wont throw an exception since this is allowed
Its only if the object your accessing is null will that happen
can someone help me with this please? :that I can't get it to work, it tells me that it didn't find the dependency
"Dependency 'com.theokanning.openai-gpt3-java:api:0.2.1' not found"
<dependency>
<groupId>com.theokanning.openai-gpt3-java</groupId>
<artifactId>api</artifactId>
<version>0.2.1</version>
</dependency>
did you reload maven?
0.12.0 is the version number
I think I need glasses :C
thanks: 3
I'm ready but still it doesn't matter :c
import io.openai.api.OpenAI;
import io.openai.api.models.CompletionRequest;
import io.openai.api.models.CompletionResponse;
"Cannot resolve symbol 'openai'"
do you know why this happens? :c
how do I include lib with maven module?
<dependency>
<groupId>com.theokanning.openai-gpt3-java</groupId>
<artifactId>api</artifactId>
<version>0.9.0</version>
</dependency>
like shading a dependency?
use the maven-shade-plugin
You posted your poms and indicate you have an issue with shading but no details we can work with. Like what isn't being shaded
I didn;t notice the time difference.
working w fuckin JS rn and for some reason fuckin clearInterval just is not doin anything
am i not allowed to call clearInterval inside of setInterval or something
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
i know 
Get JS'd
true
(function() {
'use strict';
let intId = setInterval(() => {
let closeBtn = document.querySelector('svg[aria-label="Close"]');
if (closeBtn == null) return;
closeBtn.parentElement.click();
console.log('closed Meta prompt.');
clearInterval(intId);
console.log('cleared task');
}, 1);
})();```
There shouldn't be a difference?
the context of the prompt is this stupid thing that shows up when ur editing ur profile on instagram btw
well what if my internets like really bad yknow
that page load could outlast the timeout window
no bc the interval is waiting for the element to exist in the first place
well
/waiting/ by running itself every 1ms and checking
Ah right
Just defer the js loading and use setTimeout
That way it will be loaded after html
its a tampermonkey script so ill have to experiment with run-at times
document-end should work
but instagrams also kinda like fuckywucky and has a loading screen before actual content
so there might be a not technically ready "html loaded" event
fixed it by adding a little bit of delay before i clearInterval i guess
Hi, I had an idea for protecting my plugins (not on Spigot), it's possible to check modification while the plugin is running so that if malware modifies some classes or adds it the server can be stopped and executed some protection?
you could crc your classes
what's that?
but anything you do can easily be removed by malware
crc = a checksum of your class.
and how can i implements a system like this?
with reflection?
you can read yoru jar and crc check each class.
there is also the new security manager in java, but I've nto used it
they are doing a CRC on a file, you could just do it on each class.
yes, as you are wanting to check for in memory modification using the ClassLoader would be best
ok that's one thing but checking if the checksum is the same as should, I'm sorry for making too many questions and just seems like spoon feeding but I never actually thought this would be possible, or can be a system actualy checking for the jar hash so if it is the same the plugin runs?
the CRC is just a number so you check it against whatever you calculated that it should be
sorry for asking but if a malware runs and changes class in theory the hash should change?
yes
so i need to check the hash and can be an actual good system
if the hash are the same then it can run
however, if someone is going to the effort to change your classes they will just disable your CRC check
so let me understand one thing CRC is hash?
yes
or something totaly different
kinda
a hash is less accurate
a CRC is a calculated value of every byte in yoru class.
so i should calculate crc before the plugins run in a machine and then compare them?
yes, you calculate the CRC before release. you include those values in your code (encrypted) then compare when it runs.
sorry for asking but i cannot pull classes bytes but i can pull their name its just the same? or how can i work to get them?
no
yes you can read classes
the stackoverflow even showed you how to read it from teh ClassLoader
the CRC demo I linked shows you an example of how to calculate a CRC from a file
it's just a bunch of bytes
i run into weird problem pretty sure my constractur is good
wait ill provoide code
?paste
inside the constractur?
i put it into the method instead
bruh i did the same with like more 400 lines of code at other classes
ill have to init() guess
thanks Goskii88
Is there a way to set time personally?
For instance, simultaneously player A is day time but B is night time
There is the Player#setPlayerTime but not sure if it's what you're wanting or not.
Thx that's what I wanted! let me try 🙂
How do I know the server's max health? (The value inside the spigot.yml)
Thank you
hey yall, i'm working on a fork of a plugin. I had help from the main dev in setting up everything, however, some errors keep popping up. It is very annoying, as NMS always is. I hope to get help, as that would be very nice. Here are some screenshots
here is the java file
hello looking for a dev to help me make server
if you want anyone to actually propose to help you, you should firstly describe the task
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Paste ur pom
?paste
Not downloading
Hello, how can I call a method 20 ticks before the world unload ?
you want to predict the future?
exactly x)
or maybe I can make cache for what I want
omg don't you fucking love it when you paste 2 lines in intellij and suddenly it freezes and loads the cpu to 90%
?xy
Asking about your attempted solution rather than your actual problem
My old pc be like
oh yeah, thats fun
this shit has been upgraded recently but it happens nevertheless
ok now it's reindexing jdk
cool
that's normal
I open any jetbrains ide and my laptop converts to a helicopter
lmao
i still love intellij more than anythint else
even though this sometimes happens
It's a-simple
Edit spigot to run the world unload 20 ticks later, and when you schedule it run your code
ez
okay thanks
LMFAO
Don't do it like that lmfao
Use a world unload event, cancel it if the world is not marked, run your code, mark the world, schedule unload 20 ticks later
Might not work on shutdown
guys wich language should i chose to minecraft development i was learning java and im not sure if i should keep up to it since its become an outdated version
what other options do i have besides java
kotlin etc?
or optionally Java
oh ok
Kotlin is a mess to deal with and bloats your plugin size by the MBs
i get it
wdym outdated btw
java is not used for android development for example
thats not what i meant
A lawsuit by oracle made that happen
all programming languages recieve updates
It was used before that
doesent mean they are an moder programming languges
Then they made jetbrains (creators of IntelliJ) make kotlin which is based off of the JVM to not get lawsuits
what i mean by outdated is that there are better options rn
i get it that for minecraft for sure its the best
Well java is still a pretty solid one actually
yes it was and google announced that java wasnt the main one anymore it was kotlin now
It's getting many perf/syntax improvements
Uh... it is though
Nope
I use it for android development
It's all I use for Android
i meant its not the best one anymore
Oracle made a lawsuit on Google a while back, it still can run Java because it's just the JVM
Java is literally one of the main languages for Android development
They just couldn't actually use Java at Google for android
If you want an eyesore unmaintainable project
or configuring gradle ig
Exactly 13 days ago lmao
for android
For that logic what about Scala
and i tought it would be that for the others
No java is still a industry standard for many things
And it will never go away much like C
^
well i hope so
so i wont be unnecessarly learning a language i could replace with something better
im not planning on doing android development anyways was just double checking if java would still be a nice language for pc
java is still super useful
Yep
and its the only viable option
for mc dev
except if you want to become a datapack programmer
which is an awful lang
Clojure
It's just mc commands though
It's not even a lang
true true
but it can count as a language
as it is turing complete
its just a pain
fair
This dude
He would use mc as a runtime
Ah and btw what are they exaxlcly trying to do with bedrock i have been away from MC for a while and now both versions are free while bedrock is called bedrock and Java is called minecraft Java edition?
Are they trying to replace a version or wsp
I wouldnt be suprised if they made it the main one every single thing innit u have to pay for it lol
They kinda try to get Java away from the status of the main version. They want their bedrock trash because they get more $$$, kinda lol
I rly hope it never happens man
Th going on here
hey, does anybody know what would be the best way to make a creature spawn particles around it? To be exactly I want to some of the cave spiders naturally spawned have a special drop and a player would know that spider is a special one by the particles around it
The first thing I thought is to achieve that with listeners, so using a CreatureSpawnEvent I would mark a cave spider as a special one and then do the particles thing
but I don't know if it's a good way to achieve that
That's the correct way to do that
hello, what is the event for a block being activated because of redstone, and how can i get the location of the redstone that activated it ??
There is a block state event iirc
no
alr, thanks 🙂
did you forget a { } ? can;t tell as it's just an SS
your else if doesn;t start with a }
this code is a mess first of all