#help-development
1 messages ยท Page 1705 of 1
If you mean <init>, that's a constructor, vinny
oh
like this
I am updating the block data before setting it back
nvm i haven't registered it in plugin.yml
vinny, ehm, I don't kotlin, but I'm going to assume the Java equivalent of that would be an init block just without the init keyword
nah is not this
I'm trying to redo this code in java, but I had problems
Those init blocks are called regardless of the constructor used
let me test it
god:
description: Become a god
permission: minespace.god
default: op
usage: /<command>
is like that good registered?
ye ye
the command is registered
but i mean
in the plugin.yml
the permission is ok?
the code is here
of the command
the permission i mean
but
i'm in op
and i can't send the command
it says the message that i don't have permission
if you are op and you have set a permission in your plugin.yml, you have an error on startup
or you have another plugin with a god command
@eternal oxide When I set the type of a block and get the block data afterwards, the block data should inherit all apropriate interfaces for that material, so why is setting type -> getting data -> updating data -> setting updated data wrong?
to test your issue use the createBlockData from the Material, then use that
No change
don't understand wdym
no
is it possible to find the best item suitable for mining a block, for example:-
For Ores its a Pickaxe (since it drops items)
but for sand its Shovel (even tho u can get sand from mining with ur fist)
and log is Axe (even tho u can get the log from from mining with ur fist).
without hardcoding every block in the game ?
indentation is wrong or your commands are formatted incorrectly in your plugin.yml
yes, wrong
; instead of a :
config;
ty :)
main: com.hitman.firstplugin.Main
name: TestPlugin
author: Hitman
description: Config
version: 1.0
commands:
config:```
@waxen plinth what is Void for
???
how can this produce a npr if i return?
nvm
How am I supposed to know what you mean by this
@NotNull
Optional<Void> method() {
return Optional.empty(); // Nonnull return
}
idk why you'd need this though
If item is null
This is completely useless
But Void is a boxed unit type
yeah but why what does it do
How do I get the sound for placing a specific material?
In this case, null
well but item is uninitialized if i return?
What is the lowest Spigot version I can go with that has only minor breaking behaviour upwards? Basically, what should I pick to support as many versions as possible including the latest?
1.13
I saw 1.13 broke some fairly serious stuff
will this work or not ๐
An example is if you're passing a lambda
Okay, thought so. 1.13. handles materials differently or something like that, right?
And it requires a Function<T, U>
You have a function which provides a value while taking in nothing
the only use i see is a Future<Void>
You could pass in a Function<Void, String> or something
Yeah that's another valid use
No, the classes will overlap on classpath and everything will be invalid. You need to go with a custom approach when you want to support such a broad scope of versions.
if i do new ItemStack(null) what will that do?
No, they won't overlap on the classpath but it still would be a pain.
throw an exception?
Probably
I can take a look at the implementation
I've never tried it
ah
I mean, I don't know why people ask questions for things they can very easily test themselves
From where though?
Seems about right
Like what class is throwing it?
Constructor does not check it
.
You answered yourself
It is denoted as @NotNull so you will get some issues definitely. @NotNull will not keep you from trying it
Very little will stop you from doing what you want in java
If you're persistent
For example, you can instantiate new enum values at runtime
it calls the deprecated one i assume
compiling? pah, me and the homies do runtime manipulation
using java as intended? pah, me and the homies use reflection (yes, don't flame me)
No, that's just a different constructor that is not supported anymore.
um seems like it doesn't work, as i intended it will
any other idea ? Found another way to do this with using that method and breakSpeed method
well the constructor with (Material type) keeps calling this(...) and ends up with that
This is like the best way you can go, I am surprised this is even in the API.
How would i check if the top inventory that the player is seeing is a chest using InventoryClickEvent?
Oh you are absolutelty right
i want to make a multiversion nms plugin and i want to make a module for each version that i want to support (gradle)
.getClickedInventory()
go from there
You can then check inventory size to determinte it. I don't know if there is a direct api implementation
InventoryClickEvent.getClickedInventory().getType == InventoryType.CHEST
If you get into making plugins seriously
wait is there no other type of storage that has the same amount of slots as the player inventory?
I would ditch the standard command system as soon as possible
Nah, I got the solution for you here
Not if you count armor slots
I tried that but u could still place the item inside the chest
can anyone help me with this ?
I want the player to not be able to put a specific item in another storage place
I can show you an example of a project I have made like that
I don't know a lot about this API but possibly moving an item results in an event which you can cancel?
What command system do you prefer? I am currently using Aikar's ACF as I did not really found anything else.
I have my own that I like better than all the other libraries out there
ok! thanks
It works very differently from them all
Ah yes, makes sense. Did the same for my Discord bot back then
https://github.com/Redempt/FastBlocks
Look at the settings.gradle and build.gradle
thanks
See build.gradle for the base project as well as the modules
If you're interested, I can show you how mine works
It's more streamlined than ACF
Gradle is scary honestly, I don't really understand how it works but would like to understand it a bit better. Never tried Maven but will be the same
Yeah sure, would love to see it
Maven is far worse
Yeah, that's why I never even tried it.
Gradle is not that scary and it's easy once you get the hang of it
I find the gradle "layout" confusing at times, I think it's Groovy language or something like that
Maven is quite simple. Gradle is a confuddled mess
Probably. I know the basics but when it comes to modules and stuff like that I am lost.
can i use different java versions for each module ? i guess i cant
so if i cant what version of java should i use
With Gradle it usually seems like there are 10 ways to do a single thing.
You can
See the source and target compatibility
It's a bit weird but it works
Can sb say what will happen if I set a display name to an Objective (scoreboard) with slot DisplaySlot.PLAYER_LIST?
for some reason i cant check if the inventory from the inventory click event is instanceof this class
Does the armor and crafting area in the player's inventory count as a topinventory
What is the argument for ConfiguarationSection.geyKeys(boolean)?
false
Hello, i need some help.
I have a command registered and a permission as well, but when i type the command in op it says the message i have when you don't have permissions
here's the code
does event.getInventory() instanceof SomeClass not work if that class doesnt have a field with the inventory?
don't repeat code
wdym
wdym
i see two times the permission check
I don't think you need that alias
it's for override other plugins
what does it do
yes
= just the outermost keys
because when i didn't have it
I know what a boolean is, I want to know what the argument does.
one time i needed the permission and the other one not
true = every key
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.hasPermission("minespace.god")) {
player.sendMessage(ChatColor.RED + "You don't have the required permission");
return true;
}
player.setInvulnerable(!p.isInvulnerable);
player.sendMessage(p.isInvulnerable ? ChatColor.GREEN + "God mode Enabled" : ChatColor.RED + "God mode Disabled");
return true;
}
something like that?
your choice
i'm not sure if an op gets all the permissions but i made an utils method that checks for permission and checks if the player is an op
but
public static boolean isAuthorized(CommandSender p, String permission) {
String prefix = name.toLowerCase() + ".";
return p.hasPermission(prefix + permission.replace(name + ".", "").toLowerCase(Locale.ENGLISH)) || p.hasPermission(prefix + "admin");
}
not sure why i'm replacing stuff ๐ค
ah because i was getting permissions from the plugin.yml file
?paste your plugin.yml
plugin.yml
also your if/else will never pass on your second permission test
Your code, if the player has the permission and is not invulnerable, say they don't have the permission.
If the player doesn't have the permission always say they don;t have the permission and never run the other code to set invulnerable/
ugh a protected constructor can be called from its child class no?
super yes
different packages?
one is in .....utils and one in ....gui
protected = package protected
so i have to move it?
if they are in different packages, yes
ah now it works
?paste
how does this looks?
https://paste.md-5.net/qikekajiqe.java
no
and yes
you cant access it out of the package
but you can extend it and make it public
Exactly what I said
instead of null try new ArrayList()
its pointless, other than for readability though
so new arraylist clears the key?
null removes the key
i have a question about 1_16_R3 nms
wdym?
is this the same IChatBaseComponent.a() in 1_17_1 ?
Exactly as I said, your code logic is broken
why?
follow your tests, you do an if player has permissions chanck
so
then in the else, you do the same check again
it can;t magically become true after you already tested it and found it false
but when it was without permissions
it worked
I'm just telling you what is in your code and how it will not work with yoru permission tests
is it possible that the first method is being executed when the second method started executing?
decompile and see
Is ConfigurationSection.getName() the name of the key the section is under?
if all of that code is sync, then no
Your command permissions are set in the plugin.yml, you don't need to test them at all in the command. Spigot will not allow a player without the permission to run the command.
you do not test the permission at all
ye
i did a lot of changes
bc of the permission
i did already
well
i'm having a problem in the last line
sorry fixed https://paste.md-5.net/sepaxikizo.java
it was still using player instead of p
Well, mine is correct
well then for some reason my FileConfiguration is null
I am using InventoryClickEvent but i am having trouble making it so that the player cannot move stuff into the top inventory but can move it in the bottom inventory
i have the same code as you
you do need 1 more } to close the class
I didn;t add one as I assumed you had more code in the class
I will send my code one minute
this is a full class https://paste.md-5.net/zabofoboro.java
how do i register the message in yml?
messages?
I'm not understanding your question
in plugin.yml
commands:
god:
description: Become a god
permission: minespace.god
permission-message: &cYou don't have the required permission
aliases:
- god
usage: /god
Hey is there an event or some way to obtain the Item used to Activate Beacon?
can anyone help me with this ?
click event i think
like that?
try with ยง
how do i make that simbol lol
copy
copy/paste ๐
alt gr + =
what is gr
my keyboard has no gr key ๐
but by keybord is a little one
Alt Gr
so doesn't have that things
smh the = is next to the :
Does nothing for me
same
the permission-message with " or ' ?
try alt f4
oh
ok
๐
it worked alt f4
๐ณ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
somebody help me with this
The problem I face is that even if the top inventory is there
"
brr empty lines
so like this should work?
god:
description: Become a god
permission: minespace.god
permission-message: "ยงcYou don't have the required permission"
aliases:
- god
usage: /god
yes
k ty
check yoru indentation though. Discord messes it up. 2 spaces indent
The problem that I face is that when I am trying to move the item when the top inventory is not there, It wont let me move it. https://pastebin.com/Yaxexm2u
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
portuguese keyboard ๐ ยงยงยงยงยงยงยงยงยงยง
for some reason second line causes npr
final FileConfiguration dataFile = ConfigManager.getData();
if (dataFile.contains("safe_chests") && dataFile.getConfigurationSection("safe_chests").getKeys(false).size() > 0) {
datafile cant be null as it initialized before
just because it contains "safe_chests" does not mean that there is a configuration section available there
how can i check if there is a configurationsection?
ah isConfigurationSection i guess
ok
it finally worked tysm :DDD
The Done Button to confirm payment towards Beacon doesn't fire the event..
:C
Nor Cancel does..
then maybe intercepting packets?
Never used packets. Where i can get some direction tip about it?
here you can see the packet specification https://wiki.vg/Protocol
and basically with plain spigot you can only send packets
but with some implementation like protrocollib, you can intercept them
I probably need to read them
I just need to obtain the ItemStack used
When confirmed
what is better?
messages.forEach(message -> log(message));
or
for (String s : messages) {
log(s);
}
is there any way to change the name of a project?
change the files name?
What IDE?
Eclipse its Right click project -> refactor -> rename (type name) press enter
no clue on IJ
intelij
right click project refactor rename
where?
not sure if package name will change
ye
using maven?
pom.xml
File > Project Structure > Project > Project Name
if you dont want to change the prohject name
?paste
can someone take a look at this
https://paste.md-5.net/avekupeyub.java
I have a problem that when I am trying to move the item when the top inventory is not there, It wont let me move it. https://pastebin.com/Yaxexm2u
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Does anybody know a solution?
Neither is better, they both do the same thing but are written differently ;p However you can also do messages.forEach(this::log)
impl of forEach() is just a for loop that calls that consumer
Does anyone know how to prevent the knockback reduce by many cps in the 1.8.9?
default void forEach(Consumer<? super T> action) {
Objects.requireNonNull(action);
for (T t : this) {
action.accept(t);
}
}```
That's literally all forEach() is under the hood ๐
You are probably going to have to translate those color codes to match on name
oh lol
Yeah I did that
well yea it has some small disadvantages but i can live with that
Just that it doesn't let me move it at all when I want it so that the player cannot move it into a storage like a chest
But they can move it in their own inventory
does it give you the message you are not allowed to move it?
Yeah
then your code is working as its written
I got it so that it would let me move the item into the chest but it wouldn't let me move it out
this still throws an npr
if (dataFile.isConfigurationSection("safe-chests")) {
It works but not the way I want
I am trying to make it so that the item can be moved inside the player inventory but not into any external storage place
Hiya, how can I save a config file with some default config? ( I don't mean the default config.yml file, it has a custom name)
I'd like to be able to set the config in my plugin resources directory like I do with config.yml
if that throws an NPE then dataFile is null
@eternal oxide
then check it is the player inventory you are operating on
So if the inventory type is player
But when I do that I would not let me move it in the players inventory
Wouldn't it?
Preventing knockback reduction from players
what exactly are you trying to prevent? moving it into a chest or into the players inventory?
there are multiple things you are going to have to test
But to be able to move it into the player inv
Thanks
What exactly does ConfigurationSection.getList() do?
What exactly will I have to test?
Isn't dragging just a click event and then moving your cursor?
well my file isnt null
I don't see the difference between them
You could always test the Top inventory, if that is not a player inventory don;t allow moving it
ah wait
That's what I did
I forget if player is alwasy on top or bottom
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
This is what I have currently
No you only check the click, you never check which inventory
ah I see you added one
it returns a List<?>
Thanks
Is it different if I check for null instead of checking if it's the player inventory
Because I also tried checking if the clicked inventory is the player inventory
getTop and getBottom never return null
Wait so what if you are in the player inventory what will be the too and what will be the bottom?
As in the one where u can see the armor slots
It will never be a PLAYER inventory. you test for CRAFTING
Ohhhh
So it's not inventory type player but inventory type crafting?
I am very confused wouldn't that check for the crafting table inventory?
Is this the correct way to get my config file? .getList is returning null
File configFile = new File(Main.getInstance().getDataFolder(), "chests.yml");
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
Instead of the mini crafting table in the player inv
no, crafting is the players 4 slot crafting
Question on making a variable final... intelliJ is recommending I make a variable final, but I use methods within the object that changes variables within the object. So for example I have
private final NPCStuckController stuckController;
now does this mean I cant use methods within the npcstuck controller that change private variables within the controllers class? Like the variable in npcstuckcontroller boolean isRunning;
Can i still run
stuckController().setRunning(true);
even though the variable is final?
WORKBENCH is a table
no
Ok
It's not, calling getList isn't the problem. The value it returns is null.
So all I have to check for is if the top inv is not crafting table?
yes, then prevent moving
Alright thank you very much!
for some reason data is null
dataFile = new File(plugin.getDataFolder(), "data.yml");
if (!dataFile.exists()) plugin.saveResource("data.yml", false);
data = YamlConfiguration.loadConfiguration(dataFile);
Oh. I completely forgot to add the dashes for each list item, sorry about that. I better add a null check.
Yeah
I added the dashes and it works now :D
Nah that'll be fine because I'm just using a for loop
I am right that for loops don't do anything if the list is empty, aren't I?
yes
how to get a world by name ?
Bukkit.getWorld
thanks
does anyone here know how to update a plugin's task?
explain more
well i am making a scoreboard right now, but it is not updating the statistics
the statistic is damage dealt to entities but i have to relog in to make it update, so how to update its task?
then use teh scheduler to run an update
example?
?scheduling
if i compile a plugin with java 16
can i run it in java 8, 1.8.8 ?
no
not unless you configure it to compile for 8
where do i put it tho?
below p.setScoreboard(board); ? or somewhere else
im trying to do this
but 1.17.1 classes requires java 16
ey you use Intellij too, nice
are they modules?
then you are going to have to do lots of reading about using modules and different java versions
finally found the problem
@eternal oxide where?
you create a task using the scheduler to run repeatedly and update each players scoreboard
hmm
it doesn't need to run often only every few seconds
can you give me any example of it? i dont get the link that you sent me
read teh section on "Scheduling a Repeating Task"
new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("Mooooo!");
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
this one seems good
but what do i need to change so it would repeat my scoreboard task?
inside your task just loop over Bukkit.getOnlinePlayers() and call your showScoreBoard
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getOnlinePlayers();
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
``` so like this? @eternal oxide
what type of click is the number click?
where u press 1 and the item in your first slot goes to the slot that your cursor is in?
huh
explain more lol
where should i
So when you are in your inventory or in a chest inventory you can press 1 while your cursor is on a slot and if there is an item in your first slot then that item will be placed in the slot that your cursor is on or switched with the item in the slot that your cursor is on if there is an item there
isnt that just basic mc keymap?
use modules
check
no i mean what action is that
๐คก
how to do that
how to create a new module
and use it i guess
i am using gradle
im not good at reading code
button pressing?
like how to create a submodule
i am asking you...
i am just confused on what you are tryna ask
like click event?
ooh
but they can still move the item when they are doing that action
so you wanna make it like "cancel event" like that?
i can cancel it
it just that
it doesnt cancel it if the player does it with that actiopn
can you tell me what to do ? im confused
what is this adapter thing
if they are using the num 1 button?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/package-summary.html try checking this and see if you can find what you are finding
declaration: package: org.bukkit.event.player
Is there a way to stop empty configuration values being removed?
so that i can check for it
oops didnt mean to reply sorry
hey if this configurationsection does not exist, what does this returns?
null?
return new HashSet<>(homesFile.getConfigurationSection("homes." + p.getUniqueId()).getKeys(false));
an NPE probably
yea i'm using it as tabcomplete and it returns an npe
wondering if null would be accepted as a tabcomplete
if anyone got time to explain me the module and multiversion thing and help me please tell
Is there a way to display different information on each player's scoreboard and make the option of the team command work?
public static void makeScoreboard(Player player) {
ScoreboardManager manager = Bukkit.getScoreboardManager();
assert manager != null;
Scoreboard board = manager.getNewScoreboard();
Objective objective = board.registerNewObjective("info", "dummy","ๆ
ๅ ฑ");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
player.setScoreboard(board);
}```
I'm doing this from "Player Join Event"
Team Options won't work with this :(
just a quick question
what is the most preferred IDE for plugin developement?
IntelliJ IDEA
thx ^^
How can i do to send the user a message with multiple lines?
i mean
he does /(command)
and it appears the list of commands and things like that
loop through a stringlist
what?
don't understand
you want to get it from config right ?
PlayerCommandPreprocessEvent
send a message with multiple lines
\n
like for explain the commands
player.sendMessage("h\ne\nl\nl\no");```
List<String> list = getConfig().getStringList("myMessage");
for (String s : list) {
player.sendMessage(s);
}
the config :
myMessage:
- "Hello"
- "There"
bruh not like this
ig
are you getting it from a config file ??
eehm
or just want to send multiple messages at once
so
edit your config.yml default
no
just use newline i guess
it's for showing the commands and that things
yes
the output will be
Hello
There
String multiLine = String.join("\n", configuration.getStringList("some.path"));
๐
ok tysm ๐
anyone ?
or just give me a guide about it
yes
Pog
You could take a look at this for example:
https://github.com/WesJD/AnvilGUI
multi module
Oh
Oh i thought maven
i dont get it
Subprojects?
i looked at more than 5 examples
Yeah so what is it that you donโt understand btw?
yes
?
what to do in the ide
how to use it
like use the interface
Do you regularly use maven or gradle?
Interface?
To do comments in config.yml is with // as well?
Oh you wanna achieve nms abstraction
yes
and use the IHologramManager interface
Right so first of all we need to think of subprojects / modules as dependencies also
ty
so how to make those ?
In gradle we declare a subproject by the include function in settings.gradle
It works like the Spigot API.
- You write an Interface that has a bunch of methods.
- You write an implementation of that interface for every version
- You only use the interfaces for programming
- You have no idea what actual implementation is used later on because you have a manager that decides which implementation to use when the server starts.
Yeah
Open settings.gradle
then new line -> include ':folderToSubProject'
https://github.com/Sxtanna/VersionedGradle btw have you checked this out?
Itโs a fine example of how one could do this
thats kotlin
What happened to your pfp Conclure
I wanted to become like you
Yeah
One module for the interfaces
one module for each nms version
one module for the implementation
what is the implementation
well
the main parent module thing ?
no
the implementation module is the module which is capable of choosing which nms version implementation of the interface to use
We have to do this due to that dependencies can only depend in a unidirectional way
ok
for instance
i have done this
you cannot have 2 modules simultaneously depending on each and another
yeah
Let me write an essay
ok thanks
https://paste.md-5.net/uzeqavuvar.java
What should i do to put this reload code outside the main class?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
wdym
?di
that's the reload command
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
what?
Read it. You will need id at some point when programming in an OOP language.
and how to register a plugin in the main class? with other commands i did :
getCommand("name").setExecutor(new Class());
boost
you look weird in blue
Gimme helper then im Orange.
how can I increase a single mob's player detection range
how to register a plugin?
wdym
How does a statement like this work? If one is false and one is true what is the booleans value?
boolean executing = !this.npc.getNavigator().isNavigating() && this.target != null;
to be true they both have to return true
otherwise false?
yes
Thanks
its an &&
and the ! at the beginning will invert the boolean correct?
yes
ok
how to register it in the main class
if the
code is in the main class
You mean this?
register a plugin :/
ig
@neon nymphi have this 3 commands
but i want to add a command
that is in the main class
So we have modules which acts like dependencies. Modules just as dependencies can be dependents and dependencies.
Limitations
However as said one module or dependency cannot simultaneously depend on the other module or dependency of that other module or dependency depends on that one module or dependency.
dependency-one <-> dependency-two (does not work)
So to circumvent this you will have to create a unidirectionel (single directional) dependency hierarchy where higher dependencies don't know about lower dependencies within the hierarchy.
Modules
To create a module as you might know you do need to first declare the module inside settings.gradle like this:
include ':module'
Now the folder ./module will act as a module. If it is absent, go ahead and create one. Usually you also want to have a local build.gradle contained within every module. So create the file ./module/build.gradle
Go ahead and reload your Gradle project and you will see how IntelliJ reacts to it.
The infrastructure
Earlier I mentioned that dependencies cannot be cycled (simultaneously interdependent). To circumvent this with nms abstraction you will need to have three layer levels:
- The interface layer, the layer of interfaces.
- The nms layers, the layer of nms specific classes which implements the interfaces in the interface layer.
- The final layer, this layerswitches on the nms version to then load the corresponding nms version module.
In order to achieve this we would need every nms module to depend on the interface module. You may have something like this in your settings.gradle:
//settings.gradle in rootproject
include ':api',
':v1-8-r3',
':v1-16-r3'
//class in api
interface Blah {
void blahLol();
}
//build.gradle in v1-8-r3
dependencies {
implementation project(':api')
}
//class in v1-8-r3
class v1_8_R3Blah implements Blah {
public void blahLol() {
net.minecraft.server.v1_8_R3.Blah.blah();
}
}
//build.gradle in v1-16-r3
dependencies {
implementation project(':api')
}
//class in v1-16-r3
class v1_16_R3Blah implements Blah {
public void blahLol() {
net.minecraft.server.v1_16_R3.Blah.blah();
}
}
Now when you're done with the interfaces and the respective nms implementations we also need to know which nms implementation to use, thus one should add a final module:
//settings.gradle in rootproject
include ':api',
':v1-8-r3',
':v1-16-r3',
':plugin'
//build.gradle in plugin
dependencies {
implementation project(':api')
implementation project(':v1-8-r3')
implementation project(':v1-16-r3')
}
//class in plugin
class BlahPlugin extends JavaPlugin {
Blah blah;
@Override public void onEnable() {
try {
var ver = this.getServer().getClass().getPackage().getName().split("\\.")[3];
switch(ver) {
case "v1_8_R3": { this.blah = new v1_8_R3Blah(); break; }
case "v1_16_R3": { this.blah = new v1_16_R3Blah(); break; }
}
} catch (Exception e) {
throw new RuntimeException(e);
}
blah.blahLol();
}
}
Then to build I would in rootproject's build.gradle have something like:
//build.gradle of rootproject
dependencies {
implementation project(':plugin')
}
Then of course you would need shadowJar I believe in order to shade @quaint mantle.
omg
what?
damn thanks
hope it helps lol, ask any questions in case I wasn't clear
conclure could you help me with this? pls
danke ๐
yeah
you need to declare your commands in your plugin.yml
userevents:
description: Reload the plugin
permission: userevents.reload
permission-message: "ยงcYou don't have the required permission"
aliases:
- ue
like this?
?paste your main class
yes first of all
yes?
for every getCommand("something")
the string something would have to be listed under commands: in plugin.yml
that 3 commands work
i'm just doing config.yml
and trying to get /userevents reload
which does not work either
getCommand("userevents").setExecutor(this);
the label is not for argument comparison
if (label.equalsIgnoreCase("userevents reload")) {
i'm just trying to reload the config
the label will either be the command top node name or any alias of it, depending on which alias was used
ah?
something like
@Override
public boolean onCommand(...) {
if (args.length < 1) {
return true;
}
if ("reload".equalsIgnoreCase(args[0])) {
//TODO
}
}```
should be enough
comparing labels is 99% of the time redundant
@ivory sleet where dog
disappeared :c
๐ฆ
and in plugin.yml
userevents is apart of the command name
not a command argument
you currently check for
/userevents userevents reload
wdym?
i just want /userevents reload
/<command name> <command argument>
this explains why your code seems so counter intuitive
following one of those outdated tutorials I see
yes
anyways yeah
i'm doing this plugins to have them as example
the command name is not a part of the command arguments
oh
i see
so this code is good
but i have to register the command
or is not good?
I am not going to assess your code because you would barely understand the feedback seeing it as of now. Maybe in the future we could have a code review. Anyways you always need to register your commands.
for some reason this isn't working... (its in the PlayerDeathEvent event, and killee is a variable for event.getplayer().getKiller) java if (killee.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() <= 2) { LifeSteal.getPlugin().getServer().getBanList(BanList.Type.NAME).addBan(killeeUUID, "You have lost all of your hearts", null, null); }
what specifically is not working?
its just not doing anything
could you recommend me a not outdated guide?
no
if it by video it would be better
wrong
Kick them afterwards
oooohhhh
Adding them to the banlist doesn't kick them out automatically
THANK U
https://www.youtube.com/watch?v=vmV7Zq1tf4Y @acoustic pendant
I don't endorse it being a good guide
but its not outdated
I said that because its a 1/99999999999999999999999999999999999999999 chance of me asking a question and it not turning into a big thing
ty :3
what is better, creating a table for each user or creating a single table and registering all users in it? (SQLite)
see command description
store:
description: 'text'```
Personally, I prefer the single table with multiple records. It's much easier to organize things that way
Having a table for every player that enters your server would be difficult to keep track of
My two cents ๐ช
dynamic tables also prevent fun things like joins
I really need some help
i have this code
but
for some reason
when i type /userevents reload
it sends me the }else{ code
Return true instead of false
@lost matrixbut it doesn't send the message
and idk if it reload the config.yml
Is there a way to get the full and untrimmed string of a command when auto-completing instead of just an array of arguments?
To avoid the xy problem, I should maybe elaborate more on why I would need that
i have one hypothesis but couldnt figure out a way to prove it.
So, the reason why I need this is that vanilla-like auto-completion only shows up if there is a space after an argument. So, as an example, MC only shows you a list of auto completable block ids when typing "/setblock ~ ~ ~ ". If I were to type "/setblock ~ ~ ~", there won't be any auto completion.
args.length will tell you what tabcomplete to offer
Let say i have hashtable implementation. the keys for that could be only 20 chars wide and char range is from ASCII decimal value 101
Do you mean you want to show the full command statement in the tabCompleter like player 2d testreason rather than individually player then 2d then testreason?
is it true that using charValue*index+1 would make indexes that never collide if i input only characters starting from 101
word: prisitraukimai
hash: 112*1 114*2 105*3 115*4 105*5 116*6 114*7 97*8 117*9 107*10 105*11 109*12 97*13 105*14 32*15 32*16 32*17 32*18 32*19 32*20 (ascii value * its index + 1)
according to my brain, even if you manage to flip the multiplication of all or some of the values, collision can never happen since ascii value 1, 2,3.. etc is not inside the requirements range
and 101+ character length is bigger than 20 chars only requirement
so the question is, is my conclusion true or false?
Not really. I only want to make tab completion visible after a space is put after a command node. In other words, I want to show autocompletion when typing "/testcommand testoption ", but not when I type ```
"/testcommand testoption"
any big brains would like to prove it? or not? ๐
i've had this type of completion, but i dont remember how did i do it, it did it like 6 months ago
Not sure what your goal is, but I will say that onTabComplete's args value splits with a space. So if you type in /testcommand , it'll show as 1 argument with a string with nothing in it, and /testcommand arg1 will have 2 args in it with args[0] := "arg1" and args[1] := "" and so on. You could use this to show a tabCompleter when a space is entered
Ok i got it. The first one is a proper A* approach and the second one is a fast distance interpolation approach.
ahhh ok thanks
For instance, this code
switch(args.length){
case 1:
tabComplete.add("help");
tabComplete.add("add");
tabComplete.add("delete");
tabComplete.add("edit");
return tabComplete;
Gives this
@lost matrix you big brain, can you state that my conclusion above is true or not, i really need an answer
Via the plugin.yml or via a manual check of the CommandSender inside your CommandExecutor
ascii sort yes
So you want a hash for every character in a word but the same char at a different position should have another hash?
That looks amazing! Which one you think is better now?
Why dont you just use sha256 then?
because its not for minecraft
and im coding on cpp compiler and cant even use cpp libs
and only allowed to use c stuff
rofl
Ill write the code so that you can switch between them with a boolean then you can play around and find out what works best
Amazing thank you!
i think so
i prefer the permission in the plugin.yml
so you can delete the return true;
I wouldnt describe it as "perfect" but it should work.
How can i get the config in a not main class?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Using pluses is dangerous here. Each ASCII char needs 7 bits to be displayed unambiguously.
So your best bet would be using a bit mask.
So for the word "Car" you would need 21 bits:
0000000 0000000 0000000
Then you want to iterate over your chars and bit shift them according to their index.
'C' doesnt get shifted
'a' << (1 * 7)
'r' << (2 * 7)
After that you add all chars as a mask to your empty bits.
It should look a bit like this (pseudo code):
0000000 0000000 0000000 || 'C' << (0 * 7) || 'a' << (1 * 7) || 'r' << (2 * 7)
and thats ASCII only
How can I check if player hit entity with ender pearl in 1.17.1?
Isnt the ProjectileHitEvent fired in this case?
Only thing i read that it fires when it hits block
oh okay ill try thank you
But cpp already has a hashing function for std::string if you include <hash_map> or <unordered_map>
I am using the but it returns ENDER_PEARL instead of zombie
@EventHandler
public void event(ProjectileHitEvent event) {
System.out.println(event.getEntity().getType());
}
I mostly just appreciate the visual lol
Oh, i may need to use getHitEntity()
:guncat-1:
Why is lore null in this code?
https://sourceb.in/mGb4BAWEFq
Yes that works, thank you.
ItemMeta meta = ...;
final List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
// Do something with the lore
meta.setLore(lore);
you need to check if the ItemMeta has a lore before getting it.
alr thnx
You set the lore but not the itemmeta
Add holding.setItemMeta(meta); after your #setLore()
Wrong ping, soz
@quaint mantle ^
yeah i did that
anyone could tell me why in enabling_god.message
when i type it in minecraft
it doesn't give me the message?
it's being sending by the player
and all the rest of the commands works
but not that
maybe a return?
i have 2 commands more in different classes
Your logic currently looks like this:
"If the sender is not instanceof Player then set the player invulnerable"
but the actions works
line 3 should be after you check that sender is a player, and the last return should be false
the thing is the command
go back to the original code I sorted out for you. Then see what you did wrong
but the action works
you are literally just replacing the message lines. How could you have gone so wrong
cause the bracket ig
for (String i : fragment.getPlugin(fragment.class).getConfig().getStringList("disabling_god.message")) {
i need this
all you had to do was take your for loops and replace the p.sendMessage lines
but in the other classes that worked
that code you currently have would never work in any class
yes, no if tests, no else, no logic
but works
so go back to the original code and just replace the p.sendMessage lines
the last return false is correct
The code I gave you is 100% correct and working. If yours is not then you broke it.
ok
if it shows you the command you didn;t use the exact code I gave you
it will only reach the return false; if its not a player issuing the command
@hasty prawn okay, sorry I didn't respond until now, but when I print the ItemStack it for some reason doesn't have the enchantment even though I added it
Depending on which one else's from :^)
I think this image explains a lot by itself lol
How would I get the maximum amount of health a player can have? even with GENERIC_MAX_HEALTH attribute modifiers?
What was the problem again?
It for some reason wasn't recognizing the item I wanted it to even though I gave it the exact same properties
this is a quick question @hasty prawn can you answer it?
When I print the ItemStack it finds, it gives me this:
ItemStack{GLASS_BOTTLE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_purple","text":"Soul Vial"}],"text":""}, enchants={LUCK=1}, ItemFlags=[HIDE_ENCHANTS]}}
But when it prints the ItemStack that should be identical, it gives me this:
ItemStack{GLASS_BOTTLE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"dark_purple","text":"Soul Vial"}],"text":""}, ItemFlags=[HIDE_ENCHANTS]}}
Does getMaxHealth() not return it with the modifiers?
first, its depricated... second I don't think so
How are you adding the enchantment on both items
can someone review my code rq and tell if it's good
or dangerous or bad
public void onPhase(PlayerMoveEvent event) {
PlayerData data = FunkePhase.INSTANCE.getDataManager().getPlayerData(event.getPlayer());
if (data == null)
return;
long timestamp = System.currentTimeMillis();
if (data.getLastTeleport() != null && event.getTo().equals(data.getLastTeleport())) {
data.setLastTeleport(null);
return;
}
FunkePhase.INSTANCE.getService().execute(() -> {
Player player = event.getPlayer();
if (player.getAllowFlight() || event.getTo().getWorld().getUID() != event.getFrom().getWorld().getUID() || player.getVehicle() != null || !FunkePhase.INSTANCE.phaseEnabled || timestamp - data.lastDoorSwing < 500L)
return;
if (event.getFrom().distanceSquared(event.getTo()) > (FunkePhase.INSTANCE.getMaxMove() * FunkePhase.INSTANCE.getMaxMove())) {
event.setCancelled(true);
return;
}
float minX = (float)Math.min(event.getFrom().getX(), event.getTo().getX());
float minY = (float)Math.min(event.getFrom().getY(), event.getTo().getY());
float minZ = (float)Math.min(event.getFrom().getZ(), event.getTo().getZ());
float maxX = (float)Math.max(event.getFrom().getX(), event.getTo().getX());
float maxY = (float)Math.max(event.getFrom().getY(), event.getTo().getY());
float maxZ = (float)Math.max(event.getFrom().getZ(), event.getTo().getZ());
SimpleCollisionBox box = (new SimpleCollisionBox(minX, minY, minZ, maxX, (maxY + 1.8F), maxZ)).shrink(0.05000000074505806D, 0.05000000074505806D, 0.05000000074505806D);
int x1 = (int)Math.floor(box.xMin);
int y1 = (int)Math.floor(box.yMin);
int z1 = (int)Math.floor(box.zMin);
int x2 = (int)Math.ceil(box.xMax);
int y2 = (int)Math.ceil(box.yMax);
int z2 = (int)Math.ceil(box.zMax);
for (int x = x1; x <= x2; x++) {
for (int y = y1; y <= y2; y++) {
for (int z = z1; z <= z2; z++) {
Block block;
Material material;
if ((block = Helper.getBlockAt(event.getTo().getWorld(), x, y, z)) != null && (material = block.getType()) != AIR && Materials.checkFlag(material, 1) && !FunkePhase.INSTANCE.getExcludedBlocks().contains(material)) {
CollisionBox blockBox = BlockData.getData(material).getBox(block, ProtocolVersion.getGameVersion());
if (blockBox.isIntersected((CollisionBox)box)) {
Location setback = findSetback(data);
if (setback != null) {
setback.setPitch(event.getTo().getPitch());
setback.setYaw(event.getTo().getYaw());
}
event.getPlayer().teleport((setback != null) ? setback : event.getFrom());
FunkePhase.INSTANCE.alert(event.getPlayer());
return;
}
}
}
}
}
data.locations.addLocation(event.getFrom().clone());
});
}
+
private ExecutorService service;```
-
this.service = Executors.newSingleThreadExecutor();
