#help-development
1 messages ยท Page 1867 of 1
its easy to understand but hard to compile
what if u just like made ur own implementation of Map with a constructor parameter that included the fallback value
But you still have to compile a version of map using that primitive
you'd have to make a version of every primitive
like right now
its not possible without multiple versions
class IntValueMap<KT> implements Map {
private final int def;
public IntValueMap(int def) {
this.def = def;
}
}
int get(KT key) {
// get method
if (keyNotFound) {
return def;
}
}
Yeah project valhalla our lord and savior
lol
what abt something like
class MapWithDefault<K, V> implements Map<K, V> {
private final V def;
public MapWithDefault(V def) {
this.def = def;
}
public V get(K key) {
if (notFound) {
return this.def;
}
}
}```
literally just map with default
you don't need that
thats not even related to what we're talking about
we're talking about maps with primitive value types
@lavish hemlock lol
fastutil includes maps for each primitive type I believe
Yeah
what i did above
idk i thought u just wanted to be able to supply a default value from any type
no..
Primitive types cannot be passed to a generic type parameter so we as of now have to pass their boxed variants
However project valhalla might just change it
Tho there are some questions in regards to primitive generics such as nullability, erasure etc
c# seems to have hit the nail on the head pretty well with it
Yeah probably
C# also doesn't have erasure though
because they didn't have to care about backwards compat
I mean one mistake in Java I believe kotlin fixed is the null safety
backwards compatibility is just a marketing scheme ๐
out with the old in with the new
This is the dumbest fucking thing I have ever heard
I have never heard anything more stupid than what you just said
I hope to forget what you just said so that I never reference it again
thats a compliment
It feels like my knowledge has been impacted / warped by this opinion in a negative away
mental torture is my specialty
+1
Iโll backwards your compatibility
๐
I think backwards compat is good, up to a point
Spigot got pretty extreme with it for 1.13
im gonna forward ur compat
forward compat is kinda interesting tbh, ur literally coding for the future
whereas backward compat is coding for the there and then
This is the pom.xml
"C:\Program Files\Java\jdk-17.0.1\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\pfram\IdeaProjects\Kingdoms "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\lib\idea_rt.jar=50598:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version=2021.2.3 clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< games.kingdoms:Kingdoms >-----------------------
[INFO] Building Kingdoms 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.046 s
[INFO] Finished at: 2022-01-04T19:39:59-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Kingdoms: Could not resolve dependencies for project games.kingdoms:Kingdoms:jar:1.0.0: Failure to find org.spigotmc
jar:remapped-mojang:1.17.1-R0.1-SNAPSHOT in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Process finished with exit code 1
?paste for the love of god
i couldnt remember what it was
dont forget it again ๐ช
run buildtools remapped for your MC version
java -jar BuildTools.jar --rev 1.17.1 --remapped
i mean after its remapped
Given how popular XMaterial is, clearly not extreme enough lol
after you ran buildtools, "your pom will just work"
ah
Those heckin 1.8 users
1.8 didn't even have offhand, right? lol
Yep. 1.9 added that.
i;ve just dowlaned spigot 1.18.1 to check if my plugin will work, and after running Spigot those folders have appear, can i take somehow take advantage of 'librares' folder in my plugins? or 'librares' are only for Bukkit?
they are all inside spigot, you can access them at runtime
IK but why are they now extracted to bundler folder?
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
Hi! how are you people?
I want to ask if anyone know why my command api its registering the command like double or strange
you use CommandMap#register, right?
The first parameter is the namespace, it should be your plugins name
yourCommandMap.register("yourPluginName","yourCommandName","yourCommandALias1","yourCommandAlias2", ...)
erm wait
sorry
/**
* Registers a new command
*
* @param permission Required permission or null
* @param aliases Aliases of the command. First element is the "real" command name.
*/
public static void registerCommand(@Nullable final String permission, final String... aliases) {
if (JeffLib.getPlugin() == null) {
throw new JeffLibNotInitializedException();
}
final PluginCommand command = getCommand(aliases[0]);
command.setAliases(Arrays.asList(aliases));
command.setPermission(permission);
getCommandMap().register(JeffLib.getPlugin().getDescription().getName(), command);
}
e.g. here
Yess
the first parameter in "register" must be your plugin name
the second parameter must be your PluginCommand
you however use the command's name as first parameter
see? you use executor.getName() instead "yourPluginName"
np
I was really confused when that happened
it's made so different plugins can ahve the same command
/essentials:kill, /cmi:kill, /minecraft:kill etc
Thats why
Sorry to come again but why my multi module project its looking for a custom library that made on maven repo? When its shouldnt be doing that. Because the library its installed on the local repo
because you didn't tell maven to only look in the local repo
thus, it will search everywhere else for it and then fall back to local repo
The problems is it never fall back to local
then it's not in your repo
Its search on maven website and explote
check the exact version, artifact id and group id
try this:
mvn dependency:get -Dartifact={groupId}:{artifactId}:{version} -o -DrepoUrl=file://your/repo/path
I did the following create a multi module project.
- My library i installed on local repo by doing "nvm install"
- My plugin add the library as dependency
But thanks i will try
I went to my local repo
And the library its there
Like the poms, sha1, md5, hash
The library its installed correct
And i can import it and use it. But when do a "package execution" for converting my plugin to jar its explode. Saying that it cannot find the library on maven repo. When its installed locally like its never check on local repo
Someone told me trying to do an install of the main project
Do you agree?
And then to build my plugin via package execution
It thrown me a null pointer exception
show the full error pls
mfnalex it worked
The problem was that i have to install the main project
And then compile my plugin
Now im getting a null pointer because i chaged what you said. But i will re run the code to check again
Working know
what did you change? I didn't ask you to change anything D:
that's correct
does /coins work or do you have to enter /core:coins ?
Ahh not it correct now
But im having an inssue that when executing from console it saying that i dont have permission
Thread.sleep() ?! ๐
idk if u meant that but i did it anyway
mfnalex now when using sub command from console its saying that i dont have permissions to execute it. Any recommendation?
noone can help if you don't show the source for those commands, but I gotta go to bed now
thx ๐
?paste
is it possible to remove 'Enabling message' ?
i would like to make custom one
tbh custom messages only annoy admins
they want to see whether it enabled or not, everything else like huge banners is just console spam
good point
This is my CommandExecutor class
Internal Exception: io.netty.handler.codec.DecodeException: The received string length is longer than maximum allowed (17>16)
I think the message comes from the PluginManager itself
i guess label is the wrong thing to use or something?
you show the "no permission" message when the sender DOES have the permission
your last if statement on the screenshot
Ohh yeah
add a ! before "sender.hasPermission"
np
My bad!
full stacktrace
one wasnt sent to the console, just ingame
I think that problem ocurrer when using scoreboard
you send a player packet with a player name that's longer than allowed
max player name length is 16 characters
that's the limit mojang once set
ah ok
spigot could probably handle more, but the vanilla client doesn't like that
ah i found it
Oh im again with a different problem btwww
Im having arguments problem now.
I registered an argument for the command "core"
And i do simple debug like this
And when i execute: "core info" without arguments it shown. When im not using any argument
if you used /core info, that's correct though? what did you expect?
info is the argument
Ahh
I expected the first message
But wait i pass the argument with fixArgs method, that move all the positios of the array
the first message is shown when entering /core
what? no, the bukkit command manager thingy calls your executor with exactly the arguments you entered
https://paste.md-5.net/duzigewosi.java
its not saying there was an error but its also not creating the npc
Because i need to be able through executor argument, use other arguments
Ok but info is an argument there
@sterile token if you need to do more complex commands i would recommend you to use this API https://www.spigotmc.org/resources/api-commandapi-1-16-5-1-18-1.62353/
is livingEntity.removeWhenFarAway meant to handle despawns
because it doesnt rn ๐ญ
this API is actually quite annoying when it comes to optional args
yep, but i guess its more handy then default spigot command registration
im kinda too stupid to find the answer for this myself
is there someone that can explain why some mobs (wandering traders) can persist NMS behaviour when leaving/deloading chunks but others cant? im trying to look through the code for it and see what makes it persist but all i see is them saving additional tags such as inventories etc
Thanks i forgot to put a less 1 so the array instead of counting from info, it start counting the arguments before info
Another stupid question how i can add values to 1 hashmap inside of other hashmap?
what do you mean?
make a class?
No lol
I have made a hashmap with other hashmap inside
Map<UUID,YourNewClass> cooldowns
I cant because the player will contains other cooldowns
Like report cooldown, helpop cooldown
So i dont think this would work
access the hashmap via get() and so on
HasMap().get(HashMap().get())
Oh ok
probably don't have it setup correctly to make it easy to access that inner hashmap
cooldowns.get(uuid).get("")
var playerHashMap = new HashMap(); this.cooldows.put(uuid,playerHashMap );
But i need to save 3 values
but this is susceptible to a NPE
Btw
you should probably just use an object then
like Cooldown
and then do new Cooldown(name, duration)
Uhm
you can make a new class that requires 3 inputs for the constructor and then stick that class object into the hashmap
Wait i think i can add a value name to Cooldown class
And then map<UUID, Cooldown>
Thanks!
There you go ๐
y'see I don't fuckin' know your project layout so I can't really help too well but you should basically never have nested maps
at least it isn't as bad as JSON
Allright thank for the recommendation
with its infinite nested lists >>
at least JSON can be serialized to an actual object
sure, but JSON doesn't tell you about lists or collection related things, you have to keep looping until you can't loop no moreXD
and JSON allows nesting to be infinite
you want to make many cooldowns for one player?
remember, JSON was meant for JS :3
does anyone know if stopping chunks from unloading would cause any problems?
Yeah
yes, but instead became a convenient way to send payloads
public class PlayerCooldowns
{
private final List<Cooldown> cooldowns;
public PlayerCooldowns()
{
cooldowns = new List<Cooldown>();
}
//to do
public void add()
//to do
public void get()
//to do
public void remove()
}
public class Cooldown
{
private String name;
private Consumer<Player> effect;
}```
I mean when you compare it to XML
maybe try this approache
This was my initial cooldown class without the var and method
Allright thanks Jacek and you Maow
Well, JSON has a bit more easier to read format and XML well it can be pretty crazy lmao
either serialize the map and store it that way or iterate through the map and store the information as you iterate
serialize?
configFile.addDefaults((Configuration) defaultModules); works, but I soon as I try to add another map, it errors out
How can i check a value on hashmap and if equals to stm return the value but all inline?
var value = cooldowns.get(uuid); ?
I now but i need to check if cooldown.getName().equals(name) and then return the object and if not null
All inline if it posible
like this
Like doing all the code in 1 string
those are called one-liners
var playerCooldowns = cooldowns.get(uuid);
var containsName = playerCooldowns.stream().find(c -> c.name.equalIgnoreCase(name)).find();
if(containsName.isPresent())
{
var value = containsName.get();
}
else
{
}```
Oh my band
probably not going to have one, most checks are not simply one liners
and by technicality you can put all the code on a single line
this is what you need?
if you really want to make it hard for everyone to read ๐
Yes
I need to get the the object Cooldown from my map via uuid and returning it, if the name on it equals to the one from the method
public Cooldown getCooldown(UUID uuid, String name) {
return cooldowns.get(uuid);
}
Yes that will return the object
this hashmap contains list of Cooldown as value
you can still look in the hashmap for the value too
But thanks
anyways I was just trying to get it to where they were wanting it lol
hard to follow in what is being requested
public Cooldown getCooldown(UUID uuid, String name) { return this.cooldowns.get(uuid).stream().filter(cooldown -> cooldown.getName().equals(name)).findFirst().orElse(null); }
if you use 3 back ticks, and then type java
this is unsafe approache
it will format it in Java style ๐
what if cooldowns not contains uuid?
then exceltion will be thrown
it nulls
It null
null.stream() ?
basically what you were asking is for a lambda expression
Oh ok
lambda's are what let you do multiple things in a line of code. I am not the best when it comes to that as I typically dislike Lambda
I love lambda
use cooldowns.contrains(uuid) before your code
That's a really strange way to put it
the reason I dislike them is while yes less code, it hides away details as well
I can kinda see where you're coming from but lambdas are much more than that
have yet to see lambda do something where it was absolutely needed
therefore, lambda is not special I will code in a way where details are not automatically hidden from view ๐
however that doesn't mean others need to stop using lambda
just lambda doesn't mean it executes less ๐
Passing around callbacks
They're never strictly needed
You can always use anonymous class definition
Or define an entire class
lambda is not the only way to do a callback o.O
But they really cut down on boilerplate
It's the main use case where lambdas are the clear solution
Any ideas this happens when i solve the problem return problem
@sterile token you are trying to put wrong object
{
if(!cooldowns.contains(uuid))
{
cooldowns.put(uuid,new Set<CoolDown>());
}
var set = cooldowns.get(uuid);
set.add(new CoolDown());
}```
You should probably use Multimap
the value is Set not Cooldown
Oh okk
this.cooldowns.computeIfAbsent(uuid, k -> new HashSet<>()).add(new Cooldown(name, duration));```
I love computeIfAbsent
It's so great
What does it?
refering to this
excatly the same what my code does, but it is much cleaner
Computes a value if there isn't one for the current key, and returns the new value (or old one if it already existed)
Allright thanks
Wait no i have a doubt what it the best solution? A MultiMap? Map + Set? Map + Map?
yeah
Multimap is specialized for this purpose
but it's also dependent on Guava
I'd recommend it personally out of cleanliness
first off best solution is to not use Map if you don't have a particular reason for that. Should be using HashMap or something similar. Second I think you are over complicating this more then it needs to be
well you shouldn't use HashMap as the type
just the implementation
also, beginners have a tendency to overcomplicate just let him do it
I avoid multimap
give me a sec, think I have example code for how to use maps inside maps easily
You are completly right btw
yeah no problem
instead of thinking about map, read about Consumer i believe you will need this soon
You mean the functional type or a design pattern?
both ๐
๐ค
I have already used them on the same library, for accepting the onMenuOpen and onMenuClose of my menu library
and people who use Electron
well I can't find a piece of code specifically but you are free to browse through yourself and see if anything might be helpful
best thing of that project is it displays how conversation API can be used though ๐
Allright thanks really thanks
What's the deal with the depreciation in the Chunk Generator? It means that you can't return custom chunk data
I will pin your message
deprecation doesn't mean unusable ?
deprecation = "shouldn't use," not "can't use"
exactly
Right, why shouldn't we use it?
unless explicitly stated otherwise
@lavish hemlock well when it comes to GUI do you know some architecture papers how to implement varable tracking (Binding) to make responsive GUI?
I'm asking why, I know that I can use it (since I do use it)
uhh well I don't know papers
I don't really look at research docs
mainly bc they fly over my head
but honestly just implement the observer pattern
not sure, usually there is a message of some kind attached to things deprecated it could also mean that something better is being created and thus it is to raise awareness that it might change soon
works fine
Ah, that's fair
JavaFX uses observable properties pretty much everywhere
It was added when all those other methods were added
oh yeah also observable collections too, those are cool
Even though it's not a replacement
would actually recommend a reactive programming lib like RxJava
Me too but sometimes i have problem with infinite loop while refreshing GUI
I believe only the old style chunk generator method is deprecated
There is a new one you should be using
well the idea of reactive GUI is that it shouldn't need to refresh or whatever
changes should immediately propagate
But there's no reacement to manually do stuff
Only using the provided features
which is why event listeners (observers) should be used
Elaborate?
There's no way to return custom ChunkData
yes but in case TitleName varable change i need to refresh whole GUI
this is called polling btw
Only modify the existing
In what case would you need to
when the program must repeatedly check for the change of something as opposed to that change informing the program
I design my stuff to never have polling
I prefer reactive design
Same
thx
i have implement it like this for "buttons"
Hm, ig it is possible actually...
for NMS entities that despawn do people just re-spawn them on chunk load
why do you do if(event.getValue()) ?
The tracking Value in this case is Boolean. This is example of switch on/off Button on GUI
if you want more optimal you would swap out those booleans for a short or byte instead ๐
you don't need to, just more or less poking some fun at those who optimize to the extreme however what I said is true regardless ๐
i think there is no difference becouse i would need to use 'Byte' as a class instead of primitive type 'byte'
and Byte and Boolean take the same amount of memory i guess
there is no specific size for primitives
just ranges
but it has to do with more then that however
but why short is better then booleans?
because boolean has to check for false and true and not just 1 or 0. As I said, technically true what I said but its a micro optimization thing lmao
as I said was more in reference to those who love to optimize to the extreme XD
interesting i thought boolean is somehow transorm to 0/1 after code compilation
memory wise using a boolean or int will probably take up the same amount
the only thing that is known about boolean for the JVM is that at minimum it can only take up 1 bit
google says that boolean is even smaller then byte
google isn't the one that wrote the docs either
implementation wise if I recall, boolean is backed by an int
also in the implementation or JVM, boolean doesn't have a specific size it must be and this is actually true for all of the primitives because they are all OS dependent
as well as JVM dependent
therefore, boolean could take up more space memory wise but that wasn't what I said in why boolean is less optimal
ok, good to know
Does anyone have something like a Resourcepack converter for diffrent versions? Because we want to send a different Resourcepack version depending on the Player Client version. Also I m searching for a Ressourcepack compressor that make the textures and .jsons smaller
How do I get ENABLED_MODULES as Map in config??
config.yml
ENABLED_MODULES:
PLAYER_OBTAINED_OP_ITEMS: false
PLAYER_RANDOM_ON_STONE: true
PLAYER_RANDOM_ON_GRASS: true
DEATH_MESSAGES:
PLAYER_OBTAINED_OP_ITEMS: got too powerful
PLAYER_RANDOM_ON_STONE: stepped on poison stone
PLAYER_RANDOM_ON_GRASS: stepped on poison grass
uh, hello
Why when using this method
Bukkit.getServer().broadcast(message, permission);
The console won't receive it.
But when using
Bukkit.getServer().broadcastMessage(message);
The console will receive it.
At first i thought that it was bc the permission wasn't registered in plugin.yml but after that i added it and still the same
aaaaaaaagh
my bad
i put not op
the first thing that came to my mind
weird
Still not working
Broadcasts the specified message to every user with the given permission name.
Params:
message โ message to broadcast
permission โ the required permission permissibles must have to receive the broadcast
Returns:
number of message recipients
i don't think it includes the console
i can just add one to the console, not really a problem
but i'm not sure about this
How do I change type of Map to type of Map<String, Boolean>? It forces me to remove <String, Boolean> on enabledModules enabledModules = configFile.getObject("ENABLED_MODULES", Map.class);
anyone know why
PlayerInteractEntityEvent is called twice
nvm its the hand issue
hey
I can't setScore
Scoreboard sb = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
if (sb.getObjective("output") == null) {
sb.registerNewObjective("output", "dummy", "output");
}
Objective obj = sb.getObjective("output");
int num;
Score score = obj.getScore("save-all");
num = score.getScore();
score.setScore(3);
The score wont change to 3.
gosh does no one work here?
if (board.getObjective("output") == null) {
board.registerNewObjective("output", "dummy", "output");
}
Objective obj = board.getObjective("output");
int num;
Score score = obj.getScore("save-all");
num = score.getScore();
score.setScore(3);
for(var player:Bukkit.getOnlinePlayer())
{
player.setScoreboard(board);
}
maybe try like this
what do you mean?
not real?
in this example all online player will have updated scoreBoard
i guess you just replace Bukkit.getOnlinePlayer() with player you want scoreboard be updated
Oh ok
Hey, how do I surpress Unchecked assignment: 'java.util.Map' to 'java.util.Map<java.lang.String,java.lang.Boolean>' warning? my code works finee.
static Map<String, Boolean> enabledModules = new HashMap<>();
enabledModules = configFile.getObject("ENABLED_MODULES", Map.class);
enabledModules = configFile.getObject("ENABLED_MODULES",enabledModules.getClass());```
try this
wait. getClass() is a thing? Thanks!
i believe so
w8 this is error or warning?
warning
shit
so you can just ignore it?
also, I think .getClass() also returns Map.class.. didnt work
warnings mainly says '"your code is unclear do some changes'
nope enabledModules.getClass() return HashMap<String,Boolen>
try it enabledModules.getClass().getName()
returns String
the content of the string
~~How can I see if a player is using the /msg command, and cancel it if they are
I did
@EventHandler
public void preCommand(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (event.getMessage().equalsIgnoreCase("/msg")) {
player.sendMessage("no");
}
}
And that works, but if I do something like /msg haappi hi, it doesn't send me "no"
wait do i split this so i only get the first part~~
got itt
running into a really odd java issue:
ArrayList<Vector> availableDoors = new ArrayList<>(this.availableDoors.keySet());
Vector newDoor = availableDoors.get(random.nextInt(availableDoors.size()));
currentFace = this.availableDoors.get(newDoor);
System.out.println(this.availableDoors);
System.out.println("Chose " + newDoor + ", " + currentFace);
this.availableDoors.remove(newDoor);```
gets me
```[00:14:01] [Server thread/INFO]: Available doors: [-32.0,0.0,68.0, -7.0,0.0,63.0, -25.0,0.0,33.0]
[00:14:01] [Server thread/INFO]: {-32.0,0.0,68.0=SOUTH, -7.0,0.0,63.0=SOUTH, -25.0,0.0,33.0=NORTH}
[00:14:01] [Server thread/INFO]: Chose -7.0,0.0,63.0, null``` in console. For some reason the `newDoor` instance isnt able to be referenced from the map?
display this string in the console
wait wait
What i'm saying is that
after doing setScore(3)
And then running getScore, it's still 0.
/scoreboard players get save-all = 0
not the sidebar
ik i think you need to update whole scoreboard somehow
other times it works perfectly, ```[00:14:01] [Server thread/INFO]: Available doors: [21.0,1.0,39.0, -32.0,0.0,68.0, -7.0,0.0,63.0, -25.0,0.0,33.0]
[00:14:01] [Server thread/INFO]: {21.0,1.0,39.0=SOUTH, -32.0,0.0,68.0=SOUTH, -7.0,0.0,63.0=SOUTH, -25.0,0.0,33.0=NORTH}
[00:14:01] [Server thread/INFO]: Chose 21.0,1.0,39.0, SOUTH
afterall i'm already sending "execute store success score save-all output run save-all" to console
ConfigInit
is it Spigot class?
normal class
static Map<String, Boolean> enabledModules = new HashMap<>();
enabledModules = configFile.getObject<Map<String, Boolean>>("ENABLED_MODULES", Map.class);
try to this
maybe warning disappear
or just configFile.getObject<Map>("ENABLED_MODULES", Map.class);
nope
ooooooooooooooooooo
ok it's still not working even with dispatch command
so my sb is outdated
i think i have to update it constantly
@gentle oriole do you use Intelij IDE?
yep
bc in my code it's not updating
so hold CTRL and click on the configFile.getObject getObject method
and send me how it looks inside
how do I send you?
with Screen shoot or copy and paste code
how to set title screen for players?
you might be wanting a mod, not a plugin
i have seen many server which has title screen when they enter
wdym by title screen
the big welcome that comes on their screen when they enter the server
declaration: package: org.bukkit.entity, interface: Player
@gentle oriole do you have this warning?
nope
thanks
idk you can just ignore this warning
warning only means that your code is Unclear in some place, nothing more
you don't need to do anything, it is just warning you about generics/type erasure and won't stop the compiling
how do I like, ignore them in intellij?
oh there is probably a setting to not have the IDE warn you of it
not sure where it is in IntelliJ. I use netbeans ๐
that is for so you don't get the warning in the compiler logs
it can also make the ide shut up abt stuff
im the type of person who dont like to leave unread messages, uncleared notifications, unfixed warnings...
btw is there somthing that can organize config.yml alphabetically? smh if I make changes to it ingame, the order of it changes so that the modified value is in the bottom.
disabling join/quit messages should be as simple as calling event.setJoinMessage/setQuitMessage("") right?
whats the spigot thread to hire a dev
?services maybe?
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/
oh i use null to disable it, ok
when will this thing end huh
ResourceLocation... u workin with server internals rn?
Can I download the latest version of the plugin, then disable and enable to update the plugin?
But when the server is running, will the plugin folder be locked?
Only on windows
You can put it in a folder called update (updates?) and it will be copied next restart
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryCloseEvent.html might be what you want
declaration: package: org.bukkit.event.inventory, class: InventoryCloseEvent
how do I get config as HashMap?
enabledModules = configFile.getObject("ENABLED_MODULES", HashMap.class);
Works but, it returns DEFAULT VALUES
System.out.println(enabledModules);
enabledModules = configFile.getObject("ENABLED_MODULES", HashMap.class);
System.out.println(enabledModules);
config.yml is empty...
how
its 0kb
i really cant get anything from this
?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.
is it legit?
wdym legit? also you may remove toString call
yes, why is it returning something if it is 0kb??
No
is there a resource on how to do fireworks in spigot
In folder?
/plugin/myplugin
/update/newplugin
Like this?
Copied is Spigot's function or I need to make by myself?
@analog prairie yes, I think it should have the same name as the one itโs updating
Is it update without restart server possible?
not reliably
Got it
ayo where's the night and day sky located in the texture files
How to use Particle data type?
Particle particle = ?
dataType is T a Class
In PlayerJoinEvent i want to use
I don't really understand about plugins, but you can help me with 2 classes and how can I create main in a plugin.yml
assets/minecraft/textures/environment in the jar
is it possible to create your own achivements?
yes
I looked there but thereโs no sky texture only sun moon void
hey guys, is there a way i can naturally generate a flat world with no hills/massive caves like old MC terrain
if you want flat world just set the level-type in server.properties to flat
i want it flat as in, plain biomes with some rivers
how do i do it?
Hey, I'm trying to use specialsource to remap my plugin, however, when I run it via maven, I get this error: ```
The parameters 'srgIn' for goal net.md-5:specialsource-maven-plugin:1.2.3:remap are missing or invalid
Here's what I'm running for the plugin: https://paste.md-5.net/cequvivuwa.xml
how to make lightnig when right click air spigot coding?
you listen for the playerintercatevent, and then you just get the position of the block he is looking at and summon a lightning
example?
ye
https://bukkit.org/threads/need-help-with-lightning-summoning-code.308495/ here is some but be aware to register the event in onenable
you can just adjust the code to your demands
Anyone got a solution for this?
i want like if right click at an entity it will strack lighting at the mob can you help me?
I can't get it to work
is not a valid error description
We need a command for that like
?showerror
"It is not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what does actually happen. If you get ANY error console errors, also ?paste the FULL stacktrace.
@ivory sleet can we have a command like this pls?
because 50% of my messages here is asking people what exactly their problem is and they only say "I get NPE" or "it doesn't work" lol
+1
``` `[12:48:52] io.netty.handler.codec.EncoderException: io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s) of direct memory (used: 520093703, max: 536870912)
[12:48:52] at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:125)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
[12:48:52] at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816)
[12:48:52] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
how to fix error bungeecord
you don't have enough RAM
or
are you sending a plugin message?
if so it's too long
Check for PlayerInteractAtEntityEvent
example?
yes i am big noob
@EventHandler
public void onLightning(PlayerInteractAtEntityEvent event) {
Location location = event.getRightClicked().getLocation();
location.getWorld().strikeLightning(location);
}
well i was just about to put in here, but thanks anyways lol
๐
not sure whether PlayerInteractAtEntityEvent or PlayerInteractEntityEvent tho
what I sent is correct, I wrote it in intellij
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
i want it to only work on my custom item?
how do i do that?
then check the player's main hand and return if it's the wrong item
example?
?jd
check Player there
and maybe check bit of yt vids about spigot coding, they can be quite educational for starters as well
i checked but there was no one helpful
they're usually very generic right, but simple concepts like event listeners, command listeners can be easily learned that way as well
everything else then is just combination of java and spigot from there
Hello, i've recently updated my plugin to 1.18, everything seems to be fine accept any use of ChatColor / ChatMessageType / TextComponent are not working, could someone help me resolve this issue?
ok ill give that a go, thanks
i mean import into the libraries
erm how would i do that?
did you use buildtools to create the spigot jar file?
Cache all the usernames perhaps
yes
okay and then you decompiled it right, and extracted the spigot.snashot.1.18.1 file right?
How to get a server id?
yeap
performance 100
so in the same folder the meta-inf folder you can find the bungeecord-chat-1.16-R0.4.jar
I am trying to make a simple plugin I am using eclipse when I hover over JavaPlugin it does not lets me import
ok ill try to find now thanks
What does it say when you hover over it
JavaPlugin cannot be resolved to a type then it gives me 2 options
META-INF/libraries to be exact
create a class called 'JavaPlugin' or fix project setup
How to get a server id?
id
idk abt that I am new
i cant find it, what folder was it under?
.
Otherwise, the server cannot be identified
Like Geyser Server UUID
oh
You have to add Spigot as a dependency
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thanks
i cant see that... :3 i have spigot, craftbukkit, work, apache maven 360 builddata bukkit and portiblegit... those are the folders i got..
oh well idk then, you can either search for it, decompile another spigot jar, or if you trust me i can send the file into your dms
please XD
Umm I cant find the api folder do I have to reinstall the buildtools?
You have to run BuildTools.
ok
?bt
thanks
why should i do db queries sync on enable or disable?
because it cant lag the server?
so the server doesnt load/shutdown until they are finished
ah in that way i get it
the build tools.jar? I download it now its installing something in a very old type insaller
and if i do it async the query would be interruped
it made 3 folders work, portalble git and Bukkit
Go into the Git folder. There should be like an install or executable for Git. Youโll need to run that.
might still wanna do it async but then just join the task
Actually I lied. I donโt even think you need Git Bash to run buildtools. Open terminal in the same directory as your BuildTools.jar and then run the command
java -jar BuildTools.jar --rev latest
the BuildTools result is like multiple gigabytes :3 you'll be fine :3
is there anyway to fully change a player's name ?
like from gameprofile or whatever
I am limited to 1 gb for this
Youโre going to have to clear some space then
oh can I drag the files to a different directory?
modify the gameprofile i think
its at Starting clone of htts://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git to CraftBukkit
since 2 minutes
Just close terminal, move build tools to a diff directory (and change your terminal directory) and run it again
naah I am fine rn I have 48 gb rn
will it take more then 1 gb?
that's my question
Damage is also based on velocity
wait I got a error
`Attempting to build version: 'latest' use --rev <version> to override
Found version
{
"name": "3395",
"description": "Jenkins build 3395",
"refs": {
"BuildData": "f31eb04b918592f66c6edd17c9b5998383581ae5",
"Bukkit": "a7505b3cd0498baca152777767f0e4ddebbe4d1a",
"CraftBukkit": "cc86ab1886c9d2d50495711288ffad33a0c7e554",
"Spigot": "f4ff00ffa451bd116cfbab3bd9d83b42e93904dd"
},
"toolsVersion": 138,
"javaVersions": [61, 61]
}
Pulling updates for C:\Users\User\Videos\Minecraft\BuildData.git
*** Warning, could not find origin/master ref, but continuing anyway.
*** If further errors occur please delete C:\Users\User\Videos\Minecraft\BuildData and retry.`
I closed the terminal accidently f
leave it
Hi! It's been a few hours and I still haven't gotten this to work. Can someone help me with this please?
anyone how, how in intellij, i can change every local variable declaration to var, and make them final, in exisiting project?
idk i had like three getUser methods before
pretty sure you could come up with a slightly more expressive name
also fourteenbrush
you probably want to use your own work stealing thread pool
instead of the common pool / cf's own expensive executor
if i knew how those things work i could use it
do you know how threads work?
yes
well in Java the class Thread is a special class as you're very much aware of (since invoking Thread::start won't run the runnable in sync with your other code you've declared
a thread pool is an object which manages a bunch of threads basically (their lifetime, creation and destruction)
How to Block to place blocks on Grass and tall Grass?
well what if you're querying all the ranks from the database and all the users
i'm not but yea
if its on a single thread you'd only be able to do one of those things at the time
however thing is
any call to an io device is expensive in terms of resources and takes much longer than other operations such as normal method calls etc
your database is probably an io device
therefore
i use a hikari datasource
when you use CompletableFuture#runAsync(callback) you actually invoke this instead CompletableFuture::runAsync(callback,ForkJoinPool.commonPool())
which as you can tell uses the common pool
and thing is, you'll now be using the threads from the common pool which will block other operations done in the fork join pool such as parallel streams
which isnt usually good
(since those db calls probably are quite resource expensive and take greater amount of time in comparison to what the common pool is prepared for)
well you still seem to be doing some sort of db operation
and whats the difference between the common pool and for example Executors.newCachedThreadPool?
a cached thread pool may reuse a its threads
the common pool is an instance of ForkJoinPool
which goes under the name work stealing pool
and the main difference is that the work stealing pool can steal work
well, what I mean is that lets say you have 2 workers
and you delegate 10 tasks to the first worker
now the second worker might steal 5 of those tasks if they dont have any tasks themselves
uhu
so its ideal when you have a large task which can be split up into smaller tasks
for instance large computations
not so ideal for file and db writes/reads
but well it can work decently
which cannot be split up?
hmm well not easily
right
in principle you could split them up however that'd require some sort of locking mechanisms so you dont run into a concurrency update problem
or well not the db query
but for instance when you do stuff with a file before writing to the disk
or smtng
Hello, is there a rapid way to call night skip ? I want the night to skip if 1/3 of online players are sleeping.
@EventHandler
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
// Increment the number of players sleeping
sleepingPlayers.incrementAndGet();
// Check if the number of players is equal at 1/3 of the total online players
int onlinePlayers = Bukkit.getOnlinePlayers().size();
if (sleepingPlayers.get() >= (onlinePlayers / 3)) {
// Sleep
// ??
}
}
anyways point is, the common pool is mainly present for parallel streams and other tasks which can be decomposed into smaller tasks
ah i get it
by submitting potentially big tasks you decrease the efficiency of all other parties which might use the common pool
so usually I just have my own work stealing pool
theres a gamerule do to this now
i forget the name
in my most recent app I just this implementation
new ForkJoinPool(
Runtime.getRuntime().availableProcessors() * 2,
ForkJoinPool.defaultForkJoinWorkerThreadFactory,
(t, e) -> e.printStackTrace(),
false
);
doinsomnia ?
yeah u set it to like 0.33 or 33 i think
i forget how it scales
33
0 to 100
it is for 1.17+ tho so idk then if ur working with something lower than that
does this get caused:
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getDisplayName()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
if what happens? if the displayname is null (i.e hand?)
Now i'm working with 1.18+ with via version, does it still work ?
this happens if the itemstack type is air
1.17+ is anything 1.17 or higher so yeah
or if it's null of ofc
So if i understood correctly:
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule playersSleepingPercentage 33");
or do i apply it to the world ?
can't you set gamerules with the api instead of doing it this way?
yes
iirc u can with the world class
this should fix it?
else if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase("ยง2Sellwand") && !e.getPlayer().getInventory().getItemInMainHand().equals(new ItemStack(Material.AIR))) {```
too lazy to start up my localhost
do something like
or should i return it in the event start?
if(item == null || !item.hasItemMeta()) return;
comparing to Material.AIR could produce a nullpointerexception
hasItemMeta
Thank you both ! @buoyant viper
np
np
like this?
i'm not sure if it can return null or it just returns an air itemstack
how should i use that in my case?
you should also check if the item in main hand is null
.getType()
gimme a sec
not .equals
hmm
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
if(item == null || !item.hasItemMeta()) return;
Bruh lmao
I am not naming any sites but already found a thread up asking for my plugin leak and it has like 4 downloads ๐ญ
.
yeah
just check for meta then
i once found a site that had a leaked resource but they said it was by me when it wasnt
๐
They said you leaked it yourself?
no they said i made the resource they leaked
Oh
but i had nothing to do with what they posted
Weird lol
i think i had a similar name to the actual dev or something
I made an account and replied to the guy acting like some big time leaker I was like yeah bro not gonna waste my time on this
lol pulling the no u card
i still do not know? can you help?
also i was wondering if i should just load an user object to the cache from the database (async), wait until its there and return it?
how can I push the player forwards?
I think adding velocity in the direction of player would work but idk hwo to get the player's direction & convert that to vector
is this something?
return forkJoinPool.submit(() -> getUserFromDatabase(uuid)).join();
If you comprise your plugin name of only 4 letters or less words then that site refuses to search for those โtoo-smallโ words
just another ghost ping at me here O.o
player.getLocation().getDirection()?
how do I add velocity in that direction
CompletableFuture.runAsync(() -> {
try {
return database.fetch(id);
} catch (Something e) {
throw new CompletionException(e);
}
},forkJoinPool);
https://paste.jeff-media.com/?8b51aca0d61e8686#227ehNDYTDsSs7Y1ZEfNdihnz27bs93fih3SQoSy3nqM
I once made this for Drop2Inventory. Maybe someone has an idea on how to do it without "hardcoding" all those blocks?
Post and share your source code or server logs here.
Add a new vector to it.
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
changed it little but yeah
oh perfect. didnt know it exists!
yeah if I add a vector to player's velocity it will add a vector in a set directino
or did you add it today?
thx for contributing
You can multiply the current vector, so that the direction stays the same
what if the current velocity is 0?
is there a way to accept itemstack array in annotation?
create a custom anootation?
fourteen
im bad at this stuff i know
it says it is not valid member
let me write an example of how you might wanna handle a data model if you're fine with that?
sure
p.setVelocity(p.getLocation().getDirection().multiply(multiplier));
smth like this?
Try it, play around
https://tryitands.ee ๐
can someone help me
maybe tell us what you need help with?
ok
i made this but i want only my own custom item to use this
You can only have compile time members, and objects like item stacks are runtime
just check if the player's held item is your item
how do i do that i am noob
if?
As annotations are initially processed at compile time
so the best alternative is to change it to interface, and have method with return value of ItemStack[]?
Yeah i guess
ok
But then you cant use it as an annotation i think
not helpful enough
?learnjava
idk how im suppose to explain an if statement to you
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.
also conclure wtf are you writing
a novel
a novel
lol
i
i cant seem to be able to get contents of a dropper
class User {
final UUID id;
volatile String username;
volatile int points;
User(UUID id) {
this.id = id;
}
//constructos, getters and setters and yadayadayada
}
@FunctionalInterface interface UserFactory {
User newUser(UUID id);
}
class UserRepository implements Iterable<User> {
final Map<UUID,User> map;
final UserFactory factory;
UserRepository(Map<UUID,User> map, UserFactory factory) {
this.map = map;
this.factory = factory;
}
public User getOrCreate(UUID id) {
return this.map.computeIfAbsent(id,factory::newUser);
}
public Optional<User> getIfPresent(UUID id) {
return Optional.ofNullable(this.map.get(id));
}
public Iterator<User> iterator() {
return this.map.values().iterator();
}
}
interface HumbleStorage<D> {
void bootUp();
void shutdown();
void load(D data);
void save(D data);
}
class DelegatingStorage<D> {
final HumbleStorage<D> storage;
final Executor executor;
DelegatingStorage(HumbleStorage<D> storage, Executor executor) {
this.storage = storage;
this.executor = executor;
}
void bootUp() {
this.storage.bootUp();
}
void shutdown() {
this.storage.shutdown();
}
CompletableFuture<Void> load(D data) {
return CompletableFuture.runAsync(() -> {
this.storage.load(data);
},executor);
}
CompletableFuture<Void> save(D data) {
return CompletableFuture.runAsync(() -> {
this.storage.save(data);
},executor);
}
}
class MySqlHumbleUserStorage implements HumbleStorage<User> {
public void load(D data) {
//TODO implement
}
public void save(D data) {
//TODO implement
}
}
class PluginDerivative extends JavaPlugin {
DelegatingStorage<User> userStorage;
UserRepository userRepo;
void onEnable() {
int parallelism = Runtime.getRuntime().availableProcessors() * 2;
Executor executor = new ForkJoinPool(
parallelism,
ForkJoinPool.defaultForkJoinWorkerThreadFactory,
(t, e) -> e.printStackTrace(),
false
);
this.userRepo = new UserRepository(new ConcurrentHashMap<>(16,0.25f,parallelism),User::new);
this.userStorage = new DelegatingStorage<>(new MySqlHumbleUserStorage(),executor);
this.userStorage.bootUp();:
this.getServer().getOnlinePlayers().forEach(player -> { //load all players in case of a reload
User user = this.userRepo.getOrMake(player.getUniqueId());
this.userStorage.load(user).join();
});
}
}
@tardy delta sth like this
currently the way im getting inventory is
Dropper d = (Dropper) e.getClickedBlock();
and then
Inventory inv = d.getInventory();
and then i get the needed materials blah blah blah
now you probably want to call the shutdown() method in onDisable
I have a feeling you wrote that in discord,i hope not
I did lol
what did you try?
here
@tender shard
okay wow... thats a flex
You can't cast blocks to droppers
You must get the block's state and cast that
is it? Ig hehe
i mean ik what is an if but idk what to write
?
depends on Retention
if (playershelditem == youritem)
c means dropper btw.
like this?
I said initially, not only
I think that retention doesnt matter for compile time
I think it is always processed at compile time
annotations works as documentation aswell
yeah they're always there at compile time in principle given that the annot is defined on the compile classpath
It is always processed at compile time, and it can be at runtime with the correct retention
yep
whoa that looks massive
all those classes
yeah well usually you want some sort of cleaner/invalidation manager/housekeeper (as well)
so you have an object which is responsible for clean up and one for the caching and one for the actual persistence
if i have Class<? extends Event> and i want to register handler for that event, how would i do that?
PluginManager::registerEvent exists
tho you need to pass down a listener and event executor as well
hmm yeah well that class is arguably breaking the single responsibility principle
in listener, how would i declare method? i only have Class<? extends Event>, i don't know which event it is
well you'd have to match a method in your listener with the class by using reflection for instance
rly depends on what exactly you're trying to achieve here
suppose i have a Consumer<? extends Event> and Class<? extends Event> and i want that consumer to be called each time that event happen, with that event as argument
oh
interface EventHandler<E extends Event> extends Listener, EventExecutor {
void invoke(E event);
default void execute(Event event, Listener listener) {
this.invoke((E)event);
}
static <E extends Event> void register(Plugin plugin, Class<E> eventType, Consumer<? super E> handler) {
EventHandler<E> handler = event -> handler.accept(event);
plugin.getServer().getPluginManager().registerEvent(eventType,handler,NORMAL,handler,plugin);
}
}```
Maybe you're looking for something like this?
whats the default falling velocity of an minecart if you dont set any
yeah, probably that is what i want, thanks
nothing works i am using PlayerInteractAtEntityEvent event
i still do not know? can you help?
Is it possible to set the default Bungee Server whit a plugin?
why is team.getPlayers deprecated?
not all members have to be players
how can I get all the player in a team
elaborate