#help-development
1 messages · Page 1489 of 1
where do i find that lib
That’s correct
But you haven’t imported a class called value
i need to do strin integer
It’s part of NMS
HashMap<Key, Value> name = new HashMap<Key, Value>();
The <> on the right aren’t needed
where is NMS i dont think im looking at the same one u are
no
i didnt do String, Integer
all my maps have the same <String, Interger>();
weird
It’s the vanilla server code, and part of spigot
it doesnt tell me to do it on the site im looking at
Because you don’t have to
ah
That’s a legacy thing
I need to be able to access it
Make a getter for it
And pass an instance of your main class with dependency injection
Learn java before using the spigot API
Getter is pretty basic
Also you didn’t appear to know how to use maps
I do, i just got back from water polo practice and everything is in pain and my brain no worky rn
@young knoll i still can't find anything about it
Where are you looking
@young knoll why would i need to add an instance of my main class?
Because that’s where the map is
Unless you static abuse
i found it but nothing they say i can find https://www.spigotmc.org/threads/nms-tutorials-3-gameprofiles.205493/
Game profiles don’t deal with save files
sigh
Most of NMS isn’t documented
so how can i read the nbt file
okay
I told you how to turn a file input stream input an NBT tag compound
Then you have to mess with that to get the data you want
thanks it worked
why can't there be an easier way
the stuff they say doesn't even show up in my ide
np
Because messing with offline player inventories just isn’t really intended
How do you depend on spigot
what
What are you using for the dependency
wdym
The jar? Maven? Gradle?
maven
Run buildtools for your version and change the dependency from spigot-API to spigot to access NMS
Why does this code not set the data of factionconf to /defaults/factiondefault.yml?
factionconf.setDefaults(plugin.loadConfigurationFile("/defaults", "factiondefault.yml"));
loadConfigurationFile is the following:
public FileConfiguration loadConfigurationFile(String filepath, String filename) {
File customConfigFile = new File(getDataFolder() + filepath, filename);
FileConfiguration customConfig = new YamlConfiguration();
try {
customConfig.load(customConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
return customConfig;
}
Am I not properly understanding how conf.setDefaults() works? I can't find much documentation on it, but the only thing I could find on it says it should work the way I'm using it.
I'm sorry for asking for help so often, I just can't seem to mess with configuration files well.
Defaults are used internally when a value isn’t found in the file iirc
I don’t think they are ever actually stored in the file
hmmm
Then how can I set the data of one file to another's data?
In fact, it would be better to just be able to set the data of one right from a file in the jar but I can't find a way to do that without loading it into a different file, moving it, then copying that one's data.
This works very well, but removing the tripwire hook from the inventory has the exact same problem.
Plugin.saveResource I believe
That only saves the data of a file in a plugin's JAR (which is what I need) to the main configuration folder of the plugin with the same name. I suppose I could rename it and move it though... Is there a better way to do it than that?
^
What exactly do you want to do
I'm making a configuration file for every faction (I'm making a factions plugin) named the UUID of their faction. In it, I want some data like the gamerules and permissions they have set, the description, name, etc. I need to get a template of this data because it would be a pain to manually set every default value in the code
Load it into memory with YamlConfiguration.loadConfiguration
And then set it to whatever file you want with .save
Do note this will remove comments
I'm somewhat confused on this step. In YamlConfiguration#loadConfiguration, is the File field the name of the file in the JAR's src?
But if so, this code doesn't make sense
FileConfiguration customConfig = YamlConfiguration.loadConfiguration(new File("factiondefault.yml"));
honestly I have no clue how I would even start to do that
Reader*
is there any way to know how many items were crafted via shift+click? CraftItemEvent doesn't appear to handle that
Found this, should still work https://www.spigotmc.org/threads/util-get-the-crafted-item-amount-from-a-craftitemevent.162952/
Got it, thanks :)
ya I saw various solutions like that but was hoping there was some api improvements since I didn't know about
Not that I know of
How expensive is to call the World#getBlockAt(int, int, int) method multiple times?
soooo expensive
like, suuuuper expensive to get a "Block" which is just a reference to a location
Any other alternative?
the most expensive thing you could think of
never use the method that does nothing to the world and uses almost no cpu
Are you being sarcastic?
I mean, I'm pretty aware (of what I've heard) that the World#getBlockAt() method has an impact on performance
So I just wanted to know how much
i have transcended past the help portion of this channel
i've noticed the method:
Sets the border to a square region with the specified side length in blocks```
in <https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/WorldBorder.html>
is there any way to check if it is currently moving?
Much thanks
1.8
sorry, i meant any version i just looked up worldborder spigot
well you could look at how it moves
You may be able to store the size you are aiming for and then compare it with getSize
Not sure how getSize works with movement
/worldborder set <sizeInBlocks> [timeInSeconds] this is interesting on the wiki though
you can specify speed
declaration: package: org.bukkit, interface: WorldBorder
@sage swift
I saw that lol
anyways
i need to be able to check if its moving from any world
so i dont think that would work coll
its going to be a public plugin
thx tho
how would the World affect it tho?
im trying to get a way to get the worldborder color
i dont understand
what you mean here
i need to be able to check if the border is expanding or shrinking to check the color of the border
How would that affect if it's going to multiple worlds then? Just loop through all the worlds
yea but there's no method to check if it is or not
thats my question, how would i do that
one way you could do is get the current size, wait another couple ticks
then see if it changed
that wouldnt work if the time frame was very long
unless it is tracked in huge decimal points
nvm
hey guys, do we know any new methods that are going to be available for 1.17 dev yet?
not sure if tehre's an api link yet
No
Not at all
10-4 thanks man
why 1.18 buildtools no work!!
100.00000114651071
tick later
100.00000114652671
thank u pulse u were absolutely correct
np
is there a way to get a class without calling "new"?
Wait
thats what the constructor is for right?
or.
Yes
Or you can use Reflection
alright thank you
plugin.ListenChat.put(plr.getName(), 1);
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player plr = event.getPlayer();
Map<String, Integer> playerMap = plugin.ListenChat;
plr.sendMessage("pp :)");
if(playerMap.containsKey(plr.getName())) {
event.setCancelled(true);
plr.sendMessage("help");
plr.sendMessage(event.getMessage());
}
return;
}
this is in my main class (plugin)public Map<String, Integer> ListenChat = new HashMap<String, Integer>();
And the problem is...?
The conversation api is... a bit verbose
though admittedly that was likely simply due to how I used it
please
Don’t destroy packet them?
settingsPane.addItem(new GuiItem(rlMsgItem, event -> {
Player plr = (Player) event.getWhoClicked();
plugin.ListenChat.put(plr.getName(), 1);
plr.closeInventory();
plr.sendMessage("aaaaaaaaaaa");
}), 0, 0);
^^^ Runs when the item is clicked in GUI
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player plr = event.getPlayer();
Map<String, Integer> playerMap = plugin.ListenChat;
plr.sendMessage("test :)");
if(playerMap.containsKey(plr.getName())) {
event.setCancelled(true);
plr.sendMessage("help");
plr.sendMessage(event.getMessage());
}
return;
}
^^^ Chat Event
this is in my main class (plugin)public Map<String, Integer> ListenChat = new HashMap<String, Integer>();
it doesnt send me any messages exept the AAAAAAAAAAAAA one
didnt do @EventHandler 🤦♂️
i feel you there
Probably better to freeze a player by setting their walk speed to 0
And giving them jump boost > 128 to stop jumping
The 'return' is redundant
What video do you recommend to learn to program plugins?
umm where can I find the finished gradle project after i build it
are you sure you built it
clicked the hammer
what hammer
isnt gradle dist the task you need for a jar
IDE*
idk I dont use gradle
i have no idea md
It’s build for me
i'm just starting to use gradle
dist?
use your CLI
click build on there?
🤷 i have no idea man i just use shit from cli
gradle terminal?
try gradle jar
theme_eclipse is amazing
IntelliJ IDEA has Gradle bundled
You can double-press control and then execute any command
For example, gradle build
?1.17
There is no ETA for 1.17. Having an ETA leads to unrealistic deadlines, false hope, and a bad product. It will be ready when it's ready.
for nodejs btw
Oh, Is there any way to fake console as player?
i mean, is there any code available there which uses dummy player?
if(action.equals(action.RIGHT_CLICK_BLOCK) || action.equals(action.RIGHT_CLICK_AIR) || player.getInventory().getItemInMainHand().equals(Material.COMPASS)) {
openGui(event.getPlayer());
}```
whats wrong in this i get this err
what language is that even supposed to be yeesh
What error?
wait a sec
uploading to pastebin cuz not letting me to post here
The last || should probably be &&, because you want to check if someone right clicks with a compass, right?
ohh
I can't access the pastebin, sorry
yea
u r using a higher or lower version than your server is at
yea i am using 1.8.8
but using plugin version 1.12
ohh
how do i do it in intellij ide?
just.. uhm.. using another spigot-api version
it doesnt give me options below 1.12
yea
just change the numbers to 1.8.8
ohh ok
<version>1.16.5-R0.1-SNAPSHOT</version>
i have this
what can i do
yeah and you change 1.16.5 to 1.8.8
ok :)
Dependency 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT' not found
maybe its called something else
make sure you have the spigot maven repo in your pom
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
they might have 1.12 only cause they ran buildtools
Hey? Is there a way to run spigot plugins (specifically dynmap) with forge mods on 1.16.5?
Use the Forge version of Dynmap
is it possible to make world guard regions/regions in general show up on forge dynmap
How do I get permissions from an op player? Like if I try with hasPermission it of course always returns true...
you can check both hasPermission and isPermissionSet
isPermissionSet will not return true for Ops unless they actually have the node
Thank you 😄
if you don't want op's to have a permission by default, set the permissiondefault of it to false
Can i force someone to see the end credits
Yes
public class ExampleMod extends JavaPlugin implements Listener {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
displayCredits((Player) sender);
} else {
sender.sendMessage(ChatColor.RED + "Must be a player.");
}
return true;
}
private void displayCredits(Player player) {
CraftPlayer craft = (CraftPlayer) player;
EntityPlayer nms = craft.getHandle();
nms.viewingCredits = true;
nms.playerConnection.sendPacket(new Packet70Bed(4, 0));
}
}
Found this code
There is climbing packet?
I wanna to create climbing imitation, using packets without setVelocity
For me Packet70BEd doesnt work
.
idk just googled. Just use ProtocolLib, avaiable packets: https://wiki.vg/Protocol
google how to use protocollib
add the repo
then there should be a 'maven refresh' button in the top right and it will resolve it
do i press that when its red?
Anyone knows how to decompile, modify a text in a .class file into a .jar (plugin) and recompile it?
oh yea that works ty
decompile, modify the decompiled source, fix decompiler errors, and recompile
how would i do it with protoclib
i mean how would i send a packet
idk 1 sec
Maybe
private void displayCredits(Player player) throws InvocationTargetException, IllegalArgumentException, IllegalAccessException {
BukkitUnwrapper unwrapper = new BukkitUnwrapper();
Object nms = unwrapper.unwrapItem(player);
PacketContainer useBed = new PacketContainer(Packets.Server.BED);
useBed.getIntegers().
write(0, 4).
write(1, 0);
FuzzyReflection.fromObject(nms).getFieldByName("viewingCredits").set(nms, true);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, useBed);
}
But idk I just copied it xD
I mean you do need to import still
i've done this before and never used any of that shit
Is there anything wrong with this if statement? It seems to pass if I have 3 items instead of at least 10
if (player.getInventory().containsAtLeast(item, 10)) {
did you make sure they arent named differently, have different lore
anything like that
it shoudl never pass on 3
nope
well how did u do it
do you maybe have 3 stacks instead of 3 items?
because otherwise, if you dont have more than 3 of that itemstack, it shouldnt pass
try this:
PacketContainer credits = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.GAME_STATE_CHANGE);
credits.getIntegers().write(4, 0);
credits.getFloat().write(0, 1.0F);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, credits);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
not sure if it will work tho, give it a shot
@quaint mantle
alr
I know how to do this in NMS, but im not sure in protocollib
i could do it in nms but idk how lol
nah dont work
coudl you show me in nms?
final CraftPlayer craft = (CraftPlayer) player;
final EntityPlayer entity = craft.getHandle();
entity.viewingCredits = true;
entity.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 1.0F));
I think this is how you do it
Oh wait
you need to use an unsigned byte
one second
You may have to some reflection stuff
one second
I don't so i rlly dont know whats going on
can you send us the full code and maybe a test attempt?
alr
pretty sure it would just be PacketPlayOutGameStateChange.e instead of 4
Full code is way too much to send but this is the method that's being triggerd
ItemStack item = new ItemStack(mat.get(player.getUniqueId()), 10);
if (emptySlots(chest.getInventory()) >= 1) {
OfflinePlayer seller = plugin.getData().getConfig().getOfflinePlayer("sign." + sign.getBlock().getLocation());
if (plugin.getEco().getBalance(seller) >= price) {
if (player.getInventory().containsAtLeast(item, 10)) {
player.getInventory().removeItem(item);
chest.getInventory().addItem(item);
plugin.getEco().depositPlayer(player, price);
plugin.getEco().withdrawPlayer(seller, price);
// succes
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getMessage().getConfig().getString("sucess_sell")));
} else {
// doesnt have the item
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getMessage().getConfig().getString("error_sell_item")));
}
} else {
// seller doesn't have money, fucking noob
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getMessage().getConfig().getString("error_seller_money")));
}
} else {
// chest full
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getMessage().getConfig().getString("error_chest_full")));
}
?paste
⬆️
is that for the end screen?
Full code would be 36 classes so i dont think you'll want that XD
// seller doesn't have money, fucking noob nice
np
ikr, its so funny to read back some plugins just to find comments like that XD
Love doing it
speed xD
i wasnt on an ide
could be that you are checking if the inventory contains 10x 10 items of this type iirc
If that would be the case it still woundt pass if I only have 3 items
some weird shit going on
new ItemStack(skrt papaka, 1);
Ah okay gimme a moment\
reloading server rn
well restarting
Works
Thats still weird becuz i used the same exact method with a chest inventory and that did work
Anyways ty
^^
Guys hello. How to prevent the player from going outside the square. I have distance if i to go to angle, then distance will be different.
You can probably use the BoundingBox class to define a square
You can then use BoundingBox#contains(entity.getLocation().toVector()) to check if the entity is still inside
It doesn't work
what kind of BoundingBox are you using that takes 4 parameters o.O
1.12.2
that version did not have spigot bounding boxes
Is there an analogy?
nothing I recall inside spigot directly
tho implementing a simple AABB isn't too hard
is there an event when a player feeds an animal?
there is EntityEnterLoveModeEvent
which is called when, well, and entity moves into love mode
besides that, I don't think there is a standalone event for feeding (something like a baby to grow up)
could also use PlayerInteractAtEntityEvent and check if the animal is being "fed" by checking it is being right clicked and it is holding the food item
Use PlayerInteractEntityEvent unless you need the location
So I have part of my plugin where whenever you place a chest it spawns an invisible armor stand with text above it, when you break the chest it is supposed to subsequently remove the armor stand; however this doesn't appear to be happening.
The armor stand just stays there, The code itself works as it removes all armor stands in a 2*2*2 radius of the chest and if I were to place a normal armor stand next to the chest, that does gets removed; its only the invisible one that stays there.
Ive tried running commands such as /killall entities yet the armor stand appears to just stay there permanently
Does anyone happen to know why this is happening and any potential fixes to the issue?
If the armorstand is still there its because its a packet sent entity. Which means you need to either relog or leave the world.
I assumed it wasn't his plugin. lol
Don't even know if its packet based yet 🤷 just assuming
it won't be
assuming he's using the armor stands for names that'll show wether or not the chests are filled
Show us your code
if i have a hashmap<Location;List<ItemStack>> and i add 3 item stacks where 2 of them are the exact same, is there a way to merge this 2 items that are the same thing and only have 2 item stacks? or does this happen automatically?
like when you do put(), does this always add another item or checks if theres already one to add it to
check them if they are the same. if so -> +1 amount
yea but what happens when you reach 64 items?
does this go up to 100 or more?
so like Stone x 100
and then when you add the items to the inv it splits into 2 stacks of 64 items each
anyone know how to make it so i can put prot 6 on stuff cuz when i put a prot 6 book on armor it just goes to prot 4 (also with other enchants)
use use unsafe enchants
what?
He's not making a plugin
Hello, is there a plugin that increases XP gains? So that people can get a whole level of xp when they kill a mob
Wrong channel
Mb.
Not hard to make one
If you have a null Object, is getClass working then?
null isnt an object
For example
public AClass(Object o)
Class c = o.getClass()
if null is passed a NPE will be thrown
Ok thanks
no but you can compare instanceof on a null object
You can just use the comparison operator to check otherwise
or expression whatever its called
comparison operator
“comparison operator” cs class fun times
back to the real workd
where nobody cares what you call it
cause i’ve hear “little equals thingies”
lmao
the thingis
Hey guys, what's the even when a item is used, and how can I modify the item durability to reset it (like unbreakable)
Why not just add the unbreakable tag
get the item meta through ItemStack#getItemMeta
check if the itemmeta instanceof Damageable
cast it and then set the damage to 0 I think
I am getting an NPE on this line
plugin.settingsGui.show(plr);
context is
On player chat event
Im trying to open a gui after they type smthng
Check if settingsGui and plr are null
plr is just event.getPlayer()
public ChestGui settingsGui;
and then on my onenable
settingsGui = guiClass.createSettingsGui();
also in my onEnable
guiClass = new GuiClass(this);
@gaunt relic ic
leme send the error
Caused by: java.lang.IllegalStateException: InventoryOpenEvent cannot be triggered asynchronously from another thread.
You need to open inventories synchronously, to do that run a bukkit task, Bukkit.getScheduler().runTask(
just so im learning, and its not spoonfeeding
its not threadsafe
why?
because its not synchronized. á u can modify it from other threads what could let your program explode
alright
The event is Async, Async means more than one thing can be run at the same time without jamming the main thing
but some methods on bukkit API require for it to be Sync
so do Bukkit.getScheduler().runTask(plugin, {
}));
yup
yes, and open GUI in there
thanks
wait then why do i not need to do that wehn running a command?
are the commands always in sync with the server?
forgot the arrow () ->
yes just like everything else except a few functions
got it
The method runTask(Plugin, Runnable) in the type BukkitScheduler is not applicable for the arguments ((<no type> plugin) -> {})
i get this error when doing the runnable?
ohh
nvm im dum
you have some nerve
I mean the preferred type is UUID there
intellij is imposter?
ahahahahh
thats why you should use eclipse 😏
oh god is that a paint or a code?
i mean look at this clean setup
folders and classes look so clean
do not use maven or eclipse
🤮
i use both lol
what is the issue with maven o.O
there is your problem
you can do more with gradle
sure fam, I can spend days upgrading to their new not backwards compatible release
idk, not using eclipse nor gradle seems like a very personal opionion
Both gradle and maven work at their finest
^^
idk i use eclipse because intellij is too confusing
Like, i could use it
But it just doesnt look as good, it trys to look smooth but it doesnt do it right
And it just looks- off
and eclipse is just so much simpler
you push button, code go there
hi, Sorry to interrupt your conversation, I am new to the discord server I would like a little information: you would have an Economy plugin advised me. thank you in advance^^
Could not pass event AsyncPlayerChatEvent to zAChat v1.0
org.bukkit.event.EventException: null
ru.zachat.ChatHandler.onChat(ChatHandler.java:25)
for (Entity near : p.getNearbyEntities(16,16,16)) { // <---- 25 LINE
if (near instanceof Player) {
Player nearby = ((Player) near).getPlayer();
nearby.sendMessage(e.getFormat());
}
}
what is wrong?
just had this issue lol
can you even use getNearbyEntites off the main thread
make a runnable
you can't run getNearbyEntites async
Bukkit.getScheduler().runTask(`main class`, new Runnable() {
@Override
public void run() {
}
});
thank you, i'll try
yup, that helps. Thank you again.
now i know how to start sync task in async
Ok, so i have a list of materials in my config. Im trying to get them with for Material i : config.getlist()
and its suggesting that i change it to a Object rather than Material
So it depends on how you store them in your config, I imagine it's just a List<String> right?
yea
What youll want to do then is for(String i : config.getList()) {}, or ``config.getList().forEach((i) -> {});`
but how do i then convert the string to a material
Material.matchMaterial(String) would be one way
thank you good sir
valueOf would work too
Material m = Material.valueOf(i.toUpperCase());
for(String i : plugin.getConfig().getList(""))
That would throw an IllegalArgumentException but yeah
If it's an illegal argument, then yup, as expected
cast it, for(String i : (List<String>) plugin.getConfig().getList("yourList")
Nope
getStringList works also
Just looked through my own source code, I use material.matchMaterial(String)
This is the entire part, if it helps you any:
List<String> recipeKeysList = this.getConfig().getStringList("recipeKeys");
for(String str : recipeKeysList) {
String[] parts = str.split("<-->");
char key = parts[0].toCharArray()[0];
Material m = Material.matchMaterial(parts[1]);
if(m == null) {
plugin.logWarn("Invalid material for Torch recipe: " + parts[1]);
plugin.logWarn("Errors may occur from now on!");
}
recipeKeys.put(key, m);
}
Minecraft 1.17 is out! Now we have to wait for spigot to update
Oh nvm #851747463178354729
so i made a skypvp plugin and my problem is i can't seems to get the CombatLog [ custom within the plugin ] to work correctly .
the combat log is working only 1 time . first time
when i hit player .
but after its not even work
Why not use CombatLogX 😉
Then hook
hook what?
Hook CombatLogX and just add support for your stats
It should be much easier and faster than rewriting an entire CombatLog plugin
||Disclaimer: I might be a part of their support team xd||
that is good thing xD
is there an easier way of updating a gui than closing it, updating it, and reopening it
because that resets your curser to the middle
nvm
i think you can just not close it
lol
Just reopen the gui
While they got it open
Aye Bomp
Yo what up comp
Alg hbu 🙂
Boutta try making my own in memory cache
And minecraft inventories lol(separate projects)
Intriguing, tell me in hc the results 😛
once you're done with your masterpiece that is
Well see on the memory cache it’s gonna take me a while, I mean I pretty much already did the inventories
Just have to push my work
guys when it spigot downgrading to 1.7? I just want to be ahead of the curve on this one
1.7 user: don't you mean.... UPGRADING!?
one more major version and we will no longer know if the people typing 1.8 meant to say 1.18 or are actually still stuck in 1.8
Let's just assume 1.18 by default ;/
You wish
If they're still on 1.8 it's their fault
suggestion: remove 1.8 tag from spigot plugin development section
hello, how can i check for the version of a server to do things be compatible in other versions?
and i must use 1.8.8 or 1_8_R3?
You can use whatever you want to identify it
wow elite mob!!!
pog
1.8 isn’t missing out on much performance wise at least definitely feature wise tho lol
so for example in 1.8.8 its note_pling and in 1.12.2 it block_note_pling, this will work?
if (Bukkit.getServer().getBukkitVersion().equals('1.8.8')) {
Sound.NOTE_PLIG
} else if (Bukkit.getServer().getBukkitVersion().equals('1.12.2')) {
Sound.BLOCK_NOTE_PLING
}```
buddy
See what happens
ik, but its an example
it's a bad one
Not necesarilly tbh
oh, idk, i never checked versions
It correctly describes the wanted behaviour. Whether it's the best solution is a different one 🙂
Personally I'd do a bit of parsing to figure out the x in in 1.x.y, then compare that
I just wanna say we got a new command 😛
Oh do tell!
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I somehow doubt this is actually the intended behavior tbh
Sololearn 10/10
Wat since when is there a learn java command 👀
Woo
hey conclure can you add https://programmingbydoing.com/ ? it did me a lot of good
Teach yourself to code with a safety net.
since just now :"D
W3 for Java is pretty terrible in my opinion
programmingbydoing is how I got started, the rest wasn't really doing it for me
I cant even load the image /s
if i have in config.yml a string with & for colors, how i can parse those codes when i use that string in .sendMessage
?
ChatColor.translateAlternate something something
ChatColor.translateAlternateColorCodes
@torn shuttle sure
thanks
stick it in here directly
Is that all Java Magma?
ChatColor.translateAlternateColorCodes('&', 'message here')
yeah it is
verify yourself first
Thanks @lunar schooner and @young knoll
Happy to help !
@lunar schooner so this will work?
Yes. I'm not sure about the Sound class itself, but if it is the way as you describe it will
Though I would definitely change your version detection
lol I'd share teh code I wrote to compare versions but reading back it's really not great
it's crazy how much you pick up over the years huh
E.g ```java
String version = Bukkit.getServer().getBukkitVersion().split(Pattern.quote("."))[1]
if(version > 12) {
...
} else if (version < 12) {
...
}
guess I can rewrite it
where?
I'll clean it up and share it
ok
https://github.com/TheDutchMC/rConsole/blob/master/core/src/main/java/nl/thedutchmc/rconsole/core/update/UpdateChecker.java this is my version checker
it's pretty eh, but it works 😂
Anyone know of how to get a lot of player heads - but with the texture of country flags
@wise kite
Then show me that code 🙂
if the null is your issue
missing % i'm guessing. I'm not familiar with Skript, but I'm guessing it should be %player% and %balance%
oh the playerdata? sec
So riddle me this, why use Skript when you can broadcast directly from code?
Bukkit.broadcast(String) if I remember
public double getBalance(OfflinePlayer offlinePlayer) {
Double i = PlayerData.getIntOF(offlinePlayer, "Coins");
i++;
i--;
Bukkit.broadcastMessage(i + " in code.");
return i;
}
line 4 and 5 are redundant
@lunar schooner this will work for version to version?
String version = Bukkit.getServer().getBukkitVersion().split(Pattern.quote("."))[1]
if(version > 12 && version < 1.13) {
...
} else if (version < 12 || version > 1.8) {
...
}```
that looks like it doesnt work to me
i use vault as a softdependencie
oh
Replace 1.13 with 13, 1.8 with 8
is 1.17 spigot out??
thx
ok
/**
* Compares a Minecraft version with the current version on the server. Returns true if the version on the server is older.
*
* @param majorVersion Target major version to compare (i.e. 1.>>>17<<<.0)
* @param minorVersion Target minor version to compare (i.e. 1.17.>>>0<<<)
* @return Whether the version is under the value to be compared
*/
public static boolean serverVersionOlderThan(int majorVersion, int minorVersion) {
int actualMajorVersion = Integer.parseInt(Bukkit.getBukkitVersion().split("[.]")[1]);
int actualMinorVersion = Integer.parseInt(Bukkit.getBukkitVersion().split("[.]")[2]);
if (actualMajorVersion < majorVersion)
return true;
return actualMajorVersion == majorVersion && actualMinorVersion < minorVersion;
}
this (probably) works, haven't tested yet
I'd use Pattern.quote
yeah that's also fine
so if i have this i only need to put it in onEnable() method as: ?
public void onEnable() {
<Class>.serverVersionOlderThan(1.8, 1.12)
}```
missing an if statement but that's the general idea
actually no
because it's a single argument
so
if (VersionChecker.serverVersionOlderThan(8, 0) && VersionChecker.serverVersionOlderThan(12, 0){
while (true)
sendMagmaGuyMoneyOnPayPal();
}
mind you that's redundant
if it's older than 8 then it sure as shit is older than 12
but you get the idea
Im tryna create an itemstack with the SKULL_ITEM Material, but for some reason it isnt there. Only LEGACY_SKULL_ITEM and others. Any clues?
you're going to have to mess with skull meta prolly
tryna use a custom texture and add it onto the meta, for that i would need SKULL_ITEM pretty sure
did u put the api version to 1.13?
im running latest from buildtools
or nvm
Ill see if player_head works, thanks
what was the issue?
hey, does someone have the same issues with Timed Rewards | MySQL | [1.8-1.16] 3.3.13 ?
hey man, sorry i thought everyone has problems. So apparently if I implement this plugin it works all fine until i do /trs reload, after that it just does not display the objects from /rewards, and it doesnt matter if i change anything in the .yml, even if i do not change anything it just disappears
entity.setVelocity(Vector velocity) What do I set as velocity if I want the entity to be launched toward the player like 1 or 2 block infront the player?
registerNewObjective wants a component
can people already make minecraft 1.17 servers?
Yes
prove it
playerloginevent is pre initializing the player so just when a player clicks join on server it is called
playerjoinevent is called at when about the 'Name' has joined the server part happens
owh okay
If you wanna mess with game involving stuff like teleporting the player then use PlayerJoinEvent
Because it's outdated
I mean it's the definition of ancient at this point
Remove versions below 1.13
omg doggo
Anyone know why the Javadocs for scoreboards take strings while the API actually takes components?
do u use paper api?
Can I have multiple players open the same custom inventory? Will they be properly synchronized?
yes
thanks
Checked Paper's javadocs, they use strings too
But could be
they use it altho its deprecated in favor of adventure
Adventure?
Oh, you just mean Components?
Could I draw your attention to the spigot javadocs?
sure link me
declaration: package: org.bukkit.scoreboard, interface: Scoreboard
Uses strings, non-deprecated
While the API I'm looking at uses components
Yes because you're depending on paper api
I think at least
declaration: package: org.bukkit.scoreboard, interface: Scoreboard
there
Anyway, makes sense
Are components generally considered better here?
I can see why you'd use them if they're available
But I'm not sure exactly what they can do
That others can't
If you are using Paper API, always use components
Not as if you can make click events for the scoreboards
Care to expand?
Adds a little time to dev to do so
(I know they get parsed to components anyway)
Actually, it will save you a ton of concatenation nightmares
I mean I guess it's good in regards to hover events, click events, translatable messages etc but its significantly more verbose consider normal strings and the special syntax given for them merely
After all, they are deprecated in the api for a reason - to force devs to use the adventure api more
But in this case, I feel like the extra verbosity is def worth
the quality it brings on the table
Can the scoreboard actually make any use of the JSON message stuff?
Like there's no click events etc AFAIK
In adventure?
Yeah
I mean the components are glorified json messages
To me JSON messages = Components = Adventure
Unless I'm wrong
to add the basic color you can do
NamedTextColor
Like Component.text("I am red!", NamedTextColor.RED)
Is this whole adventure thing integrated into spigot now?
Thought as much
however, it is for Paper api
Oh, interesting
You can call the toString method I believe or smtng if u wanna use it in spigot
No need
you can shade it in
and use audiences
unless you referring to getting the json?
Audiences is only for sending stuff right?
Nah
But anyway - I was wondering if there was any benefit vs using ChatColor
Other than performance of course
ClickEvents hoverevents etc
ChatColor is a bungee chat thing
Actually, adventure is known to hog quite a bit of memory
I can't imagine scoreboard actually doing anything
NamedTextColor is an adventure thing
Every time I ask a simple question you guys do not answer it
Scoreboards?
Does scoreboard make use of any json features like clickevents etc?
no
Uh.. no
Figured, thanks.
Cheers for the other enlightenment
bofa
Who knows, seems like they could've put it in at some point.
If components are being used I tend to think they'd put it in for a reason
Or maybe there's another special component based feature that can be used
Hey, how would I loop all the servers, I know you loop ProxyServer.getInstance().getServers(), but what do I set each loop value as?
(i want to do something on each server)
Go into the implementation of the method
wdym set each loop value
and see the type
I looked it up on the doc, and it returns a map (unless im using the wrong method)
Bukkit.getAllPlayers?
what
getOnlinePlayers *
Im looping all the servers, not the players
^
I want to run a command on each of the servers
Maybe you can do this:
for(ProxyServer servers: ProxyServer.getInstance().getServers()){
}
Look at the error
not applicable to X
because it is a map, you have to likely loop through the Entry set of the map
for (Map.Entry<String, ServerInfo> server : ProxyServer.getInstance().getServers().entrySet()) {
}
try this
I've got that far, but now I need to figure out what goes there
Also that still gives the same error
can I use == for inventories to see if an inventory event is about the inventory I care about?
No
Hmm, ok, no errors, ill give this a try and see if I can even use this lol
since i might need a messaging channel if this idea doesnt work
sometimes but its inconsistent as it may just create a wrapper and then it wont work
^, that's why I said no so you wont use it as it is not good
yeah lol
then how do I check if it's the correct one? I read that I should be using .getName() and compare those but according to my auto complete .getName() doesn't exist
One way is InventoryHolder, another way is InventoryView
No
you should never use getName(), also i beleive the method was removed
at some point of time
obviously not implementing InventoryHolder right
lol
🥴
so do I compare the titles of the InventoryViews then?
then how should I be doing it if I can't just compare the objects as the server might secretly be creating some wrapper?
I mean it may sound like a convincing design but think let's take an example. For instance we might wanna compare humans. It might work if we base it of names, as an example Josh is not equal to Bob. However multiple humans might go with the same name and then we can't uniquely identify every human.
yes Player#spigot()#sendMessage
I know comparing names is far from a clean thing to do but honestly I doubt any other plugin will be using the same inventory names, and you're not offering an alternative
I don't wanna be comparing names but if that's my only option I'm gonna do it
Well I mentioned 2 other ways
@quaint mantle https://www.spigotmc.org/wiki/the-chat-component-api/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
no that wasnt for you
One way is InventoryHolder, another way is InventoryView
that is pretty vague, I was told that just comparing the inventories wouldn't work because it might just be a wrapper inventory, I assumed the same might be the case for InventoryView
uh no its shaded
also, optimally I wanna compare it to an inventory I created earlier, regardless of who the player interacting with it is, having it opened by multiple players
//method one
class Menu implements InventoryHolder {
final Inventory inv = Bukkit.createInventory(...);
@Override public Inventory getInventory() { return inv; }
}
class MenuListener implements Listener {
final Menu menu = new Menu();
@EventHandler void onClick(InventoryClickEvent event) {
Inventory inv = event.getClickedInventory();
if (inv == null) {
return;
}
if (!(inv.getHolder() instanceof Menu)) {
return;
}
//do stuff
}
}
I believe coll has a good example of how InventoryView would be used. @young knoll
Yeah what are you doing rn?
Which value of the effect enum is the tnt explosion effect? i dont see it
The simplest way is to add the view to a hashset, and then check contains in the inventory events
so I'm supposed to implement my own InventoryHolder?
yeah with InventoryHolders you would do that
altho what coll said is more api friendly
thats thre wrong one
u imported the wrong TextComponent
1.17 just released today
ye
1.17 spigot isnt out yet
which ones are available for u
when I try to load 1.16maps on 1.15 it crashes
1.16.1 map on 1.16.2 server crashes too
if i remember it correctly
hmm spigot is forwards compatible
This still
nope
Minecraft itself isn't backwards compatible
yeah
which ones can u import?
I believe it should contain the term bungee in it
remove that one
Use this one:
import net.md_5.bungee.api.chat.TextComponent;
Its working fine for me 🙂
let the IDE make suggestions
if he uses an ide that is
You can write, for example, TextComp, you will get a list of classes/interfaces which names starts with TextComp
he uses as I've seen
¯_(ツ)_/¯
u might have to add it separately then
what dependency are you using btw
oh u should use the shaded one
We recommend maven
did u run buildtools darthvader?
maybe not but i still can load a 1.16 single player onto 1.15
It also includes transitive dependencies, though the shaded one + default IDE builder will still work
i found this hardcore plugin that puts you into spectator mode when you die the 3rd time, but you cant fly through walls or go through any blocks, ive looked at the sourcecode and the only thing it seems to do is p.setGameMode(GameMode.SPECTATOR)
does anyone know how i can replicate this?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
run it and comeback
hard to tell without showing the source
I have added the lib of spigot (1.8.8). You can find a step by step list to download the spigot jar here: https://www.spigotmc.org/wiki/buildtools/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
hmm say if you hire someone to make a plugin for you. But you don't really trust him. You think he might put a virus in the plugin he made. How can you check the plugin?
but you don't understand code
I mean then you would need to ask someone code knowledgeable
or just skip the commission
rip imagine if theres a antivirus for plugins
like disable deletion of world files and stuff
there is
optic fusion maintains one afaik
I believe you can also configure javas security manager
okie but what if you rented a server
yeah then it might be more difficult
and you don't have access to security manager
hmm did someone not make a AV plugin yet?
although frankly it would be kinda your own fault if one jumps into something sketchy
bets its gonna be popular
https://www.spigotmc.org/resources/spigot-anti-malware-detects-over-300-malicious-plugins.64982/ imagine if this is a malware itself
just like those antiviruses which are viruses lol
umm why is there so many pl in verified chat?
wait is @onyx fjord the one and only spigot dev?
uh no??
Nani?
he is announcing "welcome, lets update spigot to 1.17"
and stuff
He is trooling
XD
But md is the only one in charge for updates, everyone else is ... an imposter
Choco also does a lot
dont ping me tho
uhhhhh