#help-development
1 messages · Page 1906 of 1
When a player is made to log on/swap servers via bungeecord
package me.lumina.luminassw.comands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class mvCore implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player)sender;
if(cmd.getName().equalsIgnoreCase("map"))
{
if(args.length == 0)
{
if(args[0].equalsIgnoreCase("CandyLane"))
{
Bukkit.dispatchCommand(player, "/mv import "+player+" Candylane/Candylane");
player.sendMessage("[DEBUG]Command_EXCUTION_SUCCESFULL");
}
if(args[0].equalsIgnoreCase("Shaohao"))
{
Bukkit.dispatchCommand(player, "/mv import "+player+" Shaohao/Shaohao");
player.sendMessage("[DEBUG]Command_EXCUTION_SUCCESFULL");
}
}
}
return true;
}
}
Conclure sounds like they know a lot
Backend servers consider a server switch to be a quit
Gl
The plugin yml and the error and the main plugin class also
alr!
the error is just the /help error
plugin.yml:
name: LuminasSw
version: '${project.version}'
main: me.lumina.luminassw.LuminasSw
api-version: 1.8
commands:
kit:
description: Gives kit with the argument of type
usage: /<command> <kit type>
aliases: [k]
End:
description: Ends the game with the winner given
usage: /<command> <winner>
aliases: [w]
start:
description: Starts the game
usage: /<command>
aliases: [s]
mvCore:
description: Map Selector!
usage: /<command> <map>
aliases: [m]
refill:
description: Refills armor
usage: /<command>
aliases: [r]
main:
getServer().getPluginManager().registerEvents(this, this);
getCommand("kit").setExecutor(new kit());
getCommand("End").setExecutor(new End());
getCommand("start").setExecutor(new start());
getCommand("refill").setExecutor(new refill());
getCommand("mvCore").setExecutor(new mvCore());
getServer().getPluginManager().registerEvents(new LuminasSw(), this);
that is not the complete class lol
You named it mvCore and your code says map
well its a command that changes the map
idk
What are you typing in game? /map?
yeah js is weird
i call it variable function
It’s due to lambda calculus
yes
Yeah, you're registering mvCore, not map
Lambda calculus is a powerful theory where everything essentially is anonymous functions
how does the description matter
Which then also provides us with some cool proofs and some other niceties, especially when implemented in programming
getCommand("mvCore").setExecutor(new mvCore()); is not a description.
You're straight up registering a completely different command than you're executing.
oh...
Same thing in your plugin.yml
hmm so just change the cmd.getname to mvcore?
Yeah, or change the plugin.yml and the getCommand to map
hmm alr
I’m assuming this is related to the PR I submitted to your website
Also what was that last function for
i looked into liveatlas history
The one you just named “a”
and saw a commit "switch to lambda"
testing page switching
its for the button
purely for debugging ofc
i dont see anything wrong with it tho
but yes
i consider switching to json file to define pages
There are better ways to pass data in JavaScript, not storing it in the webpage title
What if you want to change the format
Then you gotta rework your regex and all that
It’s just as bad as when you use inventory titles to identify inventories
^ this is a good analogy
hmm i run this and i wasnt moved
?
You are using javascript
JSON.stringify(object)
JSON.parse(string)
hey you guys
What
for some reason PROTECTION_FALL
then what does the WATER_WORKER enum do?
They have descriptions if you look at the javadoc
thx
What is the method to get a material from a chunksnapshot at a given coord
im assuming something like this:
snapshot.getBlockType(Math.abs(location.getBlockX() % 16), location.getBlockY(), Math.abs(location.getBlockZ() % 16))
chunk snapshot ? do you mean a section or the complete chunk ?
x >> 4, y, z >> 4
So, im currently trying to store this into a gson document, anyone have any suggestions?
private Map<String, Location> homes;```
will give me the chunk coords no?
ah i see, its probably x (1 to 16) and z (1 to 16)
so basically what i wrote is true when x and z are real world coords
i think its 0-15
basically i wanted a "good" way to go from location -> Location in snapshot but i think i just worked it out
use >> 4 instead of %16
(location.getBlockX() - chunkX * 16, location.getBlockY(), location.getBlockZ() - chunkZ * 16)
works now
packets
oops
basically no big difference ... but >> 4 is (maybe a lot) faster
sorry
yeah i do use the bit manipulation to calculate the X & Z already
How do i make a join listener in kotlin?
like you did in java
No. it does not work. i follow a yt tutorial and it just keeps showing errors.
Usually kotlin devs use an extension inline function
what
This def looks like kotlin. lul. Why do you want to use kotlin if you dont even know the language?
bruh im learning
wtf
🤨
Did you learn another language first?
Do you know why it doesnt work ?
Sure. Because you dont write anything that even looks close to kotlin code.
Why did you decide to go for kotlin? You will have a much bigger community
and a greater amount of resources if you just learn java first.
I just switched from the jar library to maven and noticed this
Do i have to use ChatColor.COLOR instead of §?
I heard that you should do that but i never changed my old code
Nope. This happens when using the wrong encoding.
What spigot version do you use?
1.16.5-R0.1-SNAPSHOT
In your pom add a property for the source encoding:
<properties>
<java.version>yourJavaVersion</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
i had the same problem when i copy&paste my old projects to intellij with maven instead of eclipse ... i just kept hitting run because it shows me every class that had § translated to some bullshit char xD
Do i need to register custom entities in 1.18?
not rly ... but depends on what exactly you do
Custom falling block
how about creating a class extending Listener ?
The same way as you would with Java but with kotlin syntax.
you can name it how you want... it depends on what your code does ... and how you use the code
if you just extend FallingBlock and then create the obj with your constructors and then add it to the world you wont need registration
Btw how do you register custom entities in 1.18?
i dont register custom entities
it rly sucks to register them too
what do you want to do with it when its registered ?
Quite difficult. You will have to follow the breadcrumbs and make sense of mojangs Registry classes
This doesn't seem to work for me, or i did something wrong somewhere else
I think you accidently used registerEvent, instead of registerEvents
can you show the code where this msg is set ?
Its the file encoding. 99% sure
Also make sure the file encoding in IntelliJ is set to UTF-8
<maven.compiler.target>8</maven.compiler.target>
<java.version>8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>```
"§fRang",
"§7Todo", "",
"§6Coins",
"§7" + MySQLCoins.getFormatedPoints(board.getPlayer().getUniqueId()), "",
"§eSpielzeit",
"§7" + MySQLPlaytime.getFormattedTime(board.getPlayer().getUniqueId()),
" "```
Germanus
Don't have to but it helps with readability
What are these "identities" that are returned by the api in getAuthor and findAuthor Also is there a list of them?
Well linked accounts
where do you link them on the site?
How do I set the player prefix in the list tab? (packet & PlaceHolderAPI)
I only know how to link discord
how?
Usage: !verify <forums username>
What is the alternative for setPassenger() since setPassenger is deprecated?
read the docs
Thank you 🙏🏼
can I use Player.addAttachment(plugin, "perm", true) to grant a permission to a player?
I'm a little confused on what exactly it does
yes
👍
Hello
how i can add prefix to members in the tab ? (PlaceHolderAPi)
get TAB plugin
u can have the prefix in the tab AND for nametags if you want
everything configurable
its a VERY good plugin i HIGHLY recommend it
its completely free
How does an entity appear to have an aura and only a specific player can see it? As with pillager when ringing the bell.
You need to turn SS off
I'm so confused. how do i remove a permission from a player
and does using addAttachment just... add the permission?
SS?
Do you have a permission manager plugin
No
Why can't i just use addattachment tho
what even is a permission attachment
what is SS?
You need a permission manager
LuckPerms is the best
who tf cares, also i am asking for development help lol
Why
I thought that's what addattachment was for
To edit permissions for players
What the hell does addattachment do then lol
No but addattachment is garbage dont use it
this guy is crazy
what does it do
Because it supports SS
ss?
Use luckperms
pls help me
what is ss
@feral plank did you ever seen this button ? pls use it pls
why
It means shity sharbage
what is he even doing lmao
stop talking to me im not talking to you so leave me alone and stop bugging me if u think im crazy ignore me block me idc
listen
this channel is for plugin development
u should to the same
I am just trying to help this person
not for fucking help about luckperms or TAB
dude im asking how i can use code to add attachments
with him developing his plugin
ur a dumb
You got to use luckperms
Its the best permission manager
but
😂
why
Dont you want to give ppl permissions or sf some perms
Yes, cant i just use the spigot api
no?
what's addattachment then
just tell me
i just want to know at this point haha
what it is and why its so bad to use it
idk just hit that if that works idk
its a discord sponge plugin
doesnt even work
its supposed to be an addon for discordsrv which uses SS that is for sponge
just gimme ur adress i'll kill u
u r a virus for humanity
0_0
Addattachment
bet
i dont even get it what is he doing
LMAO
xD
bro
Wait
you just posted that so blatantly
i'll pay anyone 100$ to ban this guy
idek if you don't know what's going on
Be aware that posting such links is a bannable offense
Oh ok ima delete
dude he did nothing to you, something is not getting across here stfu
idek why ur so mad
no i did not
idk
i did not ask for a download button
did u
no
This is the official site for downloading luckperms:
https://luckperms.net/
I just came here. Could you elaborate the problem?
can someone help me how do i turn off mob despawning
so my citizens npcs dont despawn when their type is a mob
is there like a setting for that in multiverse or in another plugin or server setting of smth
for this guy too, 200$
I want to know what the method addAttachment does under player
I thought it just added a permission, plain and simple
but now everyones talking about perms managers?
i am very confused
Why do you need something to manage the permissions, shouldn't setting the permission under the player be enough?
You need it for alot of things
Its very important
IT Dont use SS
It will add a new PermissionAttachment which is basically a container that holds permissions of a player.
Those are usually handled by permission plugins.
It is for discordsrv
if so, shouldn't the server just keep track o that itself?
To the Permissible which could be a Player for example.
no it is not dude you are talking about a completely different thing
yeah, i get that
why do you need to manage it?
that's... managing it
right?
DeluxeHub is better
Its the best permission manager
Forget luckpoerms
It is nt ss
then download Illusive Endportals, so the endportals look cool
And EssentialsK
not EssentialsX
this channel is for developing plugins
Yes
not for managing servers
U need those
Just ignore them
I dont need help server
I dont have a problem im just trfghj to help
I try to help my
its like @feral plank
ok yk what this channel is just going straight to hell im opening a thread
Handling permissions can get quite complex if you want to have a limited or broader scope.
For example having permissions that are only applied in the nether. Or a permission that should be given
for 5 minutes. Or a permission that a player should obtain across a whole bungee network.
You dont need a permission manager but it makes handling permissions a bit more comfortable.
However there is nothing from stopping you to just add a PermissionAttachement to a Player and
adding all the permissions you need to it.
You need to have LuckPerms
Eat bananas
?kick @sage patio off topic
Done. That felt good.
You need Super Crates plugin for that
what is going on
You need ChatControlPro plugin to say that
What packet should I send to a player to dismount a vehicle?
Please stop spitting out random things just like that
how do i turn off mob despawning
so my citizens npcs dont despawn when their type is a mob
is there like a setting for that in multiverse or in another plugin or server setting of smth
can you pls help me with that
pls
Be patient
programmatically you would tag them as persistent
declaration: package: org.bukkit.entity, interface: Entity
Just because it's 1.18.1 javadocs doesn't mean it's not present for 1.12.2.
oh ok
Update to a supported version and then use
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html#setPersistent(boolean)
declaration: package: org.bukkit.entity, interface: Entity
void setPersistent(boolean persistent)
Sets whether or not the entity gets persisted.
Parameters:
persistent - the persistence status
See Also:
isPersistent()
how do i do that
is that what i need to do
to stop mob despawning
the same way you call every other method that belongs to any object
Probably
any plugin to turn off mob-despawning or setting or any possible way thats for 1.12.2 bukkit/spigot servers
But 1.12 is not supported anymore
I also have doubts that Citizens would improperly handle NPCs and allow them to just despawn though, or they at least have a setting for it.
if they are mobs they despawn
they act like normal mobs
OHHH
wait
is it because
i have the name plates off
i toggled the name plates off
nice
and dont they need name plates to not despawn
but i dont want the name plates
so what else would i do
I have a feeling that this is not a development related question...
It isn't.
#help-server <- Then go there
Because no one answers in help server
Then make a thread on the forums.
@feral plank please move to #help-server and be patient, I have told you already
ok fine
Thats maybe because you are having a niche problem for an unsupported spigot version
You’re not entitled to instantaneous help just because you haven’t figured a solution out yet
i figured it out
i need to turn nameplates on
ill just put the name as nothing
i can only do that in the config
so ima do that in the config
Hey, so when I use
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
}
The plugin in import org.bukkit.plugin.java.JavaPlugin is red and it says cannot resolve symbol 'plugin', and the JavaPlugin in public class Main extends JavaPlugin is red as well and says cannot resolve symbol 'JavaPlugin' I have no clue what I did wrong
I'm following this: https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-intellij-idea/#wikiPage (1.18.1 spigot)
slimmer shady
Yeah?
nope
doesnt do any difference
did you add spigot as a dependency
Yes
?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
what he said
Both BlockPistonExtendEvent and BlockPistonRetractEvent
I found it already but thanks 🙂
Is there a link for the associated remapping-mojang variables to the standard obfuscated variables for 1.17.1?
Suffering apparently
It should work somehow like this:
HashSet<EntityType> entities = getEnumFromList(someList,new HashSet<>(),EntityType.class)
but no idea how to properly define the type parameter for the collection D:
Can you even do C<E>?
no idea
actually java should know that C has type parameters because C is defined as C extends Collection<E>
public static <E extends Enum,C extends Collection<E>> Collection<E> getEnumFromList(List<E> list, Collection<E> collection) {
}
but now I'd have to cast it
it should specifically return C<E> instead of just Collection<E> 😦
Idk doesn't seem possible for it know if C<E> is even valid
public static <E extends Enum,C extends Collection<E>> C getEnumFromList(Class<E> enumClazz, List<String> list, C collection) {
this seems to work 🙂
generics make me want to die inside
they are also fun though 😄
what in the hell is that method
for stuff like this
let's see whether this works lol
public static <E extends Enum,C extends Collection<E>> C getEnumFromList(@NotNull final Class<? extends E> enumClazz, @NotNull final List<String> list, @NotNull final C collection) {
for(final String element : list) {
final E value = (E) Enums.getIfPresent(enumClazz, element).orNull();
if(value == null) {
JeffLib.getPlugin().getLogger().severe("Could not find " + enumClazz.getSimpleName() + ": '" + element + "'");
continue;
}
collection.add(value);
}
return collection;
}
Return type is just C. Its already in the scope of Collection<E>
yeah I'm already done with it^^
C is also obsolete in this static context btw.
which C?
C is the return type, how would I not need it?
Why do you pass a Collection in there if you just return it anyways?
I don't understand that question
What is the reason for that passed collection?
The ability to decide what type of collection it returns
Set<EntityType> entities = getEnumsFromList(getConfig().getStringList(EntityType.class, "allowed-entities", new HashSet<>());
List<Material> blocks = getEnumsFromList(getConfig().getStringList(Material.class, "blocks", new ArrayList<>());
I think that should be concrete. Looks really weird to me.
i am still so lost in what this method is for
for this?
imagine a config
oh nvm the first line actually puts a lot of context
allowed-entities:
- ZOMBIE
- SPIDER
blocks:
- DIRT
- GRASS_BLOCK
yeah
is there a way to force a player to right click?
hack their computer
How about
public <E extends Enum<E>, C extends Collection<E>> C getEnumFromList(Class<E> enumClass, List<String> values, Collector<? super E, ?, C> collector) {
return values.stream()
.map(entry -> Enums.getIfPresent(enumClass, entry))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(collector);
}
also I can't print out an error message like this when someone uses invalid names
as I only have an Optional now and not the original string anymore D:
Sure you can
one moment...
public static <E extends Enum<E>> List<E> getEnumFromList(Class<E> enumClass, List<String> values) {
return getEnumFromList(enumClass, values, Collectors.toList());
}
public static <E extends Enum<E>, C extends Collection<E>> C getEnumFromList(
Class<E> enumClass,
List<String> values,
Collector<? super E, ?, C> collector
) {
return values.stream()
.map(entry -> Enums.getIfPresent(enumClass, entry))
.peek(YourClass::checkValidity)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(collector);
}
private static <E extends Enum<E>> void checkValidity(Optional<E> optional) {
if (!optional.isPresent()) {
// Print message here
}
}
I still don't have the original string there
it should e.g. print Could not find EntityType ' CREPER'
I could just put it into the map function and then filter it later again
Then do in the first map...
why tf does it say this now lmao
wrote this up real quick
public static <E extends Enum<E>> Set<E> getEnumsFromList(Class<E> enumCls, List<String> constants) {
Set<E> validConstants = new HashSet<>();
constants.forEach(val -> {
try {
validConstants.add(Enum.valueOf(enumCls, val));
} catch (IllegalArgumentException e) {
System.err.println(String.format("No value '%s' in enum %s.", val, enumCls.getName()));
}
});
return validConstants;
}```
but that gets rid of the chosable collection type D:
it's always a Set now
a list
what difference would it make
What if you had [IRON_ORE, DIAMOND_ORE, IRON_ORE]
woops, i was thinking a little literally with enums so i went with one-per
I have this now 🙂
public static <E extends Enum> List<E> getEnumsFromList(final Class<? extends E> enumClazz, final List<String> list) {
return getEnumsFromList(enumClazz, list, Collectors.toList());
}
public static <E extends Enum<E>, C extends Collection<E>> C getEnumsFromList(final Class<E> enumClazz,
final List<String> list,
Collector<? super E, ?, C> collector) {
return list.stream()
.map(entry -> {
E result = Enums.getIfPresent(enumClazz, entry).orNull();
if (result == null) {
System.out.println("Could not find " + enumClazz.getSimpleName() + ": '" + entry + "'");
}
return result;
})
.filter(Objects::nonNull)
.collect(collector);
}
}
now let's see if it actually works 😄
horrific piece of code to be honest
Doesn’t pass the vibe test
the only thing I don't like about it is that I forgot to make the collector final
Get the save actions plugin and make absolutely everything final automatically.
I just do that with Code -> Inspect 😄
btw next problem
I'll just use my first version. it's more versatile anyway since it allows to pass collections that already have items in it I guess
although probably noone will ever need that
Dont use guavas Optionals
public static <E extends Enum<E>, C extends Collection<E>> C getEnumsFromList(Class<E> enumCls, List<String> constants, Collector<E, ?, C> collector) {
return constants.stream().map(constant -> {
try {
return Enum.valueOf(enumCls, constant);
} catch (IllegalArgumentException e) {
System.err.printf("No value '%s' in enum %s.", constant, enumCls.getSimpleName());
}
return null;
}).filter(Objects::nonNull).collect(collector);
}``` basically what u wrote but no deps
You can also write a Collector that appends elements to an existing collection.
I still think that passing collections for filling is super weird
unless u want to get real soft on the filtering then u could additionally iterate through the enum constants of enumCls
for a .equalsIgnoreCase or something
Holy generics Batman
dont u love java
why not? that's what Enums.getIfPresent returns
Yes. Dont use that method.
reason?
Guava's Optionals were replaced by Java's
As well as Guava's functional interfaces, like Consumer, Function, etc.
Compatability. Future proof. And Guavas Optionals are replaced by Java Optionals.
I fancy a guava right now
then I'll just do Enums.getIfPresent().orNull again
Umm how do you check for nbt tags , Im new to spigot, Btw the item Im reffering to is not an item stack its just a regular item with nbt tag
oh i just got a horrific idea
*orElse
you don't and instead use PDC
what is PDC huh
Not through Mojang types but y'know
PersistentDataContainer
It's for storing NBT
As opposed to reading it
Maow will be the one to contribute org.bukkit.nbt maybe possibly :)
my plugin is interacting with a large datapack so please do not tell me i have to go and somehow replicate the datapack but make a plugin
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/
I honestly wouldn't recommend Fiverr just cuz a lot of the shit on there seems low-quality.
Spigot's services recruitment is better from what I've seen.
Maow soo please let it be good news and not bad
Well I need someone trusted, i've gotten scammed way to many times and im not in the mood to message some guy on discord to get it done
Fiverr isn't any more trustable :p
ive created the ultimate answer @tender shard
public static <E extends Enum<E>, C extends Collection<E>> void populateCollectionWithEnumsFromList(Class<E> enumCls, List<String> constants, C collectionOut) {
E[] enumConstants = enumCls.getEnumConstants();
constants.forEach(constant -> {
for (E enumConst : enumConstants) {
if (!enumConst.name().equalsIgnoreCase(constant)) {
System.err.printf("No value '%s' in enum %s.", constant, enumCls.getSimpleName());
continue;
}
collectionOut.add(enumConst);
}
});
}``` who needs to be functional when u can just java it
Just rewrite it using javas Optionals:
public static <E extends Enum<E>> Optional<E> getIfPresent(Class<E> enumClazz, String value) {
try {
return Optional.of(Enum.valueOf(enumClazz, value));
} catch (IllegalArgumentException | NullPointerException exception) {
return Optional.empty();
}
}
I think that's your problem
You're not looking closely into the things you use and therefore you are more likely to have shittier results
Stop rushing
alrighty ill move this to #general
Terrible idea
Oh yeah. love that O(n) complexity... One moment ill make this non-abyssmal
dont use any functional interfacing or ill personally kill u @lost matrix
Umm maybe someone else knows how to deal with already existing nbt tags
Try this
You guys aren’t writing your plugins in Haskell?
Bogosort-level complexity
otherwise ill just find some other workaround
O(wO)
two loops? also it will only ever work for the very first element and only there by luck too lol
This statement was brought to you by the python club
Who needs performance when you can just get a better machine
but what is w
Umm like if theres 100s of players complexity becomes a thing
it would work with the whole list?
im making a joke
oh
Technically not true unless the code is dependent on player interactions.
no, it loops through all enum values, then it loops through all stuff in the list and only ever puts it into the other list when exactly the first pair is matchin
(Although most plugins are, so I guess it's safe to say that)
well it does work but print a ton of error messages
yeah i realized this part
Maow cmon I need my answer which does exist or ill use deprecated methods
anything to survive
NBT is always deprecated
whyy
it's not in the API
why do they hate nbt
because it's useless to do dirty NBT stuff when there actually is an API for stuff like that, called PDC
Constant time:
private static final Map<Class<? extends Enum<?>>, Set<String>> ENUM_CACHE = new HashMap<>();
public static <E extends Enum<E>> Optional<E> getIfPresent(Class<E> enumClazz, String value) {
Set<String> enumSet = ENUM_CACHE.computeIfAbsent(enumClazz, EnumUtils::toStringSet);
return Optional.ofNullable(enumSet.contains(value) ? Enum.valueOf(enumClazz, value) : null);
}
private static Set<String> toStringSet(Class<? extends Enum<?>> enumClazz) {
return Arrays.stream(enumClazz.getEnumConstants()).map(Enum::toString).collect(Collectors.toSet());
}
foit me
Ooh this is nice.
Except for the stream.
Hello
Hello
Eh. Its only called the very first time the method is called for an enum. Should be fine.
so i made a plugin no errors now but its not working as expected
But I can see how it doesn't matter here.
Although I would make a tiny change
The result would be the exact same
But it's just a little easier to read, personally:
return enumSet.contains(value) ? Optional.of(Enum.valueOf(enumClazz, value)) : Optional.empty();
I had it like this at the beginning XD
I just think it's more clear about the intention
Although the whole Optional.of is a bit messier but eh
Whatever, still manageable
You could also put them all on separate lines
its getting a little jarring to paste it, https://paste.md-5.net/uxufihovib.java
I personally do that
this fixes the possible very large error output @tender shard

It still requires two iterations though
Still linear time
O(n * m)
It's also much harder to read.
dont worry about it
Time to maowify Smile's iteration
issue with smiles version is strict checking
mine has leniency with equalsIgnoreCase
smh
private static final Map<Class<? extends Enum<?>>, Set<String>> ENUM_CACHE = new HashMap<>();
public static <E extends Enum<E>> Optional<E> getIfPresent(Class<E> clazz, String name) {
final Set<String> constantNames = ENUM_CACHE.computeIfAbsent(clazz, EnumUtils::getConstantNames);
return constantNames.contains(name)
? Optional.of(Enum.valueOf(clazz, name))
: Optional.empty();
}
private static Set<String> getConstantNames(Class<? extends Enum<?>> clazz) {
final Set<String> result = new HashSet<>();
for (Enum<?> constant : clazz.getEnumConstants()) {
result.add(constant.toString());
}
return result;
}
Maow version ^
I made some of it easier to read and also improved a few names (and removed that stream, but that's just personal taste)
The leniency of yours also causes issues with speed
The better option would be to use Smile's but add a .toUpperCase() after the name/value parameter in the contains check
what if enum name isnt following java conventions
what if its really dumb and like
Skeleton_Horse
Then the person who wrote it sucks
(You don't actually need Locale.ROOT since Locale.ENGLISH handles it)
true but it could be an edge case...
Push them off an edge
also true
(This .toUpperCase() is not locale-sensitive so we don't need a Locale.ROOT)
Idk I guess it depends if you know what enums you’ll be using it with
Anyway
In which case
You could also just do a toUpperCase() on the toString() as well
That would effectively be a "ignore case"
This is a general purpose method that should not break the contract of javas enums.
Iron_Ore should yield null and should not be tinkered with inside this method.
Thats something another method could do with the users input.
True
Normalize to lower case like a rebel
A util method shouldn't do this, you're right
what can i say, im a rule breaker
Actually could you declare two enum constants of the same name, just with different capitalization?
e.g. IRON and IrOn
📏 🔨
If so, then you essentially always want to be strict about that name parameter
Yes
They are just constants
Oh yeah and technically you couldn't do valueOf if you did the capitalization either lol
So, @buoyant viper, truly being strict here is the best approach to support everything.
what if the enum is out of our control
like EntityType
or Material
we cant add/remove constants to it to handle different capitalizations
final Optional<E> result = getIfPresent(enumClazz, enumClazz.getName().startsWith("org.bukkit") ? entry.toUpperCase(Locale.ROOT) : entry);
```:D
Not what I was saying
That's a dumb idea anyways
then what was this about
nvm
My point was that capitalizing Iron and IrOn retrieves the same result, IRON, even if they're meant to represent different things
yeah
i read that wrong and thought you were adding different capitalizations to the enum to cover edge cases of name filtering
lmao
lole
hey how can I disable any messages sent to the player other than messages and player messages?
I wanna make a sort of /chattoggle plugin
what messages are there besides "messages and player messages"?
like server messages from an announcement plugin, clear lagg messages, buycraft messages
You’d have to use packets
dammit, was trying to avoid those
or use cglib and override the player's sendMessage function lol
The heck is cglib
I have no idea how cglib works. If you find out, let me know pls 😄
I saw an animation like this: https://i.gyazo.com/2ca109065346384a25ea85dc435b37c7.gif , but all I can make is this https://streamable.com/zs3dft by putting a pickaxe on the head of the armorstand then rotating the yaw of the armorstand
does anyone know how I would make #2 look more like #1?
Math, Angles etc 
Yes, but how in specific
make the entity orbit, dont just rotate it
I don't understand what you are describing, what I did in the gif was just increment the yaw of the armorstand in a loop
yes that is part of it
but u also need to make it [the entity holding the item] orbit around a position rather than just rotating it
How would I do that?
math, angles, etc
Again, I understand that but specifically how
move the entity X units away from the position you actually want the item to be at, make entity look at the position
so instead of moving the yaw in a circle, I should be moving the armorstand?
move the armor stand in a circle and make it look at the position yes
hi rack, look at my real discord name 😛
sup xP
I was wondering how long until you recognized me
but once I got this terrible name after I linked my spigot account it was never
I generally dont check actual names, mostly go by the spigot names lol
ah I made my spigot account way too long ago
I wonder in your case if it would be possible to set the pickaxe on the head of the armorstand, and then rotate it around. I know you can put certain items on a players head so that might be an idea
nope, it isnt
Yeah that'd be too easy lol
that gif I sent is the pickaxe on the head
oh yeah, forgot entities can kinda wear anything
I have to figure out now how to get the locations of the circle around the center then ig
yeah haha
well scratch my idea completely if u could just do the other 1 idk
what other idea?
wear item, rotate
thats what I'm showing
it revolves around the circle
since it's like an item only on the front of the head
Can you show a gif of it with the armorstand visible?
I mean an orbit isn't hard to do you just need to use a formula
do you have the formula?
just steal it from cosmic /s
can an armor stand not wear a pickaxe on its head?
Does that work? Cause otherwise you're doing orbiting
ig u just gotta orbit then yea
You'll need a center, a radius, and knowledge of degrees/radians whatever MC uses.
Now step 1 is to make the armorstand rotate around the fixed point
like a planet around the sun
this is a very dumb question. in a class called commands i have a /start command. i want to define a variable that my other class "events" can use. I want this becuase the events should only execute if the /start command has been run
https://www.youtube.com/watch?v=aHaFwnqH5CU time to go back to school
This video explains how to determine the coordinates of a point on a circle given an angle and the radius of the circle.
Site: http://mathispower4u.com
Blog: http://mathispower4u.wordpress.com
how do i check event player's world?
Event players? You mean the player you get from an event?
yes
getLocation().getWorld()
yeah, this is unideal 😓
ty ^^
I mean it's always good to learn how to do it. It's not that hard
it is essential to know
why cant i call getlocation (non static method)
hmm thnx ill try
i mean, you know that it isn't a static method
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 was, for a moment, thinking that -> is a dereference operator
lmao
how can I make an armorstand look at another location?
You mean you know the location you want it to look at?
Well let's say stand is the stand and loc is the location you want it to look at
yeah
what do we look like to u, c++?
Vector v = loc.clone().subtract(stand.getLocation()).toVector();
Location standLoc = stand.getLocation();
standLoc.setDirection(v);
stand.teleport(standLoc);```
would I be teleporting to standLoc?
Oh yes, my bad
okay this is gonna sound weird but I'm not really wanting to look at directly point
I want the armorstand's right side of the body to be looking at the point
I'm hoping for the pickaxe to stay in the center
would that be possible?
Determine how far the pickaxe is from the center
I've read online that it's 0.3125 radius from the pickaxe to the center of the armor stand body
I'm not sure it's true but I can test with different values if I know what I'm supposed to do
Looks to be more than that
Then it becomes easy
You take the point where you want the pickaxe to be
And you also need the angle you want it pointing at
Then you create a vector
Location loc; //Center
loc.setPitch(0);
loc.setYaw(angle); //I forget if it is degrees or radians
Vector v = loc.getDirection().multiply(0.625);
Location standPos = loc.clone().add(v); //Location of the stand
standPos.setDirection(v);
stand.teleport(standPos);```
lmao help how do i check an event player's world
getPlayer().getWorld()?
whats the max duration i can set here?
Integer.MAX_VALUE
oh yeah completely forgot abt that!
hm what could I use instead of ??? in the javadocs?
/**
* Returns a new array of the given class type with length 0
* @param componentType ???
* @param <T> ???
* @return Array of the given class type with length 0
*/
public static <T> T[] createArray(@NotNull final Class<T> componentType) {
isn't that actually both always the same? 😄
What is wrong with this bruuh:
if(event.getPlayer().getWorld() == "Game2"){
}
it's weird to have to give a description for both
Maybe read docs
yea true
?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.
What does getWorld() return?
Because I can guarantee it's not a String
It's a World
hmm
And you shouldn't use == for String comparisons to begin with
You want
getWorld().getName().equals("someName")
yay
Would it be possible to make my plugin only work on a certain server? Or only work when I am on the server?
But I think you should make sure you have a fundamental understanding of why that is the case
I'm confused, this is what it looks like now: https://streamable.com/iig2yz here's my bukkitrunnable code: ```java
BukkitRunnable br = new BukkitRunnable() {
@Override
public void run() {
int i = Math.floorMod(rotation.getAndIncrement(), 80);
for (ShowedItem item : showingItems) {
var b = item.locations().get(i);
item.stand().teleport(b.location());
Location loc = item.loc(); //Center
loc.setPitch(0);
loc.setYaw((float) b.angle()); //I forget if it is degrees or radians
Vector v = loc.getDirection().multiply(0.625);
Location standPos = loc.clone().add(v); //Location of the stand
item.stand().teleport(standPos.setDirection(v));
}
}
};
Oh I forgot some of the math
but cant resolve method event.getPlayer in playerdeathevent :/
?jd
bruh
im dying
All of these things are easily found in the javadocs
@rancid snow Can you send me the code for spawning the armor stand initially
why is this grey'ed out?
I will try this myself and show you the resulting code when I get it working
because its not used
well, it is, but isnt
actually no it isnt bc theres no @EventHandler over it
oh yeah!
yeah, sure: https://paste.md-5.net/yanerilope.java
but even after that itd still be grayed out i think, dont worry about it
nope it isnt
interesting command registration
btw you didn't add @EventHandler
told him that
yep ty
lol why do you register your commands in the most cursed way you could thought of?
"lol are do you register..."
I don't usually, my brain is turning to mush as red can tell you I've been working on this for days straight
I usually use redlib for my projects
Would it be possible to make my plugin only work on a certain server? Or only work when I am on the server?
yes, and yes
How so?
yea, but why should u?
can you describe the problem
Trial plugins.
don't give your plugin to other server admins
they can't use it if they don't have it
very true
whats a trial plugin
The point is to make plugins for a server, and have it restricted to that server in case the owner of it decides to share it.
just in the onEnable, check to make sure they have access by doing an api call or something, and if they dont, then return early from the onEnable
and then wait for someone to remove this "protection" within 2 minutes
well yeah, security is a when question not and if question
you can ofc obfuscate it if you want more protection
Not like I'm giving out the source code
this^
obscurity does not equal security
java decompilation is basically the same thing as giving away the source code
but it usually is a good enough deterrent
If people keep taking computers from my office, and now I start screwing them into the desk, it's not an unbeatable security
but it's much harder, and takes time to break
or get a proper obfuscator 😄
not sharing a plugin isn't a reasonable approach when you're making a plugin for someone else
Unless your plugin worth a fortune, I dun see a need to do what you want to do
not saying you should open-source it or openly-distribute it
just to have the knowledge of how to keep things secure when I want to restrict it to a singular server (whenever I give the plugin to someone, and they attempt to share it)
I just started learning a few weeks ago, so I'm just planning ahead is all
then this is sufficient
I've made good progress, moving into world manipulation
I mean if you want the truth someone could spend a few minutes injecting code into your jar to nullify any check you do. Unless you write something that's a pain for people to use it's not worth the time imo
didn't know it was so easy to do these things
a really basic way to /protect/ a program is a killswitch, plugin checks a central server and if server says no, kill plugin
everyone can remove it within minutes if you don't properly obfuscate too
that requires some sort of db tho, right?
u could use a pastebin if u really wanted
but if you want proper management, a DB is needed
This method of doing things is best. It's simple, efficient and if someone cracks your jar most server owners will feel much safer using the real deal. Not only that but you can verify if they've bought it when they come to you for support
I just have a mariadb for blacklisted spigot IDs
ie?
Galaxy brain open source your plugins for everyone to use 
see honestly I have no idea how to do these things yet, I'm still on the surface of command making and event handling
going to do this for most plugins tbh
@rancid snow
idk youd have a pastebin document and when the content is true, the plugin will do its initialization sequence, if the content is false (or anything that isnt true), dont load
youd send an http request from the plugin on load or on enable
Kinda shaking a bit.
Yeah it's not 100%
also decide what happens if pastebin is down or the server has no internet. should the plugin be disabled then? or not?
The distance was definitely not .625
Probably need to tilt the entity a bit if that's even possible
id say if it cant access central server just kill it for safety
Yeah I'm not here to fiddle with the tiny margins in the numbers
wtf how
I was here to get it working
please share
@CommandHook("test")
public void test(Player sender) {
if (stand != null) {
stand.remove();
stand = null;
}
Location loc = sender.getLocation();
loc.setPitch(0);
stand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
stand.setVisible(false);
stand.setArms(true);
stand.getEquipment().setItemInMainHand(new ItemStack(Material.DIAMOND_PICKAXE));
stand.setRightArmPose(new EulerAngle(Math.toRadians(-9), Math.toRadians(90), Math.toRadians(90)));
float[] angle = {0};
Task.syncRepeating(() -> {
loc.setYaw(angle[0]);
Vector v = loc.getDirection().multiply(0.8);
Location tp = loc.clone().add(v);
Vector facing = v.clone().rotateAroundY(Math.toRadians(-90));
tp.setDirection(facing);
stand.teleport(tp);
angle[0] += 5;
angle[0] %= 360;
}, 1, 1);
}```
only thirteen?
.8 seems really close to the actual distance
i think im on about 57 right now
what was the method to get a block's optimal tool to use
tysmsmsmsmsmsmsmsmsmsmssmsm
there is none
you can check my messy code https://github.com/JEFF-Media-GbR/Spigot-BestTools
why not? the real problem is that they are all in one package
because I was a java noob 2 years ago
I would imagine that's clientside
but how would that help. e.g. some items require certain tools or enchantments
what information do you actually need?
getting the BEST tool for a block? or just checking if it would drop anything?
declaration: package: org.bukkit.block, interface: Block
and the method below, isPreferredTool
Oh
In that case, you could just try all the tools
Sword, axe, shovel, pickaxe, shears, hoe, I'm probably missing at least one
where is the Task class from?
RedLib
ohhh ok
getting a error for PlayerJoinEvent:
Caused by: java.lang.NullPointerException
Code:
public class LuminasSw extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
getServer().getPluginManager().registerEvents(this, this);
getCommand("kit").setExecutor(new kit());
getCommand("End").setExecutor(new End());
getCommand("start").setExecutor(new start());
getCommand("refill").setExecutor(new refill());
getCommand("map").setExecutor(new mvCore());
getLogger().info("Luminas sw was Started successfully.... ");
}
@EventHandler
public void onJoin(PlayerJoinEvent event){
Player player = event.getPlayer();
player.addPotionEffect(PotionEffectType.FIRE_RESISTANCE.createEffect(Integer.MAX_VALUE, 255));
player.addPotionEffect(PotionEffectType.SPEED.createEffect(Integer.MAX_VALUE, 2));
}
Well can we see the full stack trace
Because a NullPointerException is caused by trying to access something which is null
Any one of the things you're accessing here could be null
?notworking
"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.
its onEnable
t me.lumina.luminassw.LuminasSw.onDeath(LuminasSw.java:48) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_272]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_272]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_272]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_272]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
this might help
are ur commands registered in plugin.yml
onDeath

