#help-development
1 messages ยท Page 1658 of 1
NMS requires Java 16 in 1.17. Compatability might be difficult. (You will need reflection here)
^^
Oh. I indeed use NMS (1 gradle submodule per NMS version)
Yeah you need a reflection module for 1.17+
So reflexion will be the only way to avoid using Java 1.16
@waxen plinth this is my issue
+
/ \
2 3 # where to put the '*'?
ok
2*3
thank you ^^
No
You're trying to evaluate it once, right?
yep
no rhats where I fail
what even is this
the multiply is overwritten by +
Stop
Just put the tokens in order in a linked list
1+2*3
[1, +, 2, *, 3]
Start there, okay?
ok
Let me know once you've done that and have your tokens in a linked list
Linked lists are usually useless, but they have a few special properties that make them really good at this specific thing
Alright
Now, here's what makes linked lists useful
We're going to iterate over the linked list looking for operators of each priority
I don't know if you have a priority system set up, but you're going to need it
Just assign each operator a priority, with operators that should be applied first having a higher priority
So * and / should have a higher priority than + and -
hi im working with the maprenderer and map api
is render ultimately called by the main server thread? and what does that function actually do?
Now, the most basic way to approach this is to iterate over the list once for each priority we are looking for
The only good thing is O(1) complexity on removal while iterating. They are trash otherwise.
Yep
Makes em super useful for this though
I can explain how to do it faster later, imagine, but for now we're going to do it the simple way
Iterate over the list once for each operator priority
So we start at the highest priority there is, let's say you've given a priority of 10 to * and /, and a priority of 5 to + and -
You'll loop over looking for operators of priority 10, then 5
When you reach an operator token with priority 10 on your first loop
Yes rendering is called by the main thread. Thats why you should render static images only once and use a hashed cache for dynamic ones.
ye
It's very simple, you just look at its neighbors
thats what im doing i was just curious
So you have the * in here
Its neighbors are 2 prior to it, and 3 following it
So all you need to do is remove its neighbors and replace the * token with the result of 2*3
Which is 6
So you end up with [1, +, 6]
how does the canvas work, does it send the image to the client when the client is near (and call render to grab the image?)
Then on your next iteration, you find the + and do the same there, replacing the 2 value tokens and the operator token with their result, and it becomes [7]
this is O(n^2) though right
This sounds like a challenge from CodeWars. Is he trying to write an arithmetic evaluator?
im gonna start with math eval then expressions
He is
You're already doing expressions
Just, strictly mathematical ones
It does get more complicated once you throw more types in the mix than numbers
You need to keep track of which operators to use based on the types
like does render create the image packet once for each individual client, or does it call render to create a single one and distribute that packet to whoever comes near
?paste
and if its the first is it possible to cache that packet because the maps images i render never change
if its the second then its whatever
the packet?
https://paste.md-5.net/qudaporewu.java
https://paste.md-5.net/qudaporewu.java
can someone help explain to me why my plugin is not working
no buffer
the packet you can't
but the data that is send yes
maybe packet listener?
oki ill look into it
i just dont want the main server thread reencoding the same packet a billion times
ty
microsoft please fix :((((((((((((
thanks ๐
oh LOL
missing command from plugin.yml
oh yea
https://paste.md-5.net/qudaporewu.java
https://paste.md-5.net/qudaporewu.java
can someone help explain to me why my plugin is not working
oh also arithmatic expression thing
class name with lowercase?????????? SERIOUSLY?????
yes i am a phycopath
Not working, is not enough to go on
this also explains why u use NOT safe and NOT cross-version NMS without any wrapper
see if it works
arithmatic expression parsing u could just try converting it to like rpn or some other ast and then process it i think thats linear time
We could start at teh beginning.
way easier than whatever random stuff u do with trees and nodes and whatever
elgar
do u know how do i remove a certain element from a config file
like
'- SOMETHING'
I wanna delete it
yeah but idk the path
if its an element in a list, you remove it from the list and then set teh list
yeah but idk the pathhhhhhhhhhhhhhhh
You need to know the path
Hello, it's possible to automatically fill the version on plugin.yml with the gradle version variable from the build.gradle please ?
@quaint mantleyeah if you want to do in linear time just implement shunting yard and then once its in postfix its easy
how do you enable/disable hardcore
int counter = 15;
for (int i = 0; i < stringbuilder.eventScoreboard().size(); i++) {
StringBuilder current = stringbuilder.eventScoreboard().get(i);
Team team = scoreboard.registerNewTeam("team"+i);
if (current.length() <= 16 ) {
team.setPrefix(colors(current.substring(0, current.length())));
team.addEntry(ChatColor.GRAY+"");
objective.getScore(ChatColor.GRAY+"").setScore(counter);
} else if (current.length() <= 32) {
team.setPrefix(colors(current.substring(0, 16)));
team.addEntry(colors(current.substring(16,current.length())));
objective.getScore(colors(current.substring(16,current.length()))).setScore(counter);
} else if (current.length() <= 48) {
team.setPrefix(colors(current.substring(0, 16)));
team.addEntry(colors(current.substring(16, 32)));
team.setSuffix(colors(current.substring(32, current.length())));
objective.getScore(colors(current.substring(17,32))).setScore(counter);
} else if (current.length() > 48) {
team.setPrefix(colors(current.substring(0, 16)));
team.addEntry(colors(current.substring(16, 32)));
team.setSuffix(colors(current.substring(32, 48)));
objective.getScore(colors(current.substring(17,32))).setScore(counter);
}
counter = counter - 1;
}
``` so everything works but when setting the score this happens....
it skips some lines
on the loop
for somereason
it supposed to print the whole lines
What are you trying to remove?
a player name from the whole config
you shoudl never have a player name in the config
my config would look like this:
Teams:
TEAMLEADER:
- GUY1
- GUY2
TEAMLEADER2:
- GUY 1
UUIDs
^
still how to remove it
yeah i know thaat bs of ppl changing their name
but i clear the config each server restart either way :/
is it a teamleader you are trying to remove?
yeah but i dont know the path
my thing is still broken
like i dont know who the team leader is
if its a member in the list, you need to get teh list, remove the member adn put the list back
yeah and getKeys(true)
then loop the keys of leader lists
but idk how to remove it
getStringLIst
and remove the player from inside it
and put it back
afaik there's no way to remove dynamically from config list
in bukkit api atleast
idk mannn
anyone has an idea of how can i make a teams plugin in a better way
its like a /party plugin basically
why do you not cache the teams
but with some special stuff
store the uuids first of all
instead of having it in config
why put them in the config if they are only for a session?
no
well you can save
so why set to config?
they get wiped on a restart so no point in storing them in the config
then why tf are you saving it into config
a List
if you have a leader Map<UUID, List<UUID>>
LinkedList is good for adding removing but not searching
Map is the fastest
but requires abit more memory
nwrgjnoaojgjagojbagragbrjagbrjagbrjagrjboaaogrgggga
Yay! I have to recode 10 commands again!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
LOL
arent u a "Minecraft Plugins Dev (Java)"
jeez
Only store things in a file/config/database that you need to access across server starts
yes but it doesnt mean im good
most ppl here are plugin devs
but r they all good
no
and if ur not helping, take ur ass outta here :D
if you say that in your bio i'm assuming your at least mediocre on that and don't commit very beginner mistakes with coding
but thats just my opinion ๐
Do you access these Leader list and locations outside the commands?
your opinion is not appreciated, frick off
then simples, create a BaseCommand class
wut
in that class you add a private static Map<UUID, List<UUID>> leaders = new Hashmap<>();
that way you would only get that variable for that extended classes only
o
then make all your commands extend BaseCommand
BaseClass [private static Map<UUID, List<UUID>> leaders = new Hashmap<>();]
YourCommandClass [has the same hashmap, but other non extending classes doesn't]
remember its static so only one instance ever will be created
static would make sure that it wouldnt instanciate every time
that's what i was gonna say lol
๐
well its just like static in c, but could be read from multiple translatable units
why my codes skippes a few lines
xd
@eternal oxide sorry for being so annoying, but can u give me an example of a party create command with mechanic, so i get familar with it
You are using scores so I guess you set those to zero
sorry for being so annoying
@grim ice
public abstract class BaseCommandExample implements CommandExecutor
{
@Getter
private static Map<UUID, List<UUID>> leaders = new HashMap<>();
}
public class CommandExample extends BaseCommandExample
{
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, String[] strings) {
getLeaders()//do shit
return true;
}
}
this is rougly what the guys mean
well yeah but you didnt implemented getter there
what solution i could do then
oh
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase("enablehardcore")) {
if(sender.isOp()) {
// hardcore setter
if(sender == Bukkit.getConsoleSender()) {
System.out.println(ChatColor.RED + "Hardcore enabled");
}
else {
sender.sendMessage(ChatColor.RED + "Hardcore enabled");
}
return true;
}
}
return false;
}
why is this not triggering when i do /enablehardcore
that's a lombok
(also btw does the color thing work for println)
yea i used lombok for ease. sorry for any confusion
well you need to put the command in the yml file
i did
Don't use if sender == console sender, use if (!(sender instanceof Player))
aka set executor
?paste
public abstract class BaseCommand implements CommandExecutor {
protected static JavaPlugin plugin;
protected static Map<UUID, List<UUID>> leaders = new HashMap<>();
}```
why plugin is not static
yes
it shoudl be
thats because you return false
Yes
i think there is sonmething wrong with my main and i dont know what it is and why it is not working
Only if class - executor
well yea
i did and also changed the other thing to return true but it does the same thing
@grim ice Then each of your commands ```java
public class TestCommand extends BaseCommand {
public TestCommand(JavaPlugin plugin) {
TestCommand.plugin = plugin;
}
}```
It will tell you implement missing methods
auto compete it and its done
why are you checking if the sender is OP and if the sender is a console sender?
if its a console sender obviously it has OP
but it just does the same for both cases
And also
It's same messages
Just if !sender.isOp() return true
And after that send your message
o
but i meant
tthe usage of the lists
and hashhmaps
get them made first
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender.isOp()) {
// hardcore setter
sender.sendMessage(ChatColor.RED + "Hardcore enabled");
}
return true;
}
so i changed my code to this but theres no difference
it still prints white in chat?
both just say /enablehardcore in chat
(both console and ingame btw)
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!sender.isOp()) return true;
sender.sendMessage(ChatColor.RED + "Hardcore enabled");
return true;
}
if (leaders.containsKey(player.getUniqueId())) {
List<UUID> members = leaders.get(player.getUniqueId());
members.add(newMember.getUniqueId());
}```
o
still just sends /enablehardcore in chat
why can't I pass a ModUpdateData to a function taking T extends ModUpdateData as a parameter?
me?
Yes
to add a leader is similar, test if they don;t exist then leaders.put(player.getUniqueId(), new ArrayList<>());
the whole thing or just the class
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!sender.isOp()) return true;
sender.sendMessage(ChatColor.RED + "Hardcore enabled");
return true;
}
whats ss
hes fine
lol
o
No I can't I have bad screen now
Oh yes
is this some kind of calculator evaluation engine
Do you have an @override?
Great
Google your question before asking it:
https://www.google.com/
declaration: package: org.bukkit, interface: World
So the next step
no xD
Set it
o
How
says @Override not appicable to typw
You iterate, storing each operator's linked list node in a list
Then you sort by their priorities
Then combine with their neighbors just as you did before
Easy!
Your onCommand method in main class?
One iteration, much faster
no
are you implementing CommandExecutor
^^
yes
Whut
package com.tristandasavage.halfheartsurvival;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@Override
public class Commands implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!sender.isOp()) return true;
sender.sendMessage(ChatColor.RED + "Hardcore enabled");
return true;
}
}
nah over onCommand
ahh
You implemented a linked list, no?
yea above onCommand
LinkedList<T>
Its just holding tokens rn
But is it a proper linked list?
With nodes that store the value and point to the previous and next node?
still all it does is say /enablehardcore in chat
its a fucking linked list
Yes
java.util
<Token>
even with the @Override and implement and stuff
I thought you were doing this in python?
kotlin
Ah
For this you will need your own linked list implementation then
Because you need access to the nodes
And java's LinkedList does not expose them
still not working
class TokenList extends Stack<Token>
What
aight send how youve got the class right now
Would that give you access to the nodes
k
I can't imagine a stack is doubly linked
wdym by that
just send the class again
k
package com.tristandasavage.halfheartsurvival;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class Commands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!sender.isOp()) return true;
sender.sendMessage(ChatColor.RED + "Hardcore enabled");
return true;
}
}
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
its legit designed for tokens I could imagine
seems correct to me. can i see your plugin.yml
Yeah that's not what you need here
You need a linked list with nodes that you can access and store
the plugin.yml works cuz i am able to do /help with the command
and its one of the suggested option things when you type /enable in mc
k
can i see the cmd registration
wdym
commands:
enablehardcore:
description: Enables hardcore in the current world
usage: /enablehardcore
enablespawnprotection:
description: Enables 5 second invincibility after spawning
usage: /enablespawnprotection
disablehardcore:
description: Disables hardcore in the current world
usage: /disablehardcore
disablespawnprotection:
description: Disables 5 second invincibility after spawning
usage: /disablespawnprotection
lol the only one im using is enablehardcore for test
?
yea
o
show in your onEnable() registering executor
getCommand("commandname").setExecutor(new ClassName());
public void onEnable() {
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
instance = this;
this.logger = this.getLogger();
this.logger.log(Level.INFO, "Half Heart Survival v1.0 has been loaded!");
Bukkit.getServer().getWorlds().get(0).setGameRule(GameRule.NATURAL_REGENERATION, false);
}
o lol
-,-
and where registering command ._.
๐คฎ having multiple commands just to toggle something
you have a truly inspiring about me section
xD
wasnt that one of the first things we asked. wether or not you registered the command?. haha
idk
what did you add
i did register it
show
ill need to create screenshot where i said SHOW
?
show code
bruh
bruh
"a"
do you
replace a
?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.
by your cmd name
lol
i am so stupid
yes
are you new to java on top of trying spigot? 
should learn java before trying spigot, you wont learn core java knowledge using spigot
^^
As I always say; The only hard part about Spigot is knowing Java.
wise words
World w = Bukkit.getWorld("world_active");
for (Chunk c : w.getLoadedChunks()) {
for (BlockState b : c.getTileEntities()) {
if (b.getType() == Material.CHEST) {
chests.add(b.getBlock());
if (b.getY() == 126 || b.getY() == 118) {
addLoot(b, LootTable.ISLAND);
} else {
addLoot(b, LootTable.MIDDLE);
}
}
}
}```
why doesnt that work
@waxen plinth walk me through this
only a few chests have items put into them
Bukkit is also an ass api in general too tho
use b.getBlockY()
But not knowing Java makes it worse
etc
Lol
the problem is that it sometimes doesnt add any loot
middle loot works fine
Later
try with getBlockY
lol
ive already googled didnt get anything
?google how to enable/disable hardcore mode spigot
Google your question before asking it:
https://www.google.com/
mhm
all it is is crap about how to enable hardcore on a server
but its not using plugin
just server.properties
im fairly sure its not possible with the api itself. it might be using nms though but my brain isnt big enough for that
Does it on load up
๐
yea that would be possible
i do not know why my thing is not activating can anyone help
thing
-- not activating
very description
whats supposed to happen ๐
why events in main class
and main class named Main
because the guy does not confirm to society
fuck ur thread
why're you implementing listener on your main class when it has javaplugin 
Fuck you
i did not fell like making another class
harsh words are harsh
still nothin
Busy teaching someone how to use redlib
also why is your event called onDeath while its an EntityDamageEvent
bc is was originaly supposed to be on a death
but its entityDamageEvent
i got it to work
perfect
is there a command like /kill @e [type=!player] to kill a npc
or do i have to reload my server
loop the leaders lists
o
so check each list.contains
to kill players without npc, just check if current player hsa metadatakey "NPC"
yeah but i need the team leader uuid
no you can loop the keyset
o
Does someone know a program that is able to check a folder on Malformed JSONs? I have a resource pack full of jsons, deleted the ones I donโt use, validated the ones I edited all seems fine but it keeps giving me a Json malformed error.
boolean found = false;
for(UUID key: leaders.keySet()) {
if(leaders.get(key).contains(player.getUniqueId())) found = true;
}```
fixed ๐
btw
another quick question
how to check if the for loop found anything with the if requirements
OH
I GOT AN IDEA
int i = 0;
i++;
ezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
why do you need an index?
what are you doing with the search?
if you just want to check if they are in any of the lists boolean found = false; before the loop, then in the loop if found = true;
World w = Bukkit.getWorld("world_active");
for (Chunk c : w.getLoadedChunks()) {
for (BlockState b : c.getTileEntities()) {
if (b.getType() == Material.CHEST) {
chests.add(b.getBlock());
if (b.getY() == 126 || b.getY() == 118) {
addLoot(b, LootTable.ISLAND);
} else {
addLoot(b, LootTable.MIDDLE);
}
}
}
}```
why are some chests not having items added
yeahh i guess
idek how to return your favors man
like isLeader, hasGroup, getLeader(Player member)
] - '&b,
how do you do this.getConfig inside of a different class
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
so I am replacing - ' with - "
first one
in string
and from some reason it wont replace it
any ideas
bump
its a regex match so escape the `
with \
yes
I'm getting an error when more than one person joins a server, I can't send pictures though
not working
I guess not
well any other ideas
Thats like saying my grandma died, and asking how she died :/
If you are using paper you could set max joins per tick to 1
Works for me System.out.println("-' &b".replaceFirst("-'", "-\""));
u don't have space
- '
betwean
Still works System.out.println("- ' &b".replaceFirst("- '", "-\""));
try it here https://www.online-java.com/
[Disconnect] User MerryArbo has disconnected, reason: Internal Exception: java.io.IOException: Error while read(...): Connection reset by peer
Spigot 1.8.8
spigot 1.8 not supported here
We got it. He didnt save the methods result in a new variable. String immtability.
well I can tell one thing for sure I am an idiot
yep
๐
seems like a me thing to do
just got of work after 12h
bump
Because some chunks are not loaded
how do i load em
they are all chunks around 0,0
Why not? That's like the most used version of spigot lmfao
Those are some dangerously hard coded conditions you got there. I think you should just use the PDC of the Chests
and make a command that adds the PDC tag to a chest.
You can get Chunks by calling World#getChunkAt(int, int)
https://bstats.org/global/bukkit i beg to differ
No its not. Not even close. Its really old and only a minority of people use it.

what smile said
Whattttt
Its also bug infested, lacks a LOT of API features and wont ever be updated. Developing for that version is a hustle.
There are even more 1.12 than 1.8 servers now XD
yup
and donโt you even dare say that hypixel uses 1.8 or whatever - hypixel uses a jar so dissimilar from spigot that it is completely different story
a solid 0.3 percent but still he ๐
paper ftw
Yatopia 
Did you change name?
myeah
You donโt actually use that right
๐
Uh lol yes perhaps
Is there a server where I can get support?
No
StringBuilder message = new StringBuilder();
for(String arg : args) {
message.append(arg);
}
;-;
so yk how when you go to break smth with a sword in creative it does nothing?
You can probably find your issue in old forum posts. Sometimes people here also still give some support for 1.8
Ye
could also use StringUtils.join() for this
and triggers "BlockBreakEvent"
Doesnโt String.join exist?
Yeah
probably
Tho idr if it took regex only
but i use my own join method so i was just looking for one lmao
o
any ideas why it triggers blockbreakevent?
Thatโs weird
Maybe it also tracks break stages?
maybe?
I had a weird bug with one of my plugins where somehow ops could break blocks with a sword
it was wonky as fuck because I had no idea why it happened, and I couldn't reproduce it on my dev server.
@chrome beacon btw should I import spigot-api 1.13 too ?
- You told me 1.13 api + jdk 8.
- Direct access is possible for NMS pre1.17 (within my NMS submodules that include full spigot server as compileOnly dependency)
- Since accessing to java 16 compiled classes with java 8 will fail, 1.17+ NMS can only be done using reflexion
But in the main project, what spigot-api should I include as dependency ? 1.13 ?
i use 1.13
so my code console logs the lines read frm scoreboards.yml but it doesn't display more than a few lines on the scoreboard
ok ty
int size = stringbuilder.eventScoreboard().size() + 1;
for (int i = 0; i < stringbuilder.eventScoreboard().size(); i++) {
StringBuilder current = stringbuilder.eventScoreboard().get(i);
Team team = scoreboard.registerNewTeam("team"+i);
if (current.length() <= 16 ) {
System.out.println(current+"Current: "+current.length()+ "Index: "+i);
team.setPrefix(colors(current.substring(0, current.length())));
team.addEntry(ChatColor.GRAY+"");
objective.getScore(ChatColor.GRAY+"").setScore(size);
} else if (current.length() <= 32) {
System.out.println(current+"Current: "+current.length()+ "Index: "+i);
team.setPrefix(colors(current.substring(0, 16)));
team.addEntry(colors(current.substring(16,current.length())));
objective.getScore(colors(current.substring(16,current.length()))).setScore(size);
} else if (current.length() <= 48) {
System.out.println(current+"Current: "+current.length()+ "Index: "+i);
team.setPrefix(colors(current.substring(0, 16)));
team.addEntry(colors(current.substring(16, 32)));
team.setSuffix(colors(current.substring(32, current.length())));
objective.getScore(colors(current.substring(17,32))).setScore(size);
} else if (current.length() > 48) {
System.out.println(current+"Current: "+current.length());
team.setPrefix(colors(current.substring(0, 16)));
team.addEntry(colors(current.substring(16, 32)));
team.setSuffix(colors(current.substring(32, 48)));
objective.getScore(colors(current.substring(17,32))).setScore(size);
} else {
}
System.out.println(size);
size = size - 1;
}
``` why isn't it displaying
is it supposed to automatically go to the next line or something?
it has so much repeated code. you should really make a method to handle some ofthat
how do i get the locations iwthin a chunk?
String message = String.join(" ", args);
i saw that maybe the if less than 16 chars is repetitive and that might be a problem
but what are you trying to achieve right now
so its working now?
if (current.length() <= 16 ) {
System.out.println(size);
System.out.println(current+"Current: "+current.length()+ "Index: "+i);
team.addEntry(colors(current.substring(0,current.length())));
objective.getScore(colors(current.substring(0,current.length()))).setScore(size);
} else if (current.length() <= 32) {
changed
the line
instead of being the entry empty
i made it
works flawless
thanks
you should still make yourself a method to handle the substring shit along with color
will be much cleaner
am going to make that later
alright. well good luck
thanks people
what do you mean by this
like the corners of a chunk or something?
just check to see if a location is within a chunk*
well then just compare the chunk coordinates
ok
i actually stated that in past i guess, but... what is the fucking reason for it not showing in "autocompletion"?
thats not for this specific case only, it's often occuring for random classes
maybe just intellij bugs
honestly i hate the new versions
i still use 2019
its the best
i guess Xd
i have a pretty solid rig. but still had problems. so i gladly reverted back to 2019
tbh, if eclipse wouldn't look like a messy 2012 app, i'd probably switch
intellij lets me hate it more every day
not me. i think eclipse is even more shite ๐
well, eclipse works at least
seems like a dilemma ๐
or is it a general thing that stuff from gradle libraries doesnt appear in autocomplete list
but i have encountered classes not showing up either. but for me it was only when i just added a library
after id use 1 import it would then autocomplete any more
Install teh plugin DevStyle for Eclipse
same for this one if not imported already
devstyle doesnt make eclipse look good
it makes it look better
but better doesn't mean good
and tbh, it's not hard to make eclipse look better
am i the only one using a background on my ide? haha
Settings > apearance & behavior > apearance > background image
doesnt outdo this for me though
now i'm getting more weirdo again, yessir
lmfao
Backgrounds are for desktops not programs ๐
cap
I'd find them distracting. Give me a nice blank page to write on
^
imagine intellij would for example remove themes because someone says themes are for desktop environments
or remove dark mode because someone says light mode is better
Its not about removing if it never had it in the first place
then replace my remove with never added
imagine using discord light mode ๐ ๐
discord light mode be like nuclear bomb
i remember using a gif background in intellij
but removed it as it lagged my pc to hell somehow
yeah kinda
but tbh, it's distracting enough to see YoU WaNnA ShArE YoUr aNoNyMoUs dAtA? like every 5 seconds
dunno why it does that for me
it often just shows random popups again for me, idk
because NETHER_BRICK_ITEM doesn't exist afaik
afaik, it's NETHER_BRICKS
it should be NETHER_BRICK. NETHER_BRICKS would be the block type
hello all!
I had a quick question about Bungeecord! So if I have two servers, each set in their individual server.properties to have their player limit at sayyyy 50 players.
and then in my Bungee proxy I setup my priorities section in the config.yml
Once Server1 is full of players, will bungeecord auto redirect players to Server2?
More specifically, will Bungeecord redirect a player to Server2 as long as they aren't able to connect to Server1 (Like if connecting to server1 fails it'll attempt server2?) Like say they aren't whitelisted on Server1 for example.
I'm just trying to understand how that all works
No its not a queuing system.
It by default sends everyone to the lobby server
then from there you send them wherever you want
i was watching and following along with this video
https://www.youtube.com/watch?v=sdHi5N7-Yqk
and some of the methods where giving me error messages when i tryed to use them can anyone help
Ask specific questions and probably
ok
btw does anyone know where that image of slot numbers is
for player inventories
private final Player player; this does not work
okay for sure, so I'd need to grab a plugin to handle that, any suggestions?
I've found this one which seems pretty solid
https://www.spigotmc.org/resources/redirect-plus.51975/
36 i think
There are tons on google
?
That would work, but you would have to assign it a value in the class constructor
final fields have to be assigned at definition or in the class constructor
how i dont know how to do that
@earnest lark heres a code example
ok
oh
tbh, just this
So if you create a final Field you must either set it when you define it or set it in the class constructor
Channel channel = nmsPlayer.getHandle().b.a.k;```
this is not working
How can I build Spigot without using build tools?
use build tools
Stay well away from nms until you are competent with Java
there is no other way
However that tutorial is out of date to use with 1.17. A lot changed with nms
i looked build tools source code, there is a lot of git command and maven command
duh
There are a few things in standalone section of spigot that build it for you
Use if you want ๐คทโโ๏ธ
Buildtools is easy though
I don't really get what they mean
Why do you want to build it without buildtools?
Actually I want to recompile entire 1.17 to Java8
but I can recompile it
No
and fix the error by my self
it doesn;t work like that
If minecraft uses some new features
You can;t recompile Minecraft
Why is it?
There is far too much that is integral to Java 16 in MC 1.17
It would be like trying to fit a 8 ltr V8 into a horse and buggy
But it still possible right?
Its possible if you had years of experience. But you don;t
I dislike J9+ Module System
And original Spigot don't have a Kotlin Object classes support
You are not forced to use teh Module system
everythign you did on 8 will work on upto 14?
I'm lazy to pass JVM args
You mean you want reflection
The reflection problem
There are ways around some of it but most is a case of getting used to
What part is your main issue?
Like: GSON can't access some fileds
Yes, final fields
I know that can solve by pass JVM args
and it seems there are no plans to work around it
the JVM args is going away soon too
To open that module
yeah
So I want to recompile Minecraft to a older version
Without module system
its going ot be a case of rewite what you need in your plugins to not use final if you want to serialize
it seems like it is actually caused by the libraries not beeing indexed correctly... even a restart doesnt fix it, it can be fixed tho by clicking Invalidate Caches..., followed by an idea-restart
Not that easy
ok i have a npc spawn when a player dies but now i want it so that if i click on the npc it will bring up the inventory of the dead player can anyone help
not on 16 you can;t
But I can't get the unsafe by reflection
You can
I tried every which way and never got it to work
I tried that before
tried sun and everything
And also who writes this build tools
Luckily my issue was with the class loader and spigot implemented a Libraries feature which got around my problem
private static Unsafe getUnsafe()
throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
Field field1 = Unsafe.class.getDeclaredField("theUnsafe");
field1.setAccessible(true);
Unsafe unsafe = (Unsafe) field1.get(null);
return unsafe;
}
That method worked fine for me
Same way to get but error
on a final field?
That just gets the unsafe
I remember Unsafe is final field
?paste
Recompile to Java8 is quite easy for changing plugin code
My plugins are all Kotlin and have no Module System support
And Everytime the main class without a object and is singleton
looks weird
I guess I should just share the entire class, I got the methods from a UnitTest framework after much searching
Edit: Powermock is the framework
What method could I use to update lighting in a specific chunk? I'm looking to do this through 1.17 (NMS is fine).
I'll take a look at that later. Could be handy, thanks.
How would I make it so that if the player's health is 20.0, it becomes 10? etc etc
divide by 2 (can't use troll emote here sad)
That's what I did, but weird things happened with it
I want it to only show things such as 10.0, 9.5, 4.5 etc etc
do you mean you are getting too many hearts or something?
But it's showing things like 5.003 or 5.351
subtract 10
If you are talking to me, nope. When a player is at full health and you get their health, it'll obviously return 20.0, but I want it to scale from 1 to 10 instead of 1 to 20
Maybe is the float calculate problem?
Ye, but what about when the health is at 3-5
or set a health scale
public static double round(double value, int places) {
if (places < 0 ) throw new IllegalArgumentException();
long factor = (long) Math.pow(10,places);
value = value * factor;
long tmp = Math.round(value);
return (double) tmp / factor;
}
This is pretty much what I did, but I'm not sure if it made a difference or nah
It's still showing things like 6.531
If it's 6.531, I want it to only show 6.5
Or just round the output
Using String.format or DecimalFormat or whatever
And if it's 6.003, I want it to only show 6.0
How do I round it with String.format?
Can someone assist me on how I would use CompleteableFutures. I'm using MySQL and have a save method that returns a boolean that I need to obtain for a check. So far I have something like:
public void saveMyObj(MyObj myObj){
CompleteableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> database.save(myObj))
if(future.get()){
//Do something
}
}
Would I just surround it all in a try-catch?
then divided by 10
%.2f iirc, where 2 is the number of places after the decimal
Return a CompletableFuture and then use something like thenAccept
Calling get() defeats the point of using one
So String hp = String.format(health,"%.2f"," "); or something?
Hang on let me view string format docs, kind of forgot to use that thing
https://paste.md-5.net/miwezesore.java
I'm just trying to make a command that opens a GUI for the player (using the example GUI code from Spigot), everything works properly (the GUI opens and the events are working fine, but for some reason the condition to cancel the events (e.getInventory() != inv) is never true in that command
I tested the events by removing the line and it worked fine
Say if I wanted to send a message to the player (i.e. Using the BukkitAPI), wouldn't that cause issues since it would run async? Or will this run on the main thread
I honestly have no idea how to round off the stuff
String.format("%.2f", health)
Hello I'm using the net.minecraft.server library for the first time and I'm a little confused why all the methods and variables have strange names like bV bP etc. Have I added it wrong and if not, how am i meant to know what each one is? Also really sorry if this isn't the right place.
https://paste.md-5.net/miwezesore.java
I'm just trying to make a command that opens a GUI for the player (using the example GUI code from Spigot), everything works properly (the GUI opens and the events are working fine, but for some reason the condition to cancel the events (e.getInventory() != inv) is never true in that command
I tested the events by removing the line and it worked fine
Yeah i think that's what I was looking for thank you!
any help please? D:
compare to top inventory from teh view or clicked inventory
well that's where the problem is
top one is the one it's comparing to, bottom one is the one it has open
but I don't see why it is null, it wrote something to inv earlier
package org.jade.plugins.lifesteal.Commands;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TestKill implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if (!(player == null)) {
if (args.length >= 1) {
if (args[0].equalsIgnoreCase("add")) {
AttributeModifier modifierAdd = new AttributeModifier("generic.max_health", 2.00, AttributeModifier.Operation.ADD_NUMBER);
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier(modifierAdd);
player.sendMessage("test");
return true;
}
}
AttributeModifier modifier = new AttributeModifier("generic.max_health", -2.00, AttributeModifier.Operation.ADD_NUMBER);
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier(modifier);
}
return false;
}
}
When I try to add more hearts... it wont. Whats going on?
I assume the test message gets printed?
what error are you getting
no error
yes
Interesting
The vanilla one?
ye
Do you have other plugins that may be interfering?
this is only plugin
Is your spigot up to date?
yep
Weird client that might be messing with it?
wait one second
when i use
the /testkill add command
than try to add attribute vanilla way it does add one heart
and that is what the testkill command does...
why isnt it updating than? and why cant i change it to lower or higher
What do you mean lower or higher
like testkill add only adds 1 heart and when i use vanilla after that it shows that one heart but when i try to use vanilla to set it to 10 hearts it just doesnt
nvm now it is working..
wierd
Inventory inv = Bukkit.createInventory(null, 27, "asdasd");
public void onInventoryClick(InventoryClickEvent event) {
if (!event.getInventory().getName().equalsIgnoreCase("asdasd")) {
return;
No
thats unreliable and dangerous if anither plugin interferes
if you want it to be impossible to pick up and put items in the gui - event. setCancelled(true);
public abstract class PluginInventory implements Listener {
abstract Inventory makeInventory();
abstract void onClick(InventoryClickEvent event);
private final Inventory inv;
public PluginInventory() {
inv = this.makeInventory();
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (e.getInventory() == inv) {
event.setCancelled(true);
this.onClick(e);
}
}
}
that's just the same as I already had
also it needs to support multiple players
cleaner, expandability, abstractation, yours should work
problem
it doesnt
is it registered?
what if another inventory is created in another plugin called inv?
I am currently trying to add all inventories created by the custom gui command to a list and check if they are in the list in those events, but that gives me weird behaviour
tf you mean its private
someone else will help ill brb
public class GUI implements Listener {
public static void openGUI(Player p) {
Inventory inv = Bukkit.createInventory(null, 27, "Name");
inv.setItem(0, ItemUtil.create(Material.STONE, 1, (byte) 0, "Name-item", "null", null, null, null));
p.openInventory(inv);
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack clickedItem = event.getCurrentItem();
if (!event.getInventory().getName().equalsIgnoreCase("Name")) {
return;
}
if (clickedItem == null || clickedItem.getType() == Material.AIR || !clickedItem.hasItemMeta()) {
return;
}
event.setCancelled(true);
if (!event.getCurrentItem().getItemMeta().getDisplayName().equals("Name-item")) {
return;
?paste
no, that is not a unique identifier
in sense


how bout now
