#help-development
1 messages · Page 445 of 1
its only 350 lines
?
the code randomly interrupts
??????????????????????????????????????????????
@tardy swift
where is the rest of it
why is everyhthing in one class as well ðŸ˜
i give up
steaf you deal with it
i believe in you
I have dinner ready xD
have a good meal
bro forgot about all keyboard buttons
I wonder where this code came from
seeing as the code abruptly ends
ty lol
i want to give nael benefit of the doubt
but it's hard
A certain AI anyone??
this ai is bad at indenting for sure
i send something
That still cuts off
bro just sent his entire fucking project
Also what's with the random xml at the top
what is this witchcraft
@tardy swift you said that somebody told you that this code is valid\
make sure to punch them in the face next time you see them
dont be mean
sorry :3
how can i check if entity can reproduce?
AIs don't have feelings
I don't care how bad the code is, but there's no value in insulting someone because their code isn't what you consider great
take a look at their reproductive organs
for reall...
this code is not bad
because bad code compiles
Iirc it’s Entity instanceOf breedable
well if you manage to compile java code with random xml gibberish in its header i'll be pretty impressed
didnt me who write it its my friend that send me that
your friend probably used an ai
why
Idk ask your friend
because this code looks mighty weird and inconsistent and well
this
what it mean
if(!((Breedable) entity).canBreed()) {
return;
}```
doesn't work
I have bad news for you
You need to learn to code before coding
"doesn't work" means what precisely
I'd be more apt to help but it seems like you have 0 knowledge of java
so the code will never work ?
yes.
it's true even when i breed animal
like
it will not event be detect by mc
it will not compile be detect by ide
No means no
does this look valid?
or do I need to create POST_PARAMETERS?
Pastes.io API for https://pastes.io
Pastes.io is a simple and efficient pastebin for mainly code to be distributed neatly and efficiently across the web. Website where you can paste and store any type of text or code snippets online and share it with your friends.
oh lord
this site offers the code this
sorry :D
bruh
so how can icheck if entity can reporoduce?
Learn to code before trying to interact with it please
It takes time but it's a very useful skill
Hello i have a question. Can i somehow create an items in 1 inventory.setItem(index, ItemStack)?
To get out of this
umm
at the VERY least this can be simplified with loops
for (int i = 0; i < 54; i++) {
if (i > 19 && i < 17) continue;
inventory.setItem(i, glass);
}```
i don't know an elegant approach but i'd do smth like
Set<Int> of (0,1,2...)
set.forEach(slot -> inventory...
yup
Thanks you guys
you missed some but that's valid too
for helping
anytime
actually interesting
what's gonna be faster
for loop with ifs
or forEach
cuz forEach is kinda sus
but it doesn't have ifs cuz the set is predefined
i prefer readability over minor optimization
why not both
make the set and loop over it
probably just as fast as forEach but whatever
?paste
what material would i use in a gui to represent a list of players? like, i click the button and a gui with all online players opens for example
this isn't a code question, it's an opinion question
a player head is out of the question
i need a glowable item
ender eye?
for some reason it refuses to glow
maybe, any other ideas?
book i use for culture upgrades
filled map i use for stats
perhaps an ender eye works well
there is not really a good item for it
yeah
just make a resource pack 🤷
haha nah i don't care THAT much
lol
does anyone know what's wrong with my sql?
https://paste.md-5.net/vujomeciwa.coffeescript
So, the story goes like this: the first method where the UUID is supplied works, the second method where it should return everything, it doesn't work...
This is for MySQL, because for SQLite is working just fine (with other implementation)
Can anyone find wth is not working?
for me sout is not even showing....
what does the ? mean? not too familiar with sql
okay
but the problem is with the WHERE NOT EXISTS
honestly lgtm
i cant help srry xD
maybe select * would work?
are the red lines relevant?
I am getting an error at the red lines
insert ... where ... ?
what's that supposed to mean
good point
xD
insert where there is this data 😛
what is it supposed to do
insert into participants where not exists(check here if something exists)
that makes no sense
I think I just found an example
i think you're looking for update yeah
let me try it
you wouldnt be able to insert somewhere where something exists
true
because then it wouldnt be inserting
into where
wait what happens if I make the primary key unique
can you tell us in plain english what you want to do
insert something if it doesn't exist
thats always
EXACTLY what you want to do
you cant insert something that already exists
yes
please
what do you want me to respond
..
what this is supposed to save
"I want to change a player's world"
"I want to commit manslaughter"
(via the tools of, for example, somerthing)
And you want to do what via the tools of sql?
yes
what the fuck is yes
INSERT IF IT DOESNT EXIST
zbll is going bananas please respond with what you want to use the database for
WHY??
SOME VALUES
insert if it doesn't exist
yeah
I guess you dont want help then xD
wtf is some values
then what the fuck ARE you trying to do
man you're confusing th out of me
the solution always depends on the context
?xy
Asking about your attempted solution rather than your actual problem
what do you want to store in the database?
please read that
?guis
Looking for smile7 implementation
the whole mysql thing makes no sense. why e.g. are you removing everything from "participants" just one line after you tried to add two things there?
^
I said it before, I pasted it into there to check syntax errors
are we speaking the same english
so those lines are unrelated?
okay anyway, there is no WHERE in INSERT. Because it makes no sense
Ok I have a question with this implementation,
Currently if I want to have a sub-gui open from the GUI, What I do is I create a new GUI instance from a item button.
But I'm wondering, I want to do a multi-page system. How can I change the implementation to allow me to have a previous/next or is the approach just to create a new instance of each page every time and keep track of what page the current one is?
WHERE is the table on insert
I asked, how could I insert into the table only if the values I tried to insert do not exist
I could have a private int pageNumber on each menu and use that in the manager to figure out what page is currently on and what next and back should do
what you are trying to do is probably INSERT … ON DUPLICATE KEY UPDATE
just insert it regardless
?
why do you need to know if its already there
that will insert a new row, or update an existing one if the primary keys already exist
then I would have duplicates
double penetration let's go
xD
ok tysm
i sense youve gone mad from the people asking for help this past hour
i want to commit blanket
(ngl if instead of spamming commands tried to understand it would've been better)
well if instead or repeating "insert into where" you could explain what the purpose of your database is
@lost matrix I have a question with your GUI implementation.
Currently if I want to have a sub-gui open from the GUI, What I do is I create a new GUI instance from a item button.
But I'm wondering, I want to do a multi-page system. How can I change the implementation to allow me to have a previous/next or is the approach just to create a new instance of each page every time and keep track of what page the current one is? Is creating a new instance of the desired page every single time the right way? I could keep track of the current page used and then do stuff accordingly
thats the wrong smile
I wasn't the one repeating that
Indeed lol
sure whatever, do you still need help?
btw @regal scaffold editing the message isnt gonna ping him retroactively i dont think
just mention acf and smile will wake up automatically from his long hibernation
at least that worked a couple times
I think you're right
But I left the message there
Maybe he'll answer
Not gonna spam ping him
fair
Someone that knows Rest?
I'm trying to login into Pastes.io
I'm getting this error: https://paste.md-5.net/atunopihan.makefile
Code: https://paste.md-5.net/ukofelehiq.cs
I'm following this guide:
https://documenter.getpostman.com/view/25405096/2s8ZDVb4jt#34e6521d-456d-4903-a59d-c6b98f56d0af
The only slightly annoying thing about it is that it triggers auto increment rows
Because it tries to insert first
how would you do it for not triggering it?
I mean it doesn’t really matter
You can always check if it exists first
Someone that knows Rest?
I'm trying to login into Pastes.io
I'm getting this error: https://paste.md-5.net/atunopihan.makefile
Code: https://paste.md-5.net/ukofelehiq.cs
Guys, how to change the description of all items on the server? For example, the player receives an oak, and it is renamed to a different name
How i can turn this code, so in config,yml i can use & to color instead this idk symbol
because idk
Need to make a schudeler, get all players, find an item, and change its name?
what'
ChatColor.translateAlternateColorCodes('&', string)
Yea but before it?
before what
Because i need to do a prefix only
The best way to change the item names would be with a resource pack
Or with a packet listener
what's a good way to go about making an unbreakable block breakable
or any way at all
i was thinking something with playerinteractevent?
but then idk how to do the delay
and is it possible to have the block breaking effect
You can make a full custom breaking system like hypixel has
^
i have no clue where to start
well
I actually have one that’s mostly functional
the player sends an arm swing animation packet every tick
- a Start Dig, Stop dig, Abort dig packets
you can then calculate time
or you can make a resourcepack if you are dedicated and lazy
and send block break animation packets
There is a method for sending the break effect in the api
And lore can be changed in the resource pack?
But you can only have one at a time
sure, but why?
Until Chocos pr gets merged
Where i must put it?
You don’t have to
you can just make some new model for a breakable block and then make it drop the block you are trying to mimick
just around the config.getString()
oh?
well id love to see all the options
so i still wanna take a look at it
sendBlockDamage
ok thanks
ah i see
?paste
can anyone help? I reload my config and the change color didnt work.
This is my code:
if(player.hasPermission("wiadomosc.reload")){
player.sendMessage(ChatColor.GREEN + "Pomyślnie przeładowano plik config.yml");
plugin.reloadConfig();
}
``` reload command
```java
String prefix = config.getString("prefix");
prefix = ChatColor.translateAlternateColorCodes('&', prefix);
``` this is convert color, in sent message command
```yml
prefix: '[Wiadomosc] '
``` and simple config file
bruh moment, now i both have a getValue() and value()
what color does it need to be, you didnt specify a color in the config
My main class looks like this:
class Main: JavaPlugin(), DiscordoPlugin { ... }
It extends JavaPlugin and it implements my interface, DiscordoPlugin. This interface contains a method to access DiscordoAPI. In another plugin, I get the plugin instance of Discordo using the following:
DiscordoPlugin dp = (DiscordoPlugin) Bukkit.getServer().getPluginManager().getPlugin("Discordo");
Since my main class implements DiscordoPlugin, this cast should work, however, I get the exception:
java.lang.ClassCastException: dev.bloedarend.discordo.plugin.Main cannot be cast to dev.bloedarend.discordo.api.DiscordoPlugin
What am I doing wrong?
General theory question, how would I go about making a plot system? Would I great a new world? Or like space out each plot by 100 blocks?
hmm, can you cast it to (Main)?
I can't, since I have only deployed my api module. I thought by implementing the interface I could work around this.
wel judging from the error you clearly have access to Main
or maybe I am misunderstanding
This returns the Main instance of my plugin, but the return type is Plugin
Bukkit.getServer().getPluginManager().getPlugin("Discordo")
I see
I think you have to wait for someone more experienced with object juggling like this xD
Alright, nw :)
show the full error, my bet it says about different loaders
[19:50:59 ERROR]: Error occurred while enabling TestPlugin v1.0-SNAPSHOT (Is it up to date?)
java.lang.ClassCastException: dev.bloedarend.discordo.plugin.Main cannot be cast to dev.bloedarend.discordo.api.DiscordoPlugin
at test.dont.matter.testplugin.TestPlugin.onEnable(TestPlugin.java:18) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_321]
Wait hold on
did you make a mistake and shade your plugin into your other one?
I'm not sure, but I don't think so
?paste your pom
yep your last dependency needs a provided scope
what argument does it expect from me
Base(Player target)
Works, thank you!
I am blind, didn't see the constructor there oops
It wants a player
got it
It's not doing anything with it though
yh i got it
effects of doing too much python heehee
or well it doesnt work
it doesnt trow errors anymore but the listiner also doesnt work
how i can find that sound from the code?
is there any way?
(i want to change the sound in my resourcepack, but i don't know to change & play what)
lol
@tender shard you lurking?
https://github.com/MagmaGuy/EasyMinecraftGoals take a look if you want, when you want, it's based on the stuff you helped me with a few days back
That's not a PR :p
you mean for spigot?
yes
I'll do a spigot PR for this if I ever actually get comfortable with the inner workings of it
there's a lot of weird shit in here
the two AI systems is a shame, if they stuck to goalmanager it would be an easy addition
Yeah smh mojang
the fact that it uses goalmanager and brains and memories and per-entity AI is just a nightmare
Choco did a PR for a goal API a while back
But he got stuck on how to abstract all the vanilla goals so a plugin can make instances of them
brains do not expose enough to work with just through mappings, I will probably have to work around them to actually extend functionality
like you can't by default just remove a goal in a brain
it's not an accessible field
you can remove all goals or you can go eat shit
yeah not the worst thing, it's just compounding nuisances
what was choco stuck with?
This pull request IS a work in progress as of creating it because feedback is absolutely required before moving forwards. There are a few issues to address before this can get merged and they are as follows:
Vanilla pathfinder goals are unsupported
a. I cannot think of a sane way to interface with all vanilla pathfinder goals without creating 57 interfaces for every vanilla pathfinder goal. That's a little bit messy
b. If the approach above is used, there is no sane way to let developers create new instances of said interfaces because... well... they're interfaces
Navigation is really inconsistent. If the entity is focused on some entity other than the one to which it should navigate (i.e. #setTarget()), it will not navigate at all rendering the method pretty useless. I'm not sure of any alternative because this is just vanilla behaviour.
that second one sounds like a sort of misunderstanding of how the system is meant to work
from what I read the target, if any, is just where the entity will go
(Keep in mind this is from 2017)
the only workaround is to feed it a different target and force the entity to hold it via goals
though
navigation is confirmed to be shit
like I don't know if I still have some setting not quite right but it looks like it's barely able to pathfinding using the default methods, the next thing I'm adding is my own A* pathing
I mean it certainly works fine for Mojang
if you can't extend goal to create your own goal there really isn't much of a reason to have the system in the first place
that's because the bar for people's expectation of mc pathfinding can be found at the bottom of marianas trench
ive added the listener under the command now but how exactly can i accsess the target
I guess not being able to extend vanilla goals would be annoying yeah
are bats still committing suicide in caves?
also even 57 interfaces wouldn't cut it as much as you might think, there is a lot of hardcoded stuff in here
like slime movement
that's just hardcoded jumps
The idea bounced around in the PR was factory methods
But that wouldn't let you extend the vanilla ones
factory methods for what, Goal?
Making instances of the vanilla goals
ah
imo unextendable vanilla goals are fine so long as you can modify them to some extent, the main thing is I think you still need to be able to extend Goal in the first place
You could always delegate to them
was that PR before brains were added to the game?
pr would've been worth it just to have that one
Yeah sadly it died
Could definitely revive it to that point fairly quickly though
Might do that
at this stage I wouldn't bother unless you have something solid for brains, all new entities use them and I wouldn't be surprised if some soonish update gets rid of goalsmanager entirely
nah main thing is they hold states
instead of the old manager which only did priorities
Hmm
It is annoying they are split tho, I agree with that
What even uses brains
Villagers, Camel, Sniffer, ?
Pretty sure they do
might be wrong though
Iirc they were the debut of brains
uh
villagers use brains
and I kinda hate the brain system
because well... it's not that well abstracted
But you know what we can do
no you're right
We can add a hasBrain method :p
1.14?
that long ago?
weird
most of all I just wish there was just the one system
Brain<Villager> behaviorcontroller = this.getBrain();
behaviorcontroller.stopAll(world, this);
Lobotomy method
because rn I have to replicate AI across two different systems and for however many versions I want to support
if you remove the brain do they magically start using the goals? That would be funny
states
within them you have priorities
though everything seems to mostly have the same priority because why not
then you have behaviors
behaviours are basically goals 2.0, even the method layout is similar
Memories, Sensors, Behaviors, and Schedule
yeah
I'm going to guess memories save things, sensors are for finding targets, behaviors are for actual movement
And schedule is idk
uh sorta
I haven't really delved beyond behaviors thus far
I do wonder if there is a way to just set a dude to pathfind without setting a goal
I'm not trying to send body parts flying, I could teleport mobs to do that, I'm trying to use the navigation to send the pathfinding entity on its way without having to register a permanent goal
PathNavigation has a moveTo method
it sure does
Does enchantments have order that applies to all items?
Like:
First Sharpness
Second Protection
maybe I did it wrong before but it looked like any goal would override that @young knoll
so effectively useless unless I lobotomize them
I see
I'll have to retest it but I am decently sure I got it right in 1
it's real easy to do it for entities managed by goals because you can just remove a goal instance, brains are clearly way more annoying
Why can't I import ServerPlayer to my maven project? It's not suggesting it in the import net.minecraft.server.level
?nms
Hello! First of all I want to say that I'm new coding, and I learned today how to make custom config file, but I don't know how to create a realod method for them to use "/maincommand reload".
Code:
public static void createFiles(SimplePortalPermissions files){
if (!files.getDataFolder().exists()) {
files.getDataFolder().mkdirs();
}
//Creates messages.yml
messagesFile = new File(files.getDataFolder(), "messages.yml");
if (!messagesFile.exists()) {
files.saveResource("messages.yml", false);
}
messages = YamlConfiguration.loadConfiguration(messagesFile);
}
Thank you good sir, i found the problem. I didn't have the remapped in the dependencies!
any1 please? :D
reloadConfig();
It's custom config
@young knoll do you recommend me using some inventory APIs or handle it by myself?
Up to you
@Override
public void reloadConfig() {
newConfig = YamlConfiguration.loadConfiguration(configFile);
final InputStream defConfigStream = getResource("config.yml");
if (defConfigStream == null) {
return;
}
newConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
}```
That's the code for reloadConfig();
what do you usually use?
My own
In which class should I do that? In main one?
that's the code JavaPlugin uses
you can adapt it to reload your custom config
?whereami
idk why I can't invite to the proper one
Thank
you would need to get getResource method form your main class
Can anyone explain how to do that? i dont know how to use world generator
is this hard?
You could just use PlotSquared
custom chunk generator
I found an easier way, was simple
public static void reload() {
config = YamlConfiguration.loadConfiguration(configFile);
messages = YamlConfiguration.loadConfiguration(messagesFile);
}
nice
remember to use saveConfig if you have cached changes
oh ok
check this @pure dagger I learned from this
how?
I would actually make a class per config file
(possibly an interface and implement it in each class)
I'm gonna keep it like this atm, i don't wanna suffer again xd
it will free you of future headaches
for sure
I mean, what happen if I don't put it?
let me give you an example
public class ConfigMessage {
private final File configFile;
private FileConfiguration config;
public ConfigMessage() {
File file = ...;
handle file existance
this.config = new YamlConfiguration();
try {
this.config.load(file);
catch (IOException e) {
e.printStackTrace();
}
this.configFile = file;
}
public void reload() {
do reload stuff
}
}
so in that case you can construct that class on your JavaPlugin class
and then you can create methods inside it
so you will be able to do configMessage.reload()
np
how can i use the target from the command in the listener
lets rephrase that im too lazy to read all of it
just use some kind of collection ye
well yh im new to java
i have no idea what im doing half of the time
?paste
thank you
i want people to be able to send duel request with /duel
i dont really know where else to run it from then the listener cause the reuest is only supposed to be send when they click a certain item in the gui
for sqlite querys should i use
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
}
});
or something else?
I'm using Smile GUI Implementation
But I'm wondering, is there a way I can make it so that when a user presses "esc" it goes to a specific GUI but when a user clicks a icon it creates a new instance of the current GUI
.consumer(event -> {
Bukkit.getScheduler().runTaskLater(plugin, () -> {
plugin.guiManager.openGUI(new SpeedUpgradeInventory(ultraChest), player);
}, 1L);
});
Item click
The problem is
@Override
public void onClose(InventoryCloseEvent event) {
super.onClose(event);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
plugin.guiManager.openGUI(new MainMenuInventory(ultraChest), (Player) event.getPlayer());
}, 1L);
}
Overrides the previous one
I am not
I am just creating a new one like this
ah its in the close event
id say delay it a bit more but if it gets over 5 ticks or something then it just doesnt work
I see it
work
It opens the same one first, then instantly opens the onClose() one
But how can I have both functionality, if escape go to old menu, if click item open same menu
If anyone know how to setup vault api that can help I'd appriciate it. I followed the vault api github page and my plugin has depend: [Vault] but it keeps saying it can not find Vault :(
Just by checking if inventoryholder is null I make sure that players don't "imitate" my inventory right?
does the return statment matters?
Like, in some tutorials and codes i see it is return true;
but this is the default i get from the interface
it returns the "usage" from the plugin.yml if you return false.
?nms
Vault.jar in your plugins folder?
I'm using Smile GUI Implementation
But I'm wondering, is there a way I can make it so that when a user presses "esc" it goes to a specific GUI but when a user clicks a icon it creates a new instance of the current GUI.
What happens rn is that upon clicking an item it reopens the current inventory but then it activates the close event which opens the menu inventory.
How can I have both functionality?
yeah I'm using the latest version
show code
private boolean setupEconomy()
{
if (getServer().getPluginManager().getPlugin("Vault") == null)
{
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null)
{
return false;
}
econ = rsp.getProvider();
return econ != null;
}
also got an economy plugin?
and the onEnable just checks this method
im making my own implementer
not sure if vault knows to load yours
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
i'm using that
Exactly
You won't get anything in return, you need to be the one registering the service
java.lang.IllegalArgumentException: The embedded resource 'phoneData/db49723f-afd0-439c-9c32-7487e06b16d7.yml' cannot be found in plugins\rpphones-1.0-SNAPSHOT.jar
I'm saving a resource using plugin.saveResource("phoneData/" + phone.phoneUUID + ".yml", true);
Clearly doing something wrong
that wont work
saveResource gets an embedded resource from within your jar and exports it to the plugins/plugin folder
just call save on the fileconfig
I'm dumb
or file, i forgot
Wait but If I'm creating a new file
I assume I need to create the file first
Then attach the FileConfiguration
Then save it
ye
another issue is that even though my plugin depends on Vault - vault is still loading first
Perfect
So then, last question. getDataFolder gives me the entire folder
What if I want to make a subfolder
Do I create it once on first startup?
Perfect!
Thanks
If the subfolder isn't there
Don't matter because if subfolder is subfolder/file.yml
It'll save it correctly
that will ensure its parent folders exist
doesnt FileConfiguration#save do that?
its FileWriter related and im not aware of the impl
Still need to pass it a file
ye that file may or may not exist on your disk
Yup
Got it!
It's my first time using config as a "database"
I've always just serialized and store in pdc or sql
This is so cool
you are better than the dude that saved json in a sql db
Why did you go from SQL to configs?
@EventHandler
public void PlayerDamaged(EntityDamageByEntityEvent event) {
if (!((event.getDamager() instanceof Player)) && !((event.getEntity() instanceof Player))) return;
Player player = (Player)event.getEntity();
Player target = (Player)event.getDamager();
String playerUUID = player.getUniqueId().toString();
String targetUUID = target.getUniqueId().toString();
if ((!playersInCombat.contains(playerUUID)) && (!playersInCombat.contains(targetUUID))) {
playersInCombat.add(playerUUID);
playersInCombat.add(targetUUID);
player.sendMessage(ChatColor.RED + "You're now in Combat!");
target.sendMessage(ChatColor.RED + "You're now in Combat!");
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getPlugin(), new Runnable() {
public void run() {
if ((playersInCombat.contains(playerUUID)) && (playersInCombat.contains(targetUUID))) {
playersInCombat.remove(playerUUID);
playersInCombat.remove(targetUUID);
target.sendMessage(ChatColor.GREEN + "You can now log out safely.");
player.sendMessage(ChatColor.GREEN + "You can now log out safely.");
}
}
},200L);
}
}
why does it send it 4 times??
Storing different type of data, I could've done SQL but I wanted to try config since I never did before
Since I'm using 1 file per object, there is no performance downside
I can save/update stuff individually and I use a cache anyways
what's the underlying structure for hosting a maven repo of a multimodule project? Do I need to make a module that handles publishing and have that one stay close sourced to protect credentials?
so how am i suppoesd to fix it and it sends it to both players
there arent duplicates
id also check make sure player is not the target
?paste
Player player = (Player)event.getEntity();
Player target = (Player)event.getDamager();```
a player can be both by hurting themself
Don't think so
The only way to hurt yourself is with a projectile, in which case the damager will be the projectile
with a bow and arrow. no?
The damager is any Entity not just a Player
no, i tried that
You mistakingly just cast it ash such
otherwise if you confirmed then yeah ur good
you can set any object with FileConfiguration#set ?
i dont think u can do integers
what?
wait but will it still detect even if it isnt a shooter, eg. a sword
You can set any object that is primative or ConfigurationSeralizable
Projectiles do in fact call the EntityDamageByEntityEvent
they dont i just tested it
ok guys all i want to do is fix it outputting 4 messages
for both players
huh i reloaded the plugin and the 4 messages were fixed, what event do u use for the projectiles
thx
whats the public void EntityDamageEvent(EntityDamageEvent event) for
do i need it?
okay thankss then
python joined the chat
getHitEntity isnt a thing in projectile hit event
public void ProjectileHit(ProjectileHitEvent event) {
if (!((event.getEntity().getShooter() instanceof Player)) && !((event.getEntity() instanceof Player))) return;
Player player = (Player) event.getHitEntity();
Player target = (Player) event.getEntity().getShooter();
player.sendMessage("eeeeeeee");
String playerUUID = player.getUniqueId().toString();
String targetUUID = target.getUniqueId().toString();
if ((!playersInCombat.contains(playerUUID)) && (!playersInCombat.contains(targetUUID))) {
playersInCombat.add(playerUUID);
playersInCombat.add(targetUUID);
player.sendMessage(ChatColor.RED + "You're now in Combat!");
target.sendMessage(ChatColor.RED + "You're now in Combat!");
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getPlugin(), new Runnable() {
public void run() {
if ((playersInCombat.contains(playerUUID)) && (playersInCombat.contains(targetUUID))) {
playersInCombat.remove(playerUUID);
playersInCombat.remove(targetUUID);
target.sendMessage(ChatColor.GREEN + "You can now log out safely.");
player.sendMessage(ChatColor.GREEN + "You can now log out safely.");
}
}
}, 200L);
}
}```
Why does InventoryClick event doesn't have a getPlayer()?
getWhoClicked()
thx
Okay so I want to make that when player click with book in hand on to any block then the block will be put on that block but when player again click on that block with book in hand then this exact block will be changed to another one, unfornutly it change the one that I click but also put another one on the block face of the first one ;/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void BookPlace(final PlayerInteractEvent event) {
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
Player player = event.getPlayer();
Block targetBlockLocation = player.getTargetBlock(null, 100).getRelative(event.getBlockFace());
if (event.getHand().equals(EquipmentSlot.HAND)) {
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (targetBlockLocation.getType().equals(Material.BARRIER)) {
if (item.getType() != Material.BOOK) {
if (item.getAmount() == 1) {
item.setAmount(0);
} else {
item.setAmount(item.getAmount() - 1);
}
}
OraxenFurniture.place(targetBlockLocation.getLocation(), "leather_book_1", Rotation.NONE, BlockFace.UP, null);
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void BookPlaceAdd(final PlayerInteractEvent event) {
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
Block block = event.getClickedBlock();
if (event.getHand().equals(EquipmentSlot.HAND) && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) return;
if (item.getType() != Material.BOOK) return;
if (block == null || block.getType() != Material.BARRIER) return;
if (!Objects.equals(OraxenFurniture.getFurnitureMechanic(block).getItemID(), "leather_book_1"))
return;
if (item.getAmount() == 1) {
item.setAmount(0);
} else {
item.setAmount(item.getAmount() - 1);
}
OraxenFurniture.remove(block.getLocation(), event.getPlayer());
OraxenFurniture.place(block.getLocation(), "leather_book_2", Rotation.NONE, BlockFace.UP, null);
}
}
@grave lagoon what is the problem
for getting player I can just cast it?
or I need to check for something
tryna get the damaged player in a proj hit event
for bow shots?
ye
Someone has a guide or tutorial about permissions?
Im not talking about player.hasPermission("lol.lol");
Like, ive seen stuff too much complicated
but does the same
@grave lagoon
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{
if(event.getEntity() instanceof Player)
{
Player player = (Player) event.getEntity();
}
if (event.getDamager() instanceof Arrow)
{
if(((Arrow) event.getDamager()).getShooter() instanceof Player)
{
Player shooter = (Player) ((Arrow) event.getDamager()).getShooter();
}
}
}
what's that
does setslot start at 1 or at 0
0
No im not asking about plugin.yml
wtf
@grave lagoon
@EventHandler
public void onEntityDamageByEntity(ProjectileHitEvent event)
{
if(event.getHitEntity() instanceof Player && event.getEntity() instanceof Arrow && ((Arrow) event.getEntity()).getShooter() instanceof Player)
{
Player hittedPlayer = (Player) event.getHitEntity();
Player shooter = (Player) ((Arrow) event.getEntity()).getShooter();
}
}
or this
Hmm
But a permission node is what?
the string "lol.command"?
Okay
Thanks
Bukkit is the love of my life then
i thought i needed to code stuff
lol
How should i manage a sub command?
check arguments onCommand
You’ll have to check permissions manually for that
It’s only one line though so it’s not that bad
Yes
You can actually make a little framework, it isn't that difficult
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@weak meteor
will something like this work?
if (!(event.getDamager() instanceof Player)) return;
if (!(event.getEntity() instanceof Arrow) && !(((Arrow) event.getEntity()).getShooter() instanceof Player) || !(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
Player target;
if (event.getEntity() instanceof Arrow) {
target = (Player) ((Arrow) event.getEntity()).getShooter();
} else {
target = (Player) event.getDamager();
}```
Hmm but that only includes /kit
Lemme see if there's any post
or that
when using
Player#performCommand
if I use "/say 1"
it will execute "//say 1" or "/say 1"
let me try then
thanks
Make sure when you pass the args to the subcommand, you also pass the index of where to start parsing the subcommand's arguments
why doesn't player.performcommand get logged?
It should
you should search the internet before askin' here
@EventHandler
public void onEntityDamageByEntity(ProjectileHitEvent event)
{
if(event.getHitEntity() instanceof Player && event.getEntity() instanceof Arrow && ((Arrow) event.getEntity()).getShooter() instanceof Player)
{
Player hittedPlayer = (Player) event.getHitEntity();
Player shooter = (Player) ((Arrow) event.getEntity()).getShooter();
}
}
``` use this
getHitEntity isnt a thing
for proj hit event
That's odd naming too, onEntityDamageByEntity for ProjectileHitEvent
which version of spigot?
1.19.2 shaded
What are you trying to do exactly @grave lagoon
combat log
works fine for me
Yeah you want entitydamagebyentity event
yeah @young knoll performcommand adds a / before
would smt like this work?
if (!(event.getDamager() instanceof Player)) return;
if (!(event.getEntity() instanceof Arrow) && !(((Arrow) event.getEntity()).getShooter() instanceof Player) || !(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
Player target;
if (event.getEntity() instanceof Arrow) {
target = (Player) ((Arrow) event.getEntity()).getShooter();
} else {
target = (Player) event.getDamager();
}
You should change Arrow to Projectile
ok
@grave lagoon are you shure that the event is imported?
import org.bukkit.event.entity.ProjectileHitEvent;
one question guys, if I want to make a couple of inventories should I make an interface and implement it in those I need to?
gui menus?
i am using this https://github.com/zitreF/CocosMenu
?paste
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer cannot be cast to class org.bukkit.entity.Projectile (org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer and org.bukkit.entity.Projectile are in unnamed module of loader java.net.URLClassLoader @66cd51c3)
oh im stupid
1 sec
@grave lagoon This is how I start out in my plugin: https://paste.md-5.net/opizecajut.cs
I already made my own config to inventory parser :p
i got my vault to work i just redownloaded vault so I don't know what was wrong thanks all.
In that snippet of code, attackingPlayer will be the player that attacked regardless of whether they hit directly or with an arrow. It will be null if the attacker wasn't a player. You may also want to check if the Entity victim is an instanceof Player, if both are Players it is a PVP event and you should log it.
the strings stuff in onCommand includes the command?
like
/command arg1 arg2 arg3
and strings.length() = 3 or 4?
The array? Doesn't include
thanks
How i can finish a BukkitTask?
Finish in what sense
before the time i set
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
// code
}
}.runTaskLater(Main.getInstance(), 6000);
before the 6000 tick
pretty sure you can call cancel() within the runnable
i want it to run the codes too
Bukkit.getScheduler().runTask(plugin, (Runnable) task); is this correct for that?
or this starts that timer twice
@sullen marlinSorry for tagging but you are probably person to ask
I am kicking my head around this for last 10 days I am trying to load my custom log4j2.xml confguration
but looks like spigot overrides it anyway
Would you be able to tell me is it possible to do it and point me to some info
I would really appreciated it
code:
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin {
private Logger logger;
@Override
public void onEnable() {
String dataFolder = getDataFolder().getAbsolutePath();
logger = LogManager.getLogger("com.example.myplugin");
// Specify the path to your log4j2 configuration file
String configFilePath = dataFolder + "/log4j2.xml";
// Initialize log4j2 with the configuration file located in your plugin's directory
LoggerContext lc = Configurator.initialize(null, configFilePath);
// Set the logger level to debug
logger.atLevel(Level.INFO);
// Use the logger to log a message
logger.info("Plugin enabled!");
}```
Xml:
```<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="com.example.myplugin" level="info" additivity="false">
<AppenderRef ref="ConsoleAppender" />
</Logger>
<Root level="info">
<AppenderRef ref="ConsoleAppender" />
</Root>
</Loggers>
</Configuration>
What could go wrong?
Main:
public void registerCommand(){
FGCommand fgCommand = new FGCommand(this.config, this); // Line 57
getCommand("fg").setExecutor(fgCommand);
}
FGCommand class:
public FGCommand(Configuration config, Plugin plugin) { // Line 22
this.config = config;
this.plugin = plugin;
}
new fgCommand
getCommand("fg").setExecutor(new fgCommand());
its already defined up there
also that is not a command class
its just the constructor
can you check my problem too? thanks
its just a var: private String prefix = ChatColor.translateAlternateColorCodes('&', config.getString("prefix"));
what do you mean by "before the 6000 tick"
6000 is time
yes
so what are u trying to do
when the server starts that timer, it takes 6000 ticks to run the codes right?
yeah
i want to run the codes before that 6000 ticks
Mhm
well put your code in custom method
its not possible
add that method to runnable
and before runnable to onEnable
and it will run one time instalntly
when server start
and second time after 6000 ticks
lemme explain it a little bit
so you want code to be repetting?
when player breaks a block, a runnable starts and respawns that block after 6000 tick for example
when i turn off the server, there is a lot of not respawned blocks
Don’t do it like that
i want to respawn all of them on disable
well its the easier way
@Override
public void run() {
}
}.runTaskTimer(this,0,6000);```
this will run code on server start and on repeat every 6000 ticks
You’re just spawning a ton of tasks for no reason
i know
Have a single task that respawns blocks, when a block is broken add it to a queue with a timestamp
Have the single task check if it’s time to respawn a block, and then process it
sounds nice but there is a little problem
that Time to respawn depends on the player counts
its 10 mins by default, and subtracts 15 sec per each online player in server
So?
My plugin isnt being detected (Like 5m it was being detected) whats happening
15 seconds is like
so each time player breaks a block the time is different (maybe)
300 ticks
i only changed a var to public static bro
You can calculate that when checking if it’s time to respawn it
12000 - onlinePlayers*300
Or you can calculate that when storing it in the first place
Whichever you want
If you want the queue to be kept in order you can use a priority queue
why i can't understand, is it because of this?
so any of you guys have solutiont to my problem up @young knoll 🤣
weak
listen, imagine there is a mine with iron ores, player breaks 1 of them while there is 10 players on the server, so the blocks regenrates after 10 min - (15 sec * 10)
when he breaks the next block there is 15 players and its 10 min - (15 sec * 15)
then what? how i can calculate this
the runnable is running each 10 mins no matter how many player is there
per block?
yeah
No
whatever
One runnable
or one runnable
Keep a list of the blocks and the time they should be regenerated
And have the runnable check every second or whatever
and a Map<Long, List<WrappedBlockData>> where WrappedBlockData is a class containing location, material type and whatever else
ok thats correct till now
here my problem happens
there is some blocks they are still not regenerated
and i turn off the server
onDisable -> regenerateAll
how?
use your 3 braincells to read my message
Just loop through the map and process everything still in it
new problem may cause to do not help me more, i'm codding on 1.12.2
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.
mans using the romanian vpn
forgot it, i'll wait untill all the blocks regerates
then i turn off the server
thanks for help
Iran* 💀
I'd write a basic emotional message about how I wasted many years of my life stumbling blindly, being afraid to learn OOP
but I've been awake for 36 hours and can't bother thinking atm
Line 21: String prefix = config.getString("messagesPrefix");
Line 59: FGCommand fgCommand = new FGCommand(this.config, this);
getCommand("fg").setExecutor(fgCommand);
Line 23: registerCommand(); (the method that i just wrote)
Config.yml:
What's happening?
i do not understand
Config is probably null
this is from main
should i skip the this.config?
like, only config
Nope
same error
}).consumer(event -> {
plugin.guiManager.openGUI(new ContactManageMenu(phone, NEWPARAM), player);
});
If I'm using something like this for my GUI implementation
How can I pass a parameter specific to the item where NEWPARAM is
Like, I want to pass a UUID
How can you set the rotation of an entity with nms without setting the position? (EntityLiving)
if the process to get a repository up somewhere included taking a cyanide pill the process would be made less painful

in the openGUI?
or ContantManageMenu?
ConstantManageMenu
Like, lets say I make 10 items, each with a unique ID. then I add the consumer method to each one
InventoryButton button = new InventoryButton().creator(player1 -> {
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
return item;
}).consumer(event -> {
plugin.guiManager.openGUI(new ContactManageMenu(phone,), player);
});
public ContactManageMenu(APhone phone, UUID contact) {
super();
this.phone = phone;
this.contact = contact;
}
but ur already passing an UUID
It's because the ContactManageMenu is unique for a given UUID, but how can I actually put a UUID in the parameter
nono ok hold on
Lets say I have 10 items.
Made using
InventoryButton button = new InventoryButton().creator(player1 -> {
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
return item;
}).consumer(event -> {
plugin.guiManager.openGUI(new ContactManageMenu(phone,UUID FOR ITEM 1 - 10), player);
});
That's what I'm having issue with, I know the constructor is ready for arguments
But since it's inside a consumer I'm confused
it doesnt matter how many items you have?
They all have unique values
I already have that
I just need to figure out how to pass it
^
you can pass 10 or 2 if you want
or it has to bbe 10
any number
Ojay
This is inside a loop already
And the value I need to pass is actually in the creator() method
InventoryButton button = new InventoryButton().creator(player1 -> {
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
UUID uuid; <---- This what I want to pass
return item;
}).consumer(event -> {
plugin.guiManager.openGUI(new ContactManageMenu(phone, HERE), player);
});
Wait....
I'm an idiot
Holy shit
InventoryButton button = new InventoryButton().creator(player1 -> {
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
UUID uuid;
return item;
}).consumer(event -> {
plugin.guiManager.openGUI(new ContactManageMenu(phone, uuid), player); <---- Here
});
This literally works
I have autism, sry
Your uuid isn’t set to anything
Stop making your fields public...
All of them
Ability#mayfly for example
Mojang does a lot of things
Anyways
What is keyFly.consumeClick()
Wait is this forge fkery?
"client sided nms" <- lol
that's not--
Switch the order of the while loop and your fly check
The first loop always consumes all key clicks before it reaches the second
if(!flying) {
while(options.keyFly.consumeClick()) {
...
Same for the second.
Or even better: Dont have two while loops
Yes
But this can be boiled down to half the size
Then just make it work for now
boolean flying = false; i wonder why