#help-development
1 messages · Page 1886 of 1
Persistent Data Container?
?pdc
is there a way to make a lot of if statements cleaner?
switch statements and early return
what's that
it all depends on yoru if requirements.
is there smth special you want to get cleaner ?
If possible a Switch statement is much cleaner, The early return is exit out as soon as possible if you know you can
Lastly, if you are reusing the same test over and over in different places, don't, use variables
List<PermissionTree> trees = getGroups()
.stream()
.map(PermissionGroup::getPermissions)
.collect(Collectors.toList());
trees.sort(PermissionSorters.GROUP_TREES_BY_WEIGHT);
``` will this be extremely slow?
it maps, collects and sorts it
how do i know if my code can be laggy? im afraid of making something that will be ok when i test it but when more players will come on when i release the server, it will be laggy
experience
Benchmark your code.
what's benchmark
You write a program that tests how quickly it runs.
idk how to do that
How can I change a block to Air with its Location, World#setBlock wants a BlockData, whats that
?jd
than ku
Can u add custom potion effects through Spigot?
yes
How?
To a potion item? or to an entity
Entity
more players = more lagg
(if you do smth related to the players)
you can measure the time too know if it will be laggy
Like a effect called Dappaness
oh you mean custom custom
Yea
Well I guess you could create the effects, but idk about the status effect
dont think so
Aight
thanks for ur help
i dont think the player would see it
How can I get the player who is trying to craft an item from CraftItemEvent
yeah and also check if the HumanEntity is instanceof Player. Player currently is the only known thing that implements HumanEntity, but other plugins might add some weird other implementations, and also in the future other HumanEntities could be added
Is anyone here familiar with MockBukkit?
Guys quick question, if I send the player to a server through the https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#connect message. Would the player be connected even if it is a restricted server?
not if they dont have the permission bungeecord.server.<servername>
Which event is fired when players wishper
wishper?
you mean when he does /msg?
whisper yes
or /tell?
Mh, do you know how I could force a connect? Custom message or does it exists already one?
I'd just give the permission, connect them, remove permission
Hello can I talk here?
#general my friend
I think it's the same event for all the executed commands
I mean there is something called /tell
Yes
Well
@tender shard What event gets fired if someone executes a command?
So, what u can do is listen to the chat and then cancel that event and send a custom message
Ok how do I explain this
no, i guess, unless you do what this guy said
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
^
that's a stupid idea
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
change the format in that event
I know that but
@quaint mantle So try to use a PlayerCommandPreprocessEvent
use the event I sent above, then do sth like
event.setFormat("[YourPrefix] %s: %s")
first %s is the name, second %s is the msg
I do this: e.setFormat(ChatColor.RED + "" + ChatColor.BOLD + "ADMIN " + ChatColor.WHITE + e.getFormat());
thank u
and what's the problem?
Wait lemme get a screenshot of it
how to check if its /tell form that event?
by checking whether the string starts with "/tell "
however you have to take namespaces into account
it doesnt have a method for that ig
it could also be /minecraft:tell
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
if(Player.isOp){event.setFormat("§4§l(Admin) §f" + Player.getDisplayName + " > " + event.getMessage())}
I did that
no!
use the placeholders
%s %s
@EventHandler
public void playerChat(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
e.setFormat(ChatColor.GRAY + "" + ChatColor.BOLD + "MEMBER " + ChatColor.GRAY + e.getFormat());
if (p.isOp()) {
e.setFormat(ChatColor.RED + "" + ChatColor.BOLD + "ADMIN " + ChatColor.WHITE + e.getFormat());
}
}
it expects something that can be run through String.format
that looks correct except that you double the format for OPs
public void onChat(AsyncPlayerChatEvent event) {
String prefix = "MEMBER";
if(event.getPlayer().isOp()) {
prefix = "ADMIN";
}
event.setFormat(prefix + " %s > %s");
}
that results in
MEMBER mfnalex > my messsage
and
ADMIN someoneelse > other message```
I'll send you the screenshot
also
use to make a nice cool box
and it's exactly as I said
Yep
I don't really care about that lol
You first change the format and you set the format again adding to the old format
but we do 😦
:/
^do this @blazing rune
Ok
Aight
Oh
did you understand why your code duplicated the prefix?
Kinda
public void onChat(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
if(p.isOp()){
e.setFormat("§4§l(Admin) §f" + p.getDisplayName() + " > " + e.getMessage());
} else e.setFormat("§7§l(Member) §f" + p.getDisplayName() + " > " + e.getMessage());
}
well not really
the format expects a string to be used with String.format
it's not needed to manually insert the player name and message
that's what the %s placeholders are for
also it would be way easier to simply save the prefix in a variable, then use that to change the format instead of duplicating the p.getDisplayname + " > " + e.getMessage() part 🙂
Is it better to use the chatcolor or §
What you like the most
if you want to make it configurable
you should use &c color codes, and run them through ChatColor.translateAlternateColorCodes
because it might happen that the § character will change someday
Yep know that
if you want it configurable, use &c codes. If not, you can either hardcode &c codes or use ChatColor.RED
Ok
Forgot to say thanks for helping me lol
Hey can i dm someone? Since theres a error in my console i dont know and i already deleted ranksigns plugin.
What is the error about
@blazing rune ima dm
Ok
Whats that?
no problem 🙂
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
also if it's about a 3rd party plugin: #help-server
Can u answer me question there since iam freaking out about idk this one 😓
This thing is showing up on me console idk what it means
And iam freaking out
Ima dm u the problem
Okay iam here and iam very very worried
Bro iam literally shaking idk what this means and iam very worried
please do not DM me with stuff that belongs here
K i cant semd pics here
here's the error they DMed me
Okay thanks
is RankSigns your plugin?
I already deleted it
I mean - did you code that plugin?
because if not, this is the wrong channel, this channel is about coding your own plugins. if it's not your plugin, you should head to #help-server and/or contact the author of that plugin
I didnt code it
I didnt do nothing
I just downloaded it
And troed it and it dodnt work
So k deleted it
And the author doesnt have discord
Ima check the supporr
again here with 3rd party plugin help ^^ i see you dont understand it probably
I iam in help server but the chat seems inactive
Amd again they dont have discord or any support
See
I didnt code or anything
Are there any libraries for asynchronous chunk loading?
yes
PaperLib
(when using spigot, it uses synced chunk loading though. It only uses async loading when you're on paper or a paper fork)
@minor fox
Do you know if the latest spigot release supports previous versions?
how can i give a knockback effect on every entity in front of me???? 1.16.5
or damage
wdym?
is spigot 1.18 able to run on a 1.17 server
Wtf
that makes no sense
if you run spigot 1.18 it's a 1.18 server
do you mean whether you can upgrade from 1.17 to 1.18?
if so: yes
no the api
as long as the package names and method names are the same and present in runtime, it doesn't matter where those come from
Hello I have a question, how do I add permissions to players without a permission plugin?
Oh ty
blocks between 2 poisionts?
yes
like everything between 0,0,0 and 100,100,100?
you can just loop over the coordinates inside your area
like every block between my position and 8 block in front of me
Player#getLineOfSight
?
can anyone help me figure out why configuration comments are duplicating on restart
choco said something about this but i havent been able to find anymore information about it
what configuration comments?
your own plugin?
yes
show your code to save the config pls
declaration: package: org.bukkit.util, class: BlockIterator
not the comments themselves, but they duplicate themselves every redstart
and the config file grows exponentially
^
is that from those wildstacker dudes?
btw commented configs are done by default now
from what i can see mcmmo had the same
thats just the how. we need the where
i saw something in mcmmo discord about snakeyml changing in the recent updates?
Is there a way to make ghost players without a team?
i dont think so
what are ghost players?
like if the player is transparent
spectator?
nooo
you could use packets
if seeFriendlyInvisibles is true in a team then your invisible teammates are transparent
make them invisible and give them glowing
sure this is working?
then not
oh you are thinking of translucent
this would just outline the player and make the rest invisible
not transparent
i think just the head is possible cuz that's what spectator mode is, never seen anyone did a full body ghost
yeeees
sorry my english is not the best
seems like its clientside
no it's not, I sadly can't upload screenshots here
send a packet to the client that the player is spectator and that you have this "friendly team" thingy
get verified
oh wait now i think of it i did see a full body ghost before
when i played block hunt haha
um so i made a lifesteal smp server with spigot on aternos for 1.18.1 then it says U need spigot and i cant go in the server
what?
confusing in so many levels
no
free tho
is realms good?
NO
realms suck
no
depends on the version
if the chunk is unloaded, you're gonna be fucked
if it's loaded there's a good chance reading will work
it will 1.8>
who still uses 1.8 shouldn'T be allowed to ask here anything anyway 😛
I dropped support for everything below 1.16 a few months ago and it was the best decision I ever made
(besides drinking jägermeister)
Reading such thing can cause writing. Also, no one guaranties that it is nor going to be modified at the same time.
yeah, sadly you cant just do that with for example an anti AutoClicker plugin
i heard 1.15 has shit performance too
pff
Trying to add the mongodb java driver to pom.xml. However it just says depency not found
1.18 didnt went too far
1.15 is okay
repo included?
we cant do anything with that without seeing your pom
?paste
is there a fixed timing spigotmc updates its api
no
the one to see the plugin version f.e?
yea that one and the Xeroblahblah api
3 hours +-
I meant xenforo
ah ok tanks
you stopped drinking it ???
wtf xD nice
how did that picture came so fast
mobile phones exist lol
he drinking rn
and why do you have a towel?
it looks like.... ehmm is the jägi not cooled ???
ew
its burning at room temp. ^^
so, everything should be set up correctly and its still red?
Yep
did you try to invalidate your caches/restart/force download
run mvn clean package -U and then send the FULL maven log pls
No idea how to do
what ide do you use
Intellij
Cant run maven commands
File > Invalidate Caches
everything > 1.12 does
just install maven xD
only shit performance if your pc / server is bad ^^
not installed 😐
Lol
otherwise intellij provides quick commands you can use even without maven
why do you have a pom if you cannot run maven commands
intellij buttons 😄
^
ugh, default design
show screenshot of yours
Ok it works now
Still get a maven shaded thing caution message but idrc. It builds successfully
that would make me go crazy. why are the fields red
duplicated classes
I'd always think something's wrong lol
?paste
you can either exclude META-INF from your shaded stuff, or ignore that message
Idk how to exclude META-INF
once also had colored icons
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>de.jeff_media:JeffLib-*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<createSourcesJar>true</createSourcesJar>
</configuration>
</plugin>
but they are gone somehow
important thing is the <filter> part with the META-INF thing
you don't need that
you only need this:
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
i don't need nothing
Ok thanks
What does ** do again? Only match files in the folder or does it also do it recursively?
I really don't understand why people hate the default theme 😄
recursively
its so monotone and boring
i get hyped by mine
I wouldn't even notice if the colors were different, I don't look at them
so change it for us all
okay send a file to import
Question, it seems like when using getResource() and then Files.copy my file is growing in size and getting corrupted.
It's happening even after no other section of code access the file/directory.
Files.copy(getResource("region.slime"), Paths.get(mapFolder.getAbsolutePath() + "\\region.slime"), StandardCopyOption.REPLACE_EXISTING);
Top is the copy using that bit of code and bottom is the resource folder.
best colors
so we can look without being bored at your screens
sure, just tell me what I have to do lol
just install any theme
I looked through the most popular 20 themes in the plugin section and they all looked a 12 year old created them
Just go with the eclipse theme
good one lol
It is a theme after all
I am glad I uninstalled eclipse 1.5 years ago
never looked back
Idea truly is superior
most important plugin still is pokemon progress
Eclipse < IJ
eclipse is like the weird old drunk uncle of intellij
netbeans grandpa
bump
which event I must use to detect when someone steps on wheat and try to break it
I don't really understand why people switch IDEs, it is such a pain to get comfy with one
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTrampleCrops(PlayerInteractEvent event) {
Player player = event.getPlayer();
if(event.getAction() != Action.PHYSICAL) return;
if(!main.getConfig().getBoolean(Config.LEATHER_PREVENTS_TRAMPLING)) return;
if(event.getClickedBlock() == null || event.getClickedBlock().getType() != Material.FARMLAND) return;
double chance = 0;
for(ItemStack item : player.getInventory().getArmorContents()) {
if(item==null) continue;
if(item.getType().name().startsWith("LEATHER_")) chance += 0.25;
if(main.getConfig().getBoolean(Config.ONLY_REQUIRE_BOOTS) && item.getType() == Material.LEATHER_BOOTS) {
chance = 1.0;
break;
}
}
if(random.nextDouble(0,1) < chance) {
event.setCancelled(true);
}
}
TL;DR InteractEvent, Action.PHYSICAL
np
Honestly, just do
try (FileOutputStream fos = new FIleOutputStream(new File(mapFolder, "region.slime")) {
try (InputStream is = getResourceAsStream("region.slime")) {
is.transferTo(fos);
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
God do I love doing these low level streams
I'll give it a go
why don't you just use saveResource
Doesn't that save it to the plugins directory?
depends
where do you want to save it?
is mapFolder inside the world folder?
oh okay nvm then
saveResource() will save it in the same directory you have it in your local project
yeah but they need it in server root/maps/
yes 🙂 I'd just copy bukkits saveResource code and adjust it lol
There is getResourceAsStream() though iirc
yes
lmao
that works too lol
Can then write the bytes to an arbitrary file
public void saveResource(@NotNull String resourcePath, boolean replace) {
if (resourcePath != null && !resourcePath.equals("")) {
resourcePath = resourcePath.replace('\\', '/');
InputStream in = this.getResource(resourcePath);
if (in == null) {
throw new IllegalArgumentException("The embedded resource '" + resourcePath + "' cannot be found in " + this.file);
} else {
File outFile = new File(this.dataFolder, resourcePath);
int lastIndex = resourcePath.lastIndexOf(47);
File outDir = new File(this.dataFolder, resourcePath.substring(0, lastIndex >= 0 ? lastIndex : 0));
if (!outDir.exists()) {
outDir.mkdirs();
}
try {
if (outFile.exists() && !replace) {
this.logger.log(Level.WARNING, "Could not save " + outFile.getName() + " to " + outFile + " because " + outFile.getName() + " already exists.");
} else {
OutputStream out = new FileOutputStream(outFile);
byte[] buf = new byte[1024];
int len;
while((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
}
} catch (IOException var10) {
this.logger.log(Level.SEVERE, "Could not save " + outFile.getName() + " to " + outFile, var10);
}
}
} else {
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
}
}
that's the builtin saveResource method 😄
byte[] buf = new byte[1024];
int len;
while((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
I'd rather use Java 10's in.transferTo(out); and also use try-with-resources instead of these few lines which are just a memory drain
You can tell that this method was written when Java 8 (perhaps even Java 7) wasn't a thing. Nowadays we have a lot more things that are vastly superior to this
and md_5 just not having much time to reformat and rewrites those codes
And I am too lazy PRing stuff to spigot.
I'm not too lazy, I just have no idea how it actually works
Yeah I checked but it still grew in size :|
Could it be because of how java is packaging the file?
Then just delete the file beforehand honestly
Make sure the append modifier is not set
Could anyone help me with this?
Or just don't save if the file is already present
There was no file present
Then why would it grow in size?
I don't know
Actually, what do you expect to happen in the first place?
I want to save a file from my resource folder to a folder
That the file is some kind of virtual link to the jar entry or do you expect a hard copy (which will require some space on the file system)?
you can change file's name after
I want a copy of the file that is identical to the initial file in the resource folder
Ah, you mean that the file is actually not stored as it should be
What happens if you use mvn clean package instead of mvn package to build the jar?
I am doing that
isnt the initial resource folder read only
i just started reading, which file is corrupting?
region.slime
Hm, and the resource is inflated even in the jar?
(i. e. unzip the jar and check the file sizes)
Just unzip the jar
just open it as a zip -ninja'd
If not, some whacky JVM or Classloader stuff is going on.
If yes, maven is being strange (I have seen it inflating jar entries in the past, but only on class files as of now)
i guess u just disable filtering
I am so confused as to how I open this jar lol
right click
and open with winrar
or change the .jar to .zio
and then double click it
step one get winrar got it
thats it, if its open with winrar you should see the files
try disabling filters
so
<nonFilteredFileExtensions> <nonFilteredFileExtension>slime</nonFilteredFileExtension>
</nonFilteredFileExtensions>
?
Likely
yep
no worries lol
?paste
thanks.
whats the error?
How to translate hex codes to color codes?
Color.decode("")
strange..
Would it be a bad idea to just
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
and just dump that in a paste?
sure
it seems to be an issue when it attempts to filter a zip
show me
I deleted all zips and now it compiled
coolsies
weird
also add zip to your nonFilteredFileExtension then
Rn it returns this
For this:
fc6&lOԓd1&lrb2dd&le!cce8&lo,e5f4&lM7ffff&lC
public String translateHexColorCodes(String message) {
//Sourced from this post by imDaniX: https://github.com/SpigotMC/BungeeCord/pull/2883#issuecomment-653955600
Matcher matcher = HEX_PATTERN.matcher(message);
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(buffer, COLOR_CHAR + "x"
+ COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
+ COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
);
}
return matcher.appendTail(buffer).toString();
}
you have to turn ff0000 into &x &f &f &0 &0 &0 &0
Cuz last one is &6
without the spaces
public static String color(String string) {
final Pattern hexPattern = Pattern.compile("&#([A-Fa-f0-9]{6})");
Matcher matcher = hexPattern.matcher(string);
StringBuilder buffer = new StringBuilder(string.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(buffer, "&x&"
+ group.charAt(0)
+ "&" + group.charAt(1)
+ "&" + group.charAt(2)
+ "&" + group.charAt(3)
+ "&" + group.charAt(4)
+ "&" + group.charAt(5)
);
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}
It looks like an bungee api issue
&x&0&1&7&f&c&6 translates to orange
should i separate my database and cache implementation?
but that's not valid in any way
try to hardcode &x&f&f&0&0&0&0
see if it shows a solid red
I did...
it does work fine for me in bungee
I literally put &x&0&1&7&f&c&6 in the config
and you ran that through chatcolor.translate... ?
where did you use it? in the chat? actionbar? ... ?
what did you change since it doesn't work anymore?
Using bungee api 1.18
Didn't change anything about the code itself
Except
StringBuffer
to StringBuilder
can you show your full server ping code?
} else {
serverPing.setDescriptionComponent(new TextComponent(NetworkTools.color(String.join("\n", Configs.config.getStringList("modules.motd.message")))));
}
e.setResponse(serverPing);
public class ProxyPingListener implements Listener {
@EventHandler
public void onProxyPing(ProxyPingEvent e) {
I have this:
@EventHandler
public void onPing(ProxyPingEvent event) {
if(!config.getBoolean("enabled")) return;
ServerPing ping = event.getResponse();
ping.setPlayers(new ServerPing.Players(config.getInt("max-players"), ProxyServer.getInstance().getOnlineCount(),ping.getPlayers().getSample()));
String motd = config.getString("motd");
if(motd == null || motd.length()==0) return;
motd = motd.replace("%countdown%", getCountdown());
BaseComponent[] components = TextComponent.fromLegacyText(TinyTextUtils.format(motd));
BaseComponent component = components[0];
for(int i = 1; i < components.length; i++) {
component.addExtra(components[i]);
}
ping.setDescriptionComponent(component);
if(favicon != null) {
ping.setFavicon(Favicon.create(favicon));
}
event.setResponse(ping);
}
So the text is translated by TinyTextUtils.format, which looks like this:
```java
whoops
java [java]
wait I'll just upload the whole thing to github
I used java 8 before
doesnt change anything
public static String color(String string) {
final Pattern hexPattern = Pattern.compile("&#([A-Fa-f0-9]{6})");
Matcher matcher = hexPattern.matcher(string);
StringBuffer buffer = new StringBuffer(string.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x"
+ ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
+ ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
+ ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5)
);
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}
^ Old
public static String color(String string) {
final Pattern hexPattern = Pattern.compile("&#([A-Fa-f0-9]{6})");
Matcher matcher = hexPattern.matcher(string);
StringBuilder buffer = new StringBuilder(string.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(buffer, "&x&"
+ group.charAt(0)
+ "&" + group.charAt(1)
+ "&" + group.charAt(2)
+ "&" + group.charAt(3)
+ "&" + group.charAt(4)
+ "&" + group.charAt(5)
);
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}
New
remove the chatcolor translatething
Why??
lol no
iirc it gets handled by bungee itself if its that format?
The translate is so normal color codes translate to
hmm
can you remove it and try
translateAlternateColorCodes("&", color(message));
so essentialy removing it from the method
public static final Pattern HEX_PATTERN = Pattern.compile("&#(\\w{5}[0-9a-f])");
public String translateHexCodes (String textToTranslate) {
Matcher matcher = HEX_PATTERN.matcher(textToTranslate);
StringBuffer buffer = new StringBuffer();
while(matcher.find()) {
matcher.appendReplacement(buffer, ChatColor.of("#" + matcher.group(1)).toString());
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}
seems like your color() method does stupid stuff
your regex is fucked
print out the whole translated string to console WITHOUT running it rhough translateAlternateColorCodes
you did something wrong with the regex, yes
you shouldnt use ChatColor.of to translate it
public String translateHexColorCodes(String startTag, String endTag, String message)
{
final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
Matcher matcher = hexPattern.matcher(message);
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
while (matcher.find())
{
String group = matcher.group(1);
matcher.appendReplacement(buffer, COLOR_CHAR + "x"
+ COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
+ COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
);
}
return matcher.appendTail(buffer).toString();
}
``` this has the most positive ratings on spigot
you should simply manually turn ff0000 into &x&f&f&0&0&0&0
it will 100% work fine then
But even §x§0§1§7§f§c§6O makes orange
yes sure you must not use §
it's the same
i never had issues with ChatColor.of() so ._.
@EventHandler
public void onPing(ProxyPingEvent event) {
if(!config.getBoolean("enabled")) return;
ServerPing ping = event.getResponse();
BaseComponent[] components = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',"&x&f&f&0&0&0&0TEST TEST TEST"));
BaseComponent component = components[0];
for(int i = 1; i < components.length; i++) {
component.addExtra(components[i]);
}
ping.setDescriptionComponent(component);
if(favicon != null) {
ping.setFavicon(Favicon.create(favicon));
}
event.setResponse(ping);
}
This will 100% give you red solid text
Pattern.compile("&#([A-Fa-f0-9]{6})");
public String colorize(String s) { return hexColor(ChatColor.translateAlternateColorCodes('&', s)); }
public String removeColor(String s) { return s.replace("§", "&"); }
private Pattern hexPattern = Pattern.compile("#([A-Fa-f0-9]){6}");
public String hexColor(String s) {
if(s == null) return s;
if(s.isEmpty()) return s;
Matcher matcher = hexPattern.matcher(s);
while(matcher.find()) {
String color = s.substring(matcher.start(), matcher.end());
s = s.replace(color, String.valueOf(ChatColor.of(color)));
matcher = hexPattern.matcher(s);
}
return s;
}
```Here are my text color methods.
are you using vanilla mc client?
looks like you need /#
Lunar
hashtag
that doesn't make any sense imho
Lunar also seemingly randomly breaks
java 8
So it could still definitely be Lunar
lmfao
?
dessie youre great
what does the java version have to do with this
It gets cleaner in higher java versions...
it doesn't make sense because the translation method simply isn't correct
I wasn't talking about any java version things
Works fine for me xD
Makes sense to me too.
oh sorry I quoted the wrong code
Yeah my HEX color conversion is effectively the same as Yappery's
And I'm fairly certain it works 
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/data/HexColor.java here's my hexcolor class and here's my textutils class to translate them and it works without any problems on all 1.16+ versions, both with spigot and bungeecord https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/TextUtils.java
also would still recommend testing on vanilla mc client if able uwu
^^
I'd suggest to print out the text before and after running it rhough translateAlternate..... to console
your translation method is broken, I've said that 10 times already
welcome to programming
^ lmfao
sometimes shit just breaks for no good reason
gotta roll with the punches
actually it doesn't 😄
yeah it does
if stuff breaks for you with no apparent reason, something MUST have changed
i rolled out an app, worked all good. then the ios developers took a look at it and it just didn't work at all
if the same code runs with the same input, it produces the same result
uwu
thats what i mean lol, something changes and nobody tells ya so it just breaks for "no good reason"
is there a way to give knockback to the mob im looking at?
is there a way, probably. is it gonna create a lag machine? also probably lmfao
i cant imagine a way to do that without a ton of lag
Depends on how often you're checking
I doubt that checking who a player looks at every tick will cause any lag
unless you check it in a distance of 10,000 blocks
LMAO fair
every hostile mob basically checks its line of sight every tick
I doubt they need to check every tick anyways
I wrote some pretty inefficient stuff recently
true, just wanted to say it wouldn't really create a "lag machine" 🙂
good fun
Applying knockback every tick is gonna make the mob, well not be there anymore 
yeah 😄
Did it work
I'd check every tick if you're looking at an entity, and if yes, do a cooldown of 1 second or so when you've applied knockback to that mob
?paste
it makes the whole server freeze up for a few seconds, so yes.
Awesome
Ok so im trying to open a db connection and also access it from across classes. I am very noob with java so I can use it but not do anything I actually wanna do so I need help. https://paste.md-5.net/qalumafafu.java
I can use it but not do anything I actually wanna do so I need help.
what?
I have a very hard to understanding 100% how java works. Thats all
make a xyz loop and just get the blocks using getBlockData
wrong reply? 😛
whoops
use a vanilla client thnx
print out the text BEFORE and AFTER you ran it it through translateAlternateColorCodes
I did
I used ur exact files
yeah
print out the text BEFORE and AFTER you ran it it through translateAlternateColorCodes
thats what i did for my xray plugin anyways
if you do it alot just make a thread
all good
let me chck
for (int x = 0; x <= 15; x++) {
for (int y = 0; y <= 255; y++) {
for (int z = 0; z <= 15; z++) {
What is the recommended way of adding NMS to your project using paper?
using paper or not doesn't have anything to do with it
to get NMS, run buildtools --remapped, then add spigot as dependency
Can someone please help...
what exactly is the problem?
[NetworkTools]: fc6&lOԓd1&lrb2dd&le!cce8&lo,e5f4&lM7ffff&lC &7[1.12-1.18]
&eVanillaSMP - SurvivalSMP - PVP Practice
google dependency injection
yes that's not correct at all
read some websites and you'll be good to go
how do you generate that text
that's not the only problem
your starting character is #
ff0000 -> &x&f&f&0&0&0&0
I want to access the mongoclient variable set in my onEnable. but its completely ignored int he public methos on the bottom
but its completely ignored int he public methos on the bottom
what?
Just nvm ill do some reading
sorry but that sentence is cursed lol
lol
noone can understand it
Lmao I just realized that
but its completely ignored by the public method on the bottom
okay again: imagine you have the color FF0000
and you want to print "TEST"
what is completely ignored?
then you should pass EXACTLY this to translateAlternateChatColor:
&x&f&f&0&0&0&0TEST
so basically: add a & in front of every char of your hex color, and in front of the whole color, add &x
#000000 -> &x&0&0&0&0&0&0
#FFFFFF -> &x&f&f&f&f&f&f
etc
someone should make a thread
https://gyazo.com/833147b1a316ac469dda977f749d083a
I want to access this variable with this connection. But it doesnt grab it from there it grabs it from the initializer at the very top
I vote alex
it looks ok like this
the line you circeled is the initializer
oh i see
remove the first MongoClient
so
mongoClient = MongoClients.create();
that way it uses the public variable
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.
no offense but this is not a spigot related question, it's about basic concepts of java
you must know about variable scopes etc
wtf
Ik i just figured you guys would have the answer, Ill go over to the java discord (if there is one)
i gave you the answer
like right here
help...
help with what bro
when I do Bukkit.getScheduler() it says theres no getScheduler
huh it should work tho
check your imports
isn't it getSchedulers?
Ok so I know I wasnt going crazy
I've imported Bukkit
clear your cache
:)
in intellij try
file -> restart and invalidate caches
alr tried
xd
Ik
😢
what spigot version is that
add a ; at the back, let it compile and show the compiler error
oh wait
I know your problem
you use that outside of any method etc, right?
show your full class pls
jeff media is big brain
who?
ur mfnalex
jeff media is my c0mp4niii
that's what they all say...
problem solved ez
What happened to the zoom in on the logo. I was hoping for a meme where it enlarges slowly
what logo
maybe the spigot server logo?
that never had a zoom to begin with
your logo yesterday it was yuuuge
item type? wdm?
my profile pic?
yeahhhh
You know, a valid material to initialize a item stack
like id to item material?
valid materials are always minecraft:something
Material.valueOf("DIRT") for example
That is not accepting a resource location though
there are no custom blocks in spigot
they simply don't exist
what do you want to do anyway?
it's fine, I'll just use the nms item registry
that will not change anything
there simply are no custom items when you don't use client and server mods
period
Which you can overcome, by using resource packs.
Both for custom items and custom blocks, the latter requiring to sacrifice a few blocks with blockstates.
just with custom textures for certain blockstates
yeah
it's still internally only minecraft:whatever blocks
For custom items you can do up to 2 billion textures per material
Yeah, of course. You don't really need it to be anything else.
Which your block persistent data util is really useful for, by the way <3
:3
I had that idea in a dream lol
ahaha
only took them 1.5 years
Premium plugin btw
😄
unfortunately many paid plugins have way slower support than free ones
because most free devs care about ratings, while paid authors care mostly about income >.<
private ItemStack parseStack(JsonObject obj) throws JsonParseException {
Item type = IRegistry.ITEM.getOptional(MinecraftKey.a(obj.get("type").getAsString())).orElseThrow(() -> new JsonParseException("Unable to parse item entry! Invalid Item Type: " + obj.get("type").getAsString()));
net.minecraft.server.v1_16_R3.ItemStack item = new net.minecraft.server.v1_16_R3.ItemStack(type, obj.get("count").getAsInt());
if(obj.has("nbt")) {
try {
JsonElement e = obj.get("nbt");
String tag = e.isJsonObject() ? Cow.GSON.toJson(e) : e.getAsString();
item.setTag(new MojangsonParser(new StringReader(tag)).f());
} catch(CommandSyntaxException ex) {
throw new JsonParseException("Unable to parse item entry! Invalid NBT data!", ex);
}
}
return CraftItemStack.asBukkitCopy(item);
}```NMS is really not hard to use when you have experience in client modding
I'd argue it's even easier to use
The only annoying part is the constant need to convert between nms and spigot/bukkit objects
Easier to use is definitely a stretch
Its subjective, I suppose
I have much less issues dealing with the actual minecraft systems than the abstracted bukkit versions of them
I guess, but Spigot is fully documented so I would say it's WAY easier to learn how Spigot works than it is how NMS does.
So is vanilla though
It's just that this documentation is not found within the spigot community, but the modding one
The server side is documented?
Mhm

Much more than the client stuff actually
Because rendering is a black magic barely anyone dares to touch
modding makes me wanna commit war crimes
My issue with modding was that nothing was documented
You must have used forge
fabric is way easier than forge
Yep
I haven't tried in a while so
It also has proper mappings
Fabric is better than forge but has less compatability with other mods [since most use forge] and visa versa
Open source ones, which can be distributed freely
See yarn
And even have parameter names, unlike the official mojang ones
I mostly use fabric for client side stuff since y'know its easy as fk to do that with it
I don't like to do "x is better than y" for anything, but except existing mod compatibitly, forge has nothing above fabric
The only reason I still use Forge over Fabric is because of 1.8.9
public String onPlaceholderRequest(Player player, String params) this method is from PlaceholderAPI. I cannot change it. However, I'd like to asynchronously replace the placeholders, because I am getting data from my database
If servers are gonna support it, might as well us it.
you cannot do this async, placeholder need answer from you immediately after execute the request
Ok time to change my methods then....
you may consider add cache or something about db
Exactly, don't know that
bungee have way to distribute message across servers iirc
I know, but it also might be on another bungee instance
uh
how do i get a user's uuid? i can't find it in the docs thru a quick search [though i'm dumb so yh]
Nevermind
it's probably getUniqueID
yup
create a queue in some common communication channel and keep attempt consuming message in async task
complicate tho
hm personally I dont really go for extremely high performance, lazy to do async even in db xd
xD
is there a efficient way to map user given item stack to a String?
so e.g. user can set current holding item stack to a particular name
and for any other item stack coming in the future, I can map stack to its name which defined by user (if exists)
currently I have to iterate over all saved (ItemStack, String) pairs until I find the first one return true in isSimilar()
um is ItemStack comparable?
isSimilar is already mostly efficient, actually
with what would you compare itemstacks with?
You could use a tree/hash map with the materials at the key, meaning that you wouldn't have to iterate them all
compare itemstack with itemstack
Not really, from what I know it clones the itemmeta twice or so. But noone bothered to fix it so eh
ya map material first seems relatively good way
On what would you sort the stacks though?
I am reading the link from ElgarL
Does it? I think that it's using just the cached one. And it also does a material and data comparison at first, meaning that most checks don't get through anyways
which suggest using TreeMap
I'd not use Treemap
Unless it is String -> Itemstack, otherwise no, makes no sense whatsoever
treemap need keys to be comparable iirc
what would be the best way to get the time until the next hour divisible by 6 (so 00,06,12,18)?
nope, there is a #getItemMeta call at https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/inventory/ItemStack.java#290, which clones the item meta
well yes
Based on which clock?
a set timezone
do some math on System.currentTimeMillis() I guess
You'd be insane if you were to do that
uh why?
That's a weird decision, but this shouldn't have a huuge effect when he's already decreasing the total amount of checks
I think computerphile has a video on that. Timezones are pain to compute
If anything, use Clock#millis instead of System#currentTimeMillis
I have come to love DateTimeFormatterBuilder
xd I work around time for some internal functions which no show to the user so it probably easier to use currentTimeMillis
WHen is the proper time to use something asyncronouslyt?
when process is slow and you dont need feedback immediately
Got it
When you have no race conditions as well
@visual tide
Clock c = Clock.systemUTC();
LocalTime time = LocalTime.now(c);
int currently = time.getHour();
int remainingHours = 6 - currently % 6;
something along this line
Just cloned InteractiveBooks (https://github.com/Leonardo-DGS/InteractiveBooks) and it won't build or sync in IntelliJ (trying to add a feature), any ideas? That link just leads to a 404.
Could not find spigot-api-1.18-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT:20211201.040401-5).
Searched in the following locations:
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18-R0.1-SNAPSHOT/spigot-api-1.18-R0.1-20211201.040401-5.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Did you install the API through build tools?
Try the solution it's reccomending? no clue, sorry
oh wait, it might need JDK 8
Is it 1.18.1?
yea
It should be JDK 17
but it says J1.8 in build.gradle