#help-development
1 messages · Page 1604 of 1
Well you're not calling it
it should be <
anyone?
yup
org.bukkit.craftbukkit.v1_8_R3.block.CraftBlockState cannot be cast to org.bukkit.material.Directional
``` whyyyy
you cant cast material to block state
Im using the wrong directional? ' -'
Think so
It tells you to upgrade client or change auth type
What is the correct directional
I'm not sure
but it's something like org.bukkit.block.Directional
if that exists
why do you need blockstate
so how could i do that? i run mysql workbench
You don't cast state. This isn't a modern version
How i cast the state
You don't
How i use directional on the block ,_,
If you want to use Directional on a block you need to
- Get the BlockData of a Block
- Check if its instance of org.bukkit.block.data.Directional
- Cast it to org.bukkit.block.data.Directional
1.8
Ah. Then:
- Update
- Do the stuff from above
Yeah do what I said
Um that should get taken down lmao
Idk if this is legal, i only searched Spigot 1.8 setFacingDirection
Its even for 1.8.4
And its def not legal
uh, so, sorry.
Anyway do what I said then getMaterial and set the new block
Idk how to do that
What part
Idk how to create a MaterialData
new MaterialData
Idk how to interact with MaterialData ' -'
Im saying about bytes
Im saying, how can i convert blockface to byte
Why are you converting BlockFace
For what
Even when i cast it for some reason it still is CraftBlock
Im making a mystery box plugin that has a command to add new mystery box to the map, and i want it to go directly on player direction.
Like the compiler removes the cast for being unnesesary
Yeah so do what I told you
I need you to trust me here...
Just do exactly what I said
Yeah that's because it is
Casting doesnt change the actual type of an Object
oh wow I managed to permanently brick my intellij install
How lmao
Congrats on begoming a java ™️ teveloper
you mean Oracle ™️ Java ™️ developer?
Still less paim than c
c# is lit tho
Thats literaly like comparing javascript and java
Huh?
Are you speaking of C# ?
Yep comparing c# and c
lol which one is js in this metaphor
that's why I like it
easy to learn lol
if you know java and js it's fat stacks easy street
I really like delegates
And the fact that types dont erase at runtime
I've not done enough c# yet to see downsides but so far it feels a lot like java but slightly better
But if Java had those two features i wouldnt give C# a second thought
I dont like the way access modification is done
But how this will work with what i want?
Because I'm helping you get the Directional interface .-.
if(sender instanceof Player) { Player player = (Player) sender;
How do I change this in so it also lets command blocks use this command?
But idk how to use bytes
if sender instanceof BlockCommandSender
does this also let players use it?
Just use getData on your block to get the byte. Or just skip it, byte isn't important here and will be overriden
or only command?
did nnya show up and get banned again since the last time I saw him?
I think so
No idea but probably. Guy comes on every few hours
If you let them. Sure.
what a bizarre behavioral pattern he has
Every CommandSender can execute every command. How you handle the different types of CommandSender inside your method is completely up to you.
?paste
Ah okay! thanks for explaining!
https://paste.md-5.net/fuveqofope.cs
i can open an inventory from "shop" but not anywhere else
MaterialData mdata = new MaterialData(Material.ENDER_CHEST);
```what i do now?
draw the rest of the owl
Now cast mdata to Directional
Idk how to cast something ;;-;
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
(cast)something
Uh
Example:
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String string, String[] strings) {
if (commandSender instanceof Player) {
commandSender.sendMessage("You are a player.");
} else if (commandSender instanceof BlockCommandSender) {
commandSender.sendMessage("You are a command block.");
} else {
commandSender.sendMessage("Only a player or command block can execute this command.");
}
return true;
}
did you just assume my command sender type?
triggered
Thanks! Gonna save this
It is what i made with egtState()?
(((triggered)triggered)triggered)
Directional mdir = ((Directional) mdata); ?
Yes
I dont know the name lol
Now use mdir to set facing
But now i know lol
brackets and parenthesis are different things
yeah mb
Is there any way to pass in the getCommand method as an parameter to another method?
i'm not fluent in english lol
[] brackets () parenthesis {} curly braces/brackets
corrected me
You should def use googles BiMap for stuff like this
private String getKey(Inventory inventory) {
Map<String, Inventory> map = manager.getInventoryMap();
if (!map.containsValue(inventory)) return null;
for (String key : map.keySet()) {
if (map.get(key).equals(inventory)) return key;
}
return null;
}
?
Assuming that values are unique
Directional mdir = ((Directional) mdata);
```and now?
wait
my control + v isnt working
lol
can't you use if key contains inventory directly there
You cant pass methods to other methods. The question doesnt really make sense.
Wait I just realized you can do new EnderChest(BlockFacing)
mdir.setFacingDirection(BlockUtils.yawToFace(this.location.getYaw(), false));
What i do with this now
I'm trying to make a command handler but i'm struggling on registering the command
Im using .setType to set the block.
Its also really bad practice to pass data structures like maps between classes. That should be avoided at all costs.
what do i do
wait i think i found a solution
Yeah so use new EnderChest(BlockData) instead of casting directional or new Material. When you've done that call getData on the EnderChest and use that byte in the setType method
You should have methods inside the class that contains the data structure to modify it.
Like
giveInventoryOfKey(String)
or
clearKeys(), sortValues() etc.
Just never pass the data structure to other classes
ok
is there a way to make momentum last for longer? like less drag?
vector math
The physics are hard coded. So you would have to do some hacky stuff to keep an entity moving.
And how can i get a blockdata from a materialdata ' -'
ok, ty
Use EnderChest not MaterialData
Then...
Why i made a materialdata...
Because I found the EnderChest interface
You know I haven't done this before either
I'm literraly just looking around in Javadocs
What would be the best way to store wins and losses and points (such as coins and gems and such). Would it be better to use static or use a class with constructor to make a manager? {
2 or 3 more years and 1.8 is a decade old. Nobody wants to use ancient software. Thats why getting help for it will get harder and harder as time passes.
Generally:
Singleton Manager > static data
thank you
I give up at this point lol
My plugin keeps saying item is null in this
size: 54
itemshop:
categories:
blocks:
slot: 10
item: "WHITE_WOOL"
name: "&7&lBlocks"
lore: "Blocks for building"
String mat = file.getString("itemshop." + category + ".item");
ItemStack item = new ItemStack(Material.getMaterial(mat));
That's in a for loop going through the categories
lol
blocks is the category
What
uh
That doesn’t make sense
If blocks is the category, you dont need to put "itemshop.categories." + category?
blocks is a category
What
Your code is doing itemshop.blocks.item
Excuse me while I die
It keeps returning null? XD
No
Just that I did dum
Ah yes
You close Minecraft and it keeps starting anyway
very nice, Forge
Minecraf is a game made in a 4x4 house ' -'
Watch it crash when I try to open the GUI
Maybe you need to use a material formatter, not?
Lol, my server is returning Timed Out ,_<
No, I wasn't doing click events yet
LOL, my Yaw to BlockFace converter is getting the opossite face
Why i need +1 restart, god? ,_<
EnderChest ec = new EnderChest(BlockUtils.yawToFace(this.location.getYaw(), false).getOppositeFace());
this.block.setType(Material.ENDER_CHEST);
this.block.setData(ec.getData());
```Its finally workinggggg.
heard my name?
How would I have to translate color codes in a string list?
loop over
Iterate over the list and translate each String
;-
hey, anyone knows how to disable spectator menu when someone is on spectator mode ?
don't seem to find it on google
I think thats just client side
But never investigated it
but on server siude, is there a way to cancel teleport
probably
That for sure
so it'd be
on player teleport
if player is on spectator
event.cancel ?
alrighty i'll try it, thanks
Theres a way with Teams.
umm the problem is thaat while on spectator, i teleport the player, so it's gonna cancel the teleport event, anyway for my teleport event to bypass the restriction on PlayerTPEvent ?
Sure. Use a Set<UUID>
player's UUID? or what do you mean
Example:
private final Set<UUID> bypassedPlayers = new HashSet<>();
@EventHandler
public void onTeleport(final PlayerTeleportEvent event) {
final Player player = event.getPlayer();
if (player.getGameMode() == GameMode.SPECTATOR && !this.bypassedPlayers.remove(player.getUniqueId())) {
event.setCancelled(true);
}
}
public void tpWithBypass(final Player player, final Location tpLocation) {
this.bypassedPlayers.add(player.getUniqueId());
player.teleport(tpLocation);
}
To make it more clear:
@EventHandler
public void onTeleport(final PlayerTeleportEvent event) {
final Player player = event.getPlayer();
final boolean isSpectator = player.getGameMode() == GameMode.SPECTATOR;
final boolean isBypassed = this.bypassedPlayers.remove(player.getUniqueId());
if (isSpectator && !isBypassed) {
event.setCancelled(true);
}
}
alrighty, so the second code works ?
Everything there should work
The second code is the same as the first. Just written more verbose.
Is there a benefit to writing final before everything
A entity's unique id (or UUID) is an id they're attributed
Every entity has a UUID
And, as its name states, it's unique
Yes. It makes it clear that the variable should not be redeclared. Also every variable is automatically qualified for usage in anonymous classes and lambdas.
Hm, I guess. Aren't they still qualified if they're effectively final anyways?
So it makes the intent of the code much more clear. Depending on your code, it serves as a hint for the compiler to potenitally enable optimizations.
It also makes them thread safe by default.
Hm interesting, thanks
I just configured my IDE to fill those things in for me and it helped me write cleaner code for a while.
I usually know when my variables shouldn't be redefined, but I do understand the use if you're working in a team environment
How can I check if an item can be damaged
Check if the ItemMeta is instanceof Damageable
ah ty
You can also see if Material#getMaxDurability() yields the results you want.
im rly bored anyone has an idea of a plugin
asking again, does anyone know if loading worlds is possible on load instead of on enable?
A plugin to import simulations and animations from blender so you can have giant moving creatures that are made out of blocks
Um why
I would suspect that its not. onLoad happens really early in the application.
But then i also dont see a reason to do that.
I want to guarantee that world loading happens before I try to load things in them and in general world loading comes with a shitload of logging data which is largely irrelevant for 99.99% of people but makes it hard to see anything else, especially if you're loading a lot of them
I can just shift stuff around but ideally I'd shuffle it way, way before the core loading part of things
Just block console output while your worlds are loading ^^
I might have to, it's getting on my nerves
is there an event for an explosion caused by calling world.createExplosion?
BlockExplodeEvent
really? Thought thats if a block itself explodes
I've never really dealt with console message suppression, what's the starting point for that?
Which is what happens if you call World#createExplosion()
duckduckgo
nah as in, if the block causes an explosion
but I'll give it a go ty
ok so just java then, nothing spigot-side?
Just pipe System.out into dev/null or something idk
Do it like me use ddg as default engine but always type google in the searchbar 🧠
iirc firefox had a system to quickly search in a specific location but I had to stop using it because the websites I have to use for work don't support it
Probably something in this direction:
System.setOut(new PrintStream(...));
Let me try just setting it to null XD
btw why is the yield inverted in the explosion events
What do you mean by that?
Im this far:
@Override
public void onEnable() {
System.out.println("Test");
this.getLogger().info("LoggerTest");
this.disableSTDOut();
System.out.println("Post_Test");
this.getLogger().info("Post_LoggerTest");
}
public void disableSTDOut() {
System.setOut(new PrintStream(new ByteArrayOutputStream()));
this.getLogger().setLevel(Level.OFF);
}
Console:
[23:34:07 INFO]: Time elapsed: 1177 ms
[23:34:07 INFO]: [SpigotSandbox] Enabling SpigotSandbox v${project.version}
[23:34:07 INFO]: Test
[23:34:07 INFO]: [SpigotSandbox] LoggerTest
[23:34:08 INFO]: Running delayed init tasks
[23:34:08 INFO]: Done (4.158s)! For help, type "help"
[23:34:08 INFO]: Timings Reset
So it suppresses some stuff but not the server logging.
world loading is logged by servers right?
yield is inversely proportional to explosion power. i.e. TNT has a yield of 0.25, and a creeper has a yield of 0.33
or whatever (1/creeper power) is
yield isn't inversely proportional, the bigger the yield the bigger the explosion
I've actively used setting yields and I can guarantee that bigger numbers go bigger boom
you can create an explosion yourself
explosion yield
when creating an explosion or when receiving the event
I've mostly messed with creating them
then that's different
that's power
but yield = 1/power for whatever reason
they use yield in the events
why do you think it's inverted
since logging it shows that it is inverted
if you didn't know how to set the yield in the first place how do you know the one you're getting isn't accurate?
I use tnt which has a known yield of 4
can someone explain to me as to why when I start a plugin java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils appears even though I included it as a dependency when I compiled the plugin???
I'll test again comparing tnt's reported yield (0.25) vs a custom explosion with power 2.5
no, it has a known power of 4
power isn't yield
they call it yield as you said
then it has a known power of 4
Did you not shade it in?
And also bukkit I think has that dependency and you need to relocate it
To some different name
shade it in? I haven't heard of that before
oh
It’s when you include the classes in the library into your jar file
So your classes can use them directly
ooooh
how do you do that?
Maven or gradle?
maven
checked with a fireball. If you summon one with explosion power 10, reported yield is 0.1
U need the compiler plugin
if the power is 2, the yield is 0.5
Then you need to setup as so, and set your dependency to compile
sounds consistent to me if I assume that you are doing the power wrong and it's just getting default yields
thanks
and no javadocs in the jar doesnt help lol
so how do we get the power of an explosion?
no it isn't
they must then be doing it differently on different events
both of these seem to be the same though
you are looking at the creation side
well if they changed it after 1.0 it's recent to me
so it's impossible to get the power of an explosion from the event...
alright cool it works now thank you so much!
Np
How to spawn an Item with ProtocolLib-API for one player ?
I know I need these two:
But im not really able to understand and spawn a item!
Im trying to spawn a item with this lines of code:
EntityItem entity = new EntityItem(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY()+2, loc.getZ(), CraftItemStack.asNMSCopy(i));
PacketContainer item = protocolManager.createPacket(PacketType.Play.Server.SPAWN_ENTITY);
// PacketContainer itemData = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
item.getIntegers().write(0, entity.getId())
.write(6, 2);
item.getUUIDs().write(0, entity.getUniqueID());
item.getDoubles()
.write(0, loc.getX())
.write(1, loc.getY()+2)
.write(2, loc.getZ());```
But instead of an default stone item, it just spawn this https://i.imgur.com/vCe6vb7.png
Before I'm trying to use `ENTITY_METADATA`, I want to `SPAWN_ENTITY` get working xd
Im very very very new to protocolLib's API, but I dont have any idea how to work with it o.O
EntityShulker shulker = new EntityShulker(EntityTypes.ay, ((CraftWorld) loc.getWorld()).getHandle());
shulker.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
shulker.setFlag(6, true); //Glow
shulker.setFlag(5, true); //Invisibility
What is the new flag for Glow and Invisibility? I cant find it
Dude I already mentioned it xd But how to use it right with ProtocolLib ?
So I only need Entity ID, Object UUID, Type, X, Y, Z ? How to set them right ? What did I wrong
hey, i'm having trouble with this code :
public void onDeath(PlayerDeathEvent event) {
event.setDeathMessage(null);
Player player = event.getEntity();
if(player.getKiller() != null){
Player killer = player.getKiller();
if(killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//If the killer has and helmet AND the player doesn't have a helmet : say "player has been killed by unknown"
Bukkit.broadcastMessage(player.getName() + " s'est fait tuer par un inconnu");
}
if(killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//If the killer has an helmet AND the player has an helmet : SEND NOTHING
return;
}
if(player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//if the player has an helmet AND the killer doesn't have a helmet : say "unknown has been killed by killer"
Bukkit.broadcastMessage("un inconnu s'est fait tuer par " + killer.getName());
}
if(!player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//if the player doesnt have an helmet AND the killer doesnt have a helmet : say "player has been killed by killer"
Bukkit.broadcastMessage(player.getName() + " s'est fait tuer par " + killer.getName());
}
}else{
//killer is null
}
}```
in the chat it returns me nothing, like nothing AT ALL
Did you register your Listener ?
I did
I would recommend to just put overall a System.out.println to test your code is even working.
Place one right at the beginning, like over your event.setDeathMessage(null);
And check if the killer is an instance of Player
How do I check if a player stopped moving? (My ideia is: If a player stopped moving, they die :D, so they need to constantly move :)
i'm adding one to each condition statement
How much does this have to scale?
PlayerMoveEvent ?
Async Task / Threads / I would not recommend PlayerMoveEvent
like 1 second
Then just a Thread or Task
Check Pos
Check 2x pos and their distance and so on .. xd
You need to ask yourself 3 questions.
How much does my code have to scale
Is there a min delta space step that counts as not moving
Is there a min delta time step that counts as stopping
With scale i mean: How many people do you expect to support?
Then i would actually just go with the PlayerMoveEvent
ok thx :v
cant I just do:
if (plyaer.getWalkSpeed() == 0) {
// do stuffs
}
somehow?
you're looking for velocity
although iirc it's never 0?
since it's acceleration and there's always a negative y vector
something like that
fuck my life...
ok
so I think I would need to learn how to use the "RunTaskLater"
I searched a little bit
probably not a bad idea
the concept is:
- Create a HashMap (with the last player location)
- Every second (with the RunTaskLater, I think) it would update the HashMap
- If it updates with the same location, then it means that he stopped moving, and then he dies :D
again, sorry if my english sucks 😔
Just a quick mock up:
private static final long MIN_DELTA_TIME_MS = 1000;
private static final double MIN_DELTA_SPACE_SQ = 0.01 * 0.01;
private final Map<UUID, Long> trackedTimes = new HashMap<>();
@EventHandler
public void onMove(final PlayerMoveEvent event) {
final UUID playerID = event.getPlayer().getUniqueId();
final Location from = event.getFrom();
final Location to = event.getTo();
final double distanceSquared = from.distanceSquared(to);
if (distanceSquared > MIN_DELTA_SPACE_SQ) {
this.trackedTimes.put(playerID, System.currentTimeMillis());
} else {
final long timeStanding = System.currentTimeMillis() - this.trackedTimes.getOrDefault(playerID, System.currentTimeMillis());
if (timeStanding > MIN_DELTA_TIME_MS) {
// Player stopped moving here
}
}
}
did you test it?
Nope
np
And there is one big flaw i just realised. If they just stand still for a while nothing happens. Just if they move their mouse ever so slightly the time will get detected.
okay, i retested this code
public void onDeath(PlayerDeathEvent event) {
System.out.println("Begin");
event.setDeathMessage(null);
Player player = event.getEntity();
Player killer = player.getKiller();
if(player.getKiller() != null){
if(killer instanceof Player) {
if(player != null && killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//If the killer has and helmet AND the player doesn't have a helmet : say "player has been killed by unknown"
System.out.println("killer has helmet AND plyer no helmet");
Bukkit.broadcastMessage(player.getName() + " s'est fait tuer par un inconnu");
}
if(player != null && killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//If the killer has an helmet AND the player has an helmet : SEND NOTHING
System.out.println("both helmeted");
return;
}
if(player != null && player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//if the player has an helmet AND the killer doesn't have a helmet : say "unknown has been killed by killer"
System.out.println("player has helmet AND killer doesnt have helmet");
Bukkit.broadcastMessage("un inconnu s'est fait tuer par " + killer.getName());
}
if(player != null && !player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
//if the player doesnt have an helmet AND the killer doesnt have a helmet : say "player has been killed by killer"
System.out.println("both no helmet");
Bukkit.broadcastMessage(player.getName() + " s'est fait tuer par " + killer.getName());
}
}}else{
}
}```
and all conditions doesnt work, checked it with sysouts, only the first sysout works which tells "Begin"
any ideas ?
honestly, sorry for bothering much, but i really cant find the answer i tried everything i could
conditions just arent firing
kinda clustered with comments so slightly hard to tell
i'll delete
You should def group the conditions and early escape
write self expressing code btw 😄
okay, i retested this code
public void onDeath(PlayerDeathEvent event) {
System.out.println("Begin");
event.setDeathMessage(null);
Player player = event.getEntity();
Player killer = player.getKiller();
if(player.getKiller() != null){
if(killer instanceof Player) {
if(player != null && killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
System.out.println("killer has helmet AND plyer no helmet");
Bukkit.broadcastMessage(player.getName() + " s'est fait tuer par un inconnu");
}
if(player != null && killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
System.out.println("both helmeted");
return;
}
if(player != null && player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
System.out.println("player has helmet AND killer doesnt have helmet");
Bukkit.broadcastMessage("un inconnu s'est fait tuer par " + killer.getName());
}
if(player != null && !player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET)) {
System.out.println("both no helmet");
Bukkit.broadcastMessage(player.getName() + " s'est fait tuer par " + killer.getName());
}
}}else{
//killer is null
}
}```
here
Example:
Player killer = player.getKiller();
if(killer == null) {
return;
}
i'll just replace return with a sysout
just a question, when "return;" appears, like you did, it means that it doesn´t return nothing, right?
sorry if it is a dumb question, but whatever
You are right. This happens in method which have the return type void
alright killer isnt null
"it doesnt return anything" but im not a native speaker
because no sysout
but it tells me on console "exception : null on line 49" which is
if(player != null && killer.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET) && !player.getInventory().getHelmet().getType().equals(Material.LEATHER_HELMET))
my first condition
thx 🙂
my english never was the best
@EventHandler
public void onDeath(final PlayerDeathEvent event) {
final Player player = event.getEntity();
final Player killer = player.getKiller();
if (killer == null) {
return;
}
final ItemStack playerHelmet = player.getEquipment().getHelmet();
final ItemStack killerHelmet = killer.getEquipment().getHelmet();
final Material playerHelmetType = playerHelmet == null ? null : playerHelmet.getType();
final Material killerHelmetType = killerHelmet == null ? null : killerHelmet.getType();
final boolean playerHasLeatherHelmet = playerHelmetType == Material.LEATHER_HELMET;
final boolean killerHasLeatherHelmet = killerHelmetType == Material.LEATHER_HELMET;
if (playerHasLeatherHelmet) {
if (killerHasLeatherHelmet) {
System.out.println("Both have a leather helmet.");
} else {
System.out.println("Only the player has a leather helmet.");
}
} else {
if (killerHasLeatherHelmet) {
System.out.println("Only the killer has a leather helmet.");
} else {
System.out.println("Nobody has a leather helmet.");
}
}
}
This code doesnt need comments because the variable names are expressive and tell you exactly what you are trying to do.
i'm not rlly good at this, prefer doing just code then comment
Youll get there if you keep coding
i hope so, i started learning java 4d go
ago
all day just clicking & clicking my keyboard
Anybody use Hibernate in their plugins? I'm getting a problem when closing the SessionFactory in onDisable() Caused by: java.lang.ClassNotFoundException: org.h2.mvstore.MVMap$2 even though I can definitely see the anonymous classes shaded in the jar
Thought about it. Really didnt like my first experiences with it. Then scratched it.
You can block the main thread really fast if you are not careful
I use it in work with Spring Boot which is really nice, so thought I'd give it a go standalone
Do you fully understand how the lifecycles work and when hibernate is actually accessing a database? Because you really dont want that to happen on the main thread.
Also JAP entities are quite primitive. Serializing more complex data with hibernate is a bit of a hustle.
Especially if they are life Objects
I hadn't thought about the main thread issue tbf
Because even serializing an ItemStack with hibernate could result in half the server being serialized recursively
You can play around and give me an update if you found a nice way of decoupling the JPA Entity from the main thread. Maybe with a proxy class?
I'm currently serializing everything into a YAML file so it can't be much worse. And yeah I was planning on storing most of the Bukkit ConfigurationSerializable's as JSON anyway
Ah ok
Not sure I get what you mean by decoupling the entity from the main thread though? Do you mean the Queries to get/update entities?
Oh you probably dont want full autonomous persistence. So you just want to serialize/deserialize the entities in a DB and then schedule the queries yourself?
Yep that's what I'm doing, currently I'm storing everything in HashMaps and Lists in memory etc. And then that all gets serialized into a YAML file when the world file is saved. It's grew fairly fast and so it's not practical doing it all in memory anymore.
Holy moly. Too big for memory? You need to have a TON of data then. I lately was on a server project that just kept the data of the latest 5000 users in memory. Didnt even occupy 2 gigs of ram.
I just throw everything into gson and register custom serilizers for the more complex types. 😄
Especially when it's all relational data, and doing all that object orientated is getting annoying.
I.e storing a HashMap with player ID's and everything related to them. Then a hashmap of Locations and everything related to players at that location.
I'm planning on utilizing Geospatial queries for the Locations which will help a lot
Oh i see. I normally have a more centralised data approach.
Map<UUID, PlayerData>
And PlayerData contains all the data i need.
Then throw everything into Gson -> MongoDB and hide it behind a AsyncLoadingCache for access to offline data.
I basically have HashMap<String, HashMap<String, ChestLinkStorage>> which is UUID -> StorageName -> Object
Nested HashMaps -> make a new class that contains the nested map
^^
But do you really want Hibernate then?
Because custom serialization with hibernate is a bit tedious.
All I need to store is player UUID's, String and ItemStack's tbh
There's just a lot of relationships between them all
Which is why I think a relational model will work much better
I.e get all Storages that Player X is a member of. Or that Player Y is the Owner of. Will be much easier
Sure. I was just thinking that you could use something like Querydsl and build the queries yourself instead of using hibernate for that.
But if you are confident with custom mappings then go for hibernate
I thought I need to use those on top of Hibernate?
Hibernate will automatically update database schemas for me too on upgrades
No. With hibernate you just do something like
hibernate.persist(object) and you are done. You dont see a single query there.
@eternal oxide and 7smile7 I was talking to the devs that made NBT api and they said that it's not possible to do what im trying to do
Hibernate is there to abstract the queries away from you
F
No. It just scales worse.
I mean... Databeses have build in memory caches. So that why for repeated access they are in fact faster
But you can do the same with flat files.
Yeah, I've just been messing around with this class to achieve most of what I want https://paste.md-5.net/atejezoyer.java
I guess ima have to deal with that delay I have
I think my query bad though
it takes longer than 10ms
10ms sounds good for an SQL query to me...
Def. And you shouldnt worry even if its 100ms. Just dont do any IO on the main thread.
Do you have an N+1 problem by any chance?
Looks nice. Now you just need to register some custom mappings and you are good to go.
I.e are you firing off a shit load of queries one after the other?
no
So why is 10ms slow?
I never said it was slow
Bumpy
Oh right, I thought you meant that SQL was your bottleneck
Wait isn't there a way to check if its running on your main thread
What version are you on?
v1_17_R1
Bukkit.isPrimaryThread() iirc
SQL? Off thread wherever possible. This is where CompletableFutures come in handy
I see you are using NMS. What do you need Protocollib for then?
No Bukkit.isPrimaryThread()
What is CompletableFutures though?
ugh
why is the server crashing
As we told you yesterday. Really edge case method you will probably never use.
You first need to understand how to properly spawn a new thread, do something on it, and
sync back with the main thread when you are done.
If they are on another thread then no. BukkitScheduler is thread safe tho.
I don't wan't to use NMS. I wan't to use ProtocolLib for this, but I really don't know how.
I took this example on the bottom https://github.com/dmulloy2/ProtocolLib/#sending-packets
So thats the way to send packets right.
But somehow it wont really work, as you see on my previous message xd
Do you close the Connection first or PreparedStatement I forgot
latter probably
I could probably extend CompleteableFuture and just make it call directly through BukkitScheduler then?
why
You are already using NMS
just wrap the bukkit scheduler into an executor and the pass that to the future?
if Bukkit.isPrimaryThread() returns true that means its running on main thread correct
ye
Do you want to substitute what you have so far?
Because doing this purely with ProtocolLib will require you to do some nasty DataWatcher assembly.
If you mean EntityItem and CraftItemStack then yes.
But I want to do it with only ProtocolLib, I want to learn it.
It's late, you got an example of this? 😄
well what exactly do you want?
This defeats the purpose of the CF.
What are you guys doing?
CF? I was just going to look at wrapping my queries to return Future's so that the queries can be run on a separate thread?
Oh completableFuture
Actually, I just want to know what I did wrong with my code, that somehow a particle appears instead of an item.
It can't be that difficult to somehow read that from https://wiki.vg/ and then use it?
James then just use CompletableFuture#runAsync(command) and supplyAsync(supplier)
Or no?
Might wanna pass a custom executor actually
I suppose I want it to run on a separate thread and then I want the stuff in the future to be able to be run on the Bukkit thread
Sure
Here is an example how you would load some data async and then apply an action to the data on the main thread.
public CompletableFuture<PlayerData> applyToPlayerData(final UUID playerID, final Consumer<PlayerData> playerDataConsumer) {
return CompletableFuture.supplyAsync(() -> {
final File playerFile = getPlayerFile(playerID);
final PlayerData playerData = readAndLoadPlayerData(playerFile);
return playerData;
}).thenAccept(playerData -> {
Bukkit.getScheduler().runTask(SomePlugin.getInstance(), () -> playerDataConsumer.accept(playerData));
});
}
Aww smile is fast as usually
haha now its not running on the main thread
Okay cool, I suppose I can write a utility method that would return a Consumer directly from that method to be consumed in the BukkitScheduler
Ok thats how far im currently. This should be the proper way to prepare an Item packet. The metadata will be more complex tho.
public void spawnItemWithProtocolLib(final ItemStack itemStack, final Location location) {
final ThreadLocalRandom random = ThreadLocalRandom.current();
final ProtocolManager manager = ProtocolLibrary.getProtocolManager();
final PacketContainer itemPacket = manager.createPacket(Server.SPAWN_ENTITY);
final PacketContainer metaPacket = manager.createPacket(Server.ENTITY_METADATA);
final int entityID = random.nextInt();
final int entityType = 41;
final int extraData = 1;
final StructureModifier<Integer> itemInts = itemPacket.getIntegers();
itemInts.write(0, entityID);
itemInts.write(1, entityType);
itemInts.write(2, extraData);
final StructureModifier<UUID> itemIDs = itemPacket.getUUIDs();
itemIDs.write(0, UUID.randomUUID());
final StructureModifier<Double> itemDoubles = itemPacket.getDoubles();
itemDoubles.write(0, location.getX());
itemDoubles.write(1, location.getY());
itemDoubles.write(2, location.getZ());
}
Hey guys, how would I check if a player is looking at a location
Like, getting the direction, and by the direction he can see the location
A Location is a very very tiny point. A player will almost never be looking at exactly one discrete location.
You can however easily find out what block the player is looking at by just using the ray trace method of Player
Yup, but I need to have this ray being able to tell me if it actually passes inside a "region"
Basically, like the hitboxes works
Wow! Thank you very much!
But where did you get the values entityType = 41; and extraData = 1; ?
From Spigot itself or by wiki.vg ?
Ah and by just using your snipped, it looks like this https://i.imgur.com/OUxtB9Z.png
(I looped this functions many times)
Just go look at the client and gg you learned it
Looking at the client ? I've never done this before
Yea you can get the client source and it has an implemented server
Ah okay
Is this the right place to ask about plugin development? I’m looking to port my fabric mod.
This is the channel for it, yes
From wiki.vg
41 is the entity id of Item
How close are the APIs in terms of functionality?
Aha! From here so https://wiki.vg/Entity_metadata
But i have literally no idea why you see just a bunch of particles
Did you see an Item with your instance ?
If it helps idk
Now you will have to do something like this:
final StructureModifier<Integer> metaInts = metaPacket.getIntegers();
metaInts.write(0, entityID);
final WrappedDataWatcher watchableObjects = new WrappedDataWatcher();
// Do some weird stuff here idk
final StructureModifier<WrappedDataWatcher> metaDataWatcher = metaPacket.getDataWatcherModifier();
metaDataWatcher.write(0, watchableObjects);
And fill the WrappedDataWatcher with stuff. But im not 100% sure. Maybe Plib has some separate wrapper for Items
Is hot registering and unregistering commands possible?
Yes
In Fabric you have direct access to brigadier
But you usually dont want to do that
You can also gain direct access to brigadier in spigot. Just not with the API.
Is there a spigot equivalent to mixin? My mod cancels methods.
What do you mean by "cancels methods"?
Spigot has a command framework.
If you want to do bytecode injection then you need to shade that in yourself.
In fabric I can inject into a Minecraft method and then return from that
Yeah
Wdym shade it in?
Use your dependency manager (maven or gradle) and provide an injection library like ASM with your plugin.
So shade the library into your plugin.
How bad of performance can you lose from getting a value from your sql db if it's on the main thread?
To the point where your server just crashes
Is there a reason why my server isn't crashing?
You didnt encounter any problems with your DB so far and you probably dont stress test the DB to simulate what would happen with multiple users online.
right
So when your connecting to the db do you still not want to be on the main thread?
If you DB (or your hard drive) is busy then the main thread will just wait (worst case) several seconds for a response.
In this time nothing on the server will function. Every user will stand still, every entity will stand still, nothing falls moves or flows. The server is just dead for that time.
worst case scenario using default values you could be waiting 30 seconds for a connection timeout
by that time all your players have been disconnected
hm ok
A connection can fail and take some time to recover
Is there different threads to let me return a long?
If you start a new thread then you wont get anything from the thread right away. You just tell the thread to do something and then move on.
right
but
wait do I just need to put the connection in a new thread?
Sorry I'm just trying to understand this
It’s just locking, so your main thread gets frozen until it’s no longer locked
Multithreading is a pretty complex topic. Ill draw you a quick diagram that shows how the threadflow in spigot works
ok
Look just run your stuff with a bukkit runnable async.
You’re better off with that for now
But then I gotta redo everything
Ok so Minecraft is a tick based game.
Every 50ms a new tick begins.
First Minecrafts core mechanics will be applied. All mobs will be ticked. Packets will be prepared and read. Chunks will be loaded etc. This consumes the first 10, 20, 30 ms
Then there is some Spigot stuff happening. Event handling. Runnables will be executed etc. This lasts another lets say 5ms.
Now you have maybe 25ms to waste with your plugins code. If you start a query that lasts longer than 25ms then the next tick has to be delayed. This results in fewer ticks per second being scheduled.
(1000ms / 50ms = 20(ticks) but if a tick lasts 60ms on avg then 1000ms / 60ms = 16,66(ticks))
@proud basin
But i most cases you dont need to do complicated stuff like this.
You can always listen for the AsyncPlayerPreLoginEvent which is async on default and just load all the player specific data there into memory.
Then just work with the data in memory.
Then listen for the PlayerQuitEvent and save the player specific data back into your DB using the BukkitScheduler.runTaskAsync(...)
fancy diagrams

hello, it is I, magmaguy, master of java programming here to teach the people who make java how to make java better
lads, you have instanceof, give me notinstanceof
every time I do (!(a instanceof b)) a fragment of my soul exits through my ass
But i get you. Ive always wanted something like that because the brackets are tedious
Same. But that would violate the syntax
yes but not having it violates my soul
XD
anyway thanks for coming to my tedx talk, you can purchase my book "how java ruined my soul" on your way out for $45
Is it signed?
you can pay an additional $20 for the signature
deal.
sure just paypal me the $65 and I'll send you a copy
you know what I've not checked at all but I bet c# has a way to deal with this that is entirely seamless
Just write an email to the oracle HQ notinstanceof when?
I don't actually think it does, Magma
iirc it too uses !(value instanceof whatever)
java is like the lame stepfather who hits you with a belt when you try to put on your hat backwards and c# is the cool dad who picks up your friend in a convertible while blasting russian hardbass
Oh it's is in C#. Sorry. Haven't done much C# in a while
so I I'm trying to do it the complicated way?
if(C is not typeOf(D)) {
}
But yeah, same issue
oh fuck off, they just added is not in 9.0 lol
https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/#logical-patterns
how do u get the paper api?
I mean sure he'll be in a car wreck one of these days but it will be a cool car wreck and he probably will have a dashcam
Ask on the paper discord
Well you're definitely in the wrong server, burger lol
oh crap ya lol
C# is lit and once I start using it for unity I will probably never really come back to java
I actually have no idea what you are currently doing. I was just rumbling about threads...
Eh you probably will. Microsoft Javas popularity is declining. Also Minecraft...
No no. I just dont know what you are actually doing XD
Where dog? 
I'm not beholden to following the trends
for the foreseeable future I have the liberty of choosing which programming language I want to use
Definitely overcomplicating that because Bukkit's scheduler will suffice for that
You will come by all of them. At least C++, Python and JavaScript
Python 🤮
I don't really see why I'd ever bother with python
Bukkit.getScheduler().runTaskAsync(plugin, () -> {
// Do your SQL stuff in here. No need for the Thread creation
});```
unless it really changes in the future
ah ok so I did it completely wrong
In some industries getting stuff done quickly with scripts is more important than maintainability
Not completely wrong. What you wrote works fine, just no reason to start the thread yourself when Bukkit supplies you with a thread pool
well if things go right I won't need to worry about that
Not completely wrong. Just overcomplicated.
Few words go slow
ah
Unless there is a library in the background that uses C for the hard lifting. But yes. (pure) Python is really slow.
for some reason every time I see a python program is seems to be made to just process some math and maybe make some graphics
just lots of number crunching
You should probably follow the routine ive described earlier.
- Load the Data from a DB in the AsyncPlayerPreLoginEvent
- Use the data in memory (so a Map for example)
- Save the data back when the player quits (PlayerQuitEvent) then you can just use an async task from bukkit
So you dont have to constantly tinker with multithreading or async tasks.
hm
but why would I load the data whenever someone joins?
Because you only need a players cooldown when he is actually online, right?
What if the command /reload was used?
Then you tell the person that used the command that it is not supported by anyone and he should not use it.
But it's such a useful command
But you can just iterate over all online users on onEnable() and onDisable() to load/unload the data on reaload.
I guess
No its an evil command that nobody should use. Even spigot discourages the usage of this command.
Then why did they add it?
They didnt
mojang did
I think its a bukkit command
Can I cancel chat from going through to other players in a spigot plugin?
Anyways. You can support reloads by saving all online player data onDisable() and load all online player data onEnable()
Yes. You can change the recipients of a Message by simply listening for the chat event.
alright
Time to achieve this
But if you want to cancel messages from other plugins then you would need to listen for the outgoing chat packets.
Which is done using a library called ProtocolLib
Cool beans, another question, can I run commands from a plugin or run Minecraft methods?
It injects a packet handler into the netty pipeline
bukkit.dispatchcommand(CommandSender, String)
Thx
Would I use this in the asyncPlayerPreLogin
u cant run client methods from mc but u can run nms methods from the net.minecraft.server package
You can force a CommandSender (including the console) to dispatch a command.
in order to do that u have to use buildtools and compile spigot
Can I capture server console log output?
Uhm. Sure. Its just a simple PrintStream
This is my fabric mod by the way if you’re wondering why I’m asking about this random stuff https://GitHub.com/CamelBot/CamelMod
7smile7
Discord bridging plugin for block game https://www.spigotmc.org/resources/discordsrv.18494/ - DiscordSRV/ConsoleAppender.java at master · DiscordSRV/DiscordSRV
jtx
bump to you
or that
Ah. Yes. Thats the right event. You dont need to do anything special here other than loading the data.
ok so I don't need the scheduler
Nope. Just load the data right there. The event is already async. So stuff you call in this event wont be on the main thread.
ok
Does someone know what's the math to calculate if a vector does intersect a plane ?
Sure. But why do you need that? In most cases you dont need something so low level in spigot.
Alright the asyncpalyerprelogin is event is done
Cause I'm trying to dev a custom hitbox system that need to know if the player is actually looking at the hitbox
Hello I need help with Bungee
Step 1 is completed
Use the build in BoundingBox class from spigot for that.
Yeah, but that's a box
say you have class A then class B extends class A then class C extends class B , and they all have a #remove() method which gets more complex as you go down, is the correct solution to override and then have a non-overwritten helper method that contains the logic for the #remove method so you don't just copy paste code from class to extended class?
And you want an octahedron?
it feels sort of dumb
Any kind of shape
Would I want to load all of their data including uuid, time and cooldown
I need help with bungee!
Ok then be prepared for some ridiculous amount of math. Calculating the intersection of a vector and an arbitrary shape is complex.
Yes. All the data that is related to this player.
I was thinking of getting all the shape's planes (from the shape's coordinates) and then calculate if the vector does intersect one of the planes
Which would result in the player looking at the shape (I guess)
ideas for my polymorphistic nightmare?
This means your method linearly scales with the amount of planes in the shape. Which is bad.
eXpLaIn https://dontasktoask.com/
Is it recommended to always close the connection?
Would be O(n) yeah
I have this command panel, When I do ./server [name] it works but not in the panel
name "Command Pannel"
State of the art vector intersection is done using ray marching.
command panel?
yes the plugin
ray tracing but implemented by the army?
Is that a bungeecord plugin?
^

An introduction to raymarching in C++ with diffuse Phong shading and ASCII-terminal output.
no
No. You overwrite like this:
@Override
public void remove() {
super.remove();
// Do your new stuff here
}
This calls remove from the super class before it runs other code
man I even did that in other parts of my plugin, I need to go get some more coffee
thanks
man I am doing some stupid shit today
So i have to install it in my bungee for it to work aswell? @silk mirage
Ok so you want to support intersection of non cubic shapes in a voxel based game. Why?
are u using bungeecord message system OR what r u doing
Because, people do make custom models, and those are not always cubic
A fixed set of shapes? Or even custom shapes imported from something like blender
Imagine having a dragon, with a proper hitbox that is shaped as the dragon
Can be done with a bunch of cubes
Has anyone had problems with the maven shade plugin not working on Java 16?
Cant seem to get mine to shade anything in with an unsupported class ver of 60 error
add <target>
wait
it was like
Not so far. I dont think the java version should affect your maven dm.
Well, it would still be a custom shape since it requires multiple cubes
compiler target
I have maven.compiler.target in the properties set to 16
Also set the source to 16 and see if that helps
it shall be bcz shaded library were built with java version less than 16
That should be no problem
Is it a compile time error?
It's when I run mvn clean install
Ah. Then make sure maven properly recognises your installed java version.
oh that's interesting, so it's like raytracing's roundboi friend
Are you developing a plugin?
mvn --version is showing it just fine, I just reran it now and removing one of my configs under the shading system seems to fix that problem but another one has popped up that i'm looking into now
Then this is the wrong channel
Named command panel
so is non-spherical raymarching faster than ray tracing in general and then sphere tracing would only be faster in very specific contexts?
sphere tracing sounds like a technique someone would've used back in the ps2 era in order to squeeze more juice out of the hardware but still have a form of tracing
I know this thing has been fixed for ages: https://bugs.mojang.com/browse/MC-106202 but was the fix only on the chest block glitching out?
if so do you think it would still be possible to open a chest with a 3 chest layout?
You can do it via code for sure
This was the problem, one of my dependencies in another package were out of date
I had an idea of how this could be utilized but yeah idk if you really can open the gui with a triple layout, I have not looked into it at all so I really don't know anything about it
Huh? Java versions are backwards compatible.
you know what I'm going to implement sphere tracing on my plugin just for the hell of it
It was a lombok err due to compiler changes
I just remembered this old bug and got an idea out of it so it would be cool to get it working
you should probably be asking that on the worldedit discord
I am sure I would have to send packets myself for this though right? everything that is exposed in the api probably if not definitely doesn't allow it
then you have your answer
sure it's possible
anything is possible if you have an infinite amount of time
there's probably a way to do it using reflections
Hm... just realised that they patched the possibility of just using a normal inventory out.
that's sad, which version was that patched in?
It means that you basically scan the actual class file instead of getting the information from the runtime.
So you can change stuff you are normally not supposed to even see.
reason why it gets mentioned so much is because it and nms are the only ways of doing some pretty crucial stuff
cough pathfindergoals cough
just read thru some patch notes on the bug and it seems as if the actual gui problem wasn't ever actually fixed, the only thing that was fixed was the chest bug that allowed it
Im currently digging in NMS but it doesnt look too good because even when i bypass the spigot check i get:
The same
I tried going down to 7 * 9 which is one row more that usual
Nope it goes even deeper. In NMS there is one static final instance for every container size
Nope. Im pretty sure that when im going to try and tinker a new version of this container with 9x9 slots the client would just crash.
So I managed to get the list of columns but how could I just get the rows from those columns (sql)
hmm idk if it would crash as it was able to render that container but yeah I guess I see your point as those are set like that
I can maybe try tomorrow with some reflection and a lot of optimism to assemble a container with that size
but im out for today
yeah no worries man, if you have some spare time and get to do it @ me please I am curious lmao
cya
could someone help me with this:
https://paste.md-5.net/oyezafiyoj.md
it has an issue with NBT API
but i added it to maven and regenerated it
oh wait
found it
forgot to add the plugin to my plugins folder
Does someone has the bit of code where the damages are calculated ?
Explain?
I would like to know the damage a player would do if he hits something WITHOUT hitting something
Likle you want to damage someone?
just for reference so you have it
I have done some testing now but I really can't get past some things as I really didn't mess with most of this stuff
but yeah container sizes are checked in some ways so maybe you could do something with reflection idk
Like, I would like to know, when a player hits the air for example, what would be the damage done if it wasn't air but an entity
any clue why i'm getting sent this?
https://paste.md-5.net/ucilikotes.sql is looping over and over
Is this what you're trying to do?
at com.mcbt.rpgpackets.Slimeinswamp.SlimeReplace(Slimeinswamp.java:29) ~[?:?]
ahh
forgot to notate that
Entity ent = Bukkit.getWorld("rpg").spawnEntity(event.getLocation(), EntityType.SLIME);
what is the issue with this
Does the world "rpg" exist
yes
Send the full error pls
^
alright
indeed
Hm, lemme see if I can find anything
alright it took a bit of effort to get a latest.log that isn't so big that I cant save it to the hastebin but here it is
Oh, spawnEntity is calling SlimeReplace(EntitySpawnEvent), so it's infinitely looping
hmm
how would I work around this?
I thought my if (event.getEntity().getType() != EntityType.SLIME || event.getEntity().getType() != EntityType.PLAYER || event.getEntity().getType() != EntityType.DROPPED_ITEM) { would cover that
WAIT
IT SHOULD BE =
NOT !=
or
hmm
it should be .equals not == right/
hmm
wait no
ahh i got it nvm
if you do @ me please :)
👍
also just referring to this screenshot, it's saying container size 41 is smaller than expected as I was passing the playerInventory in the iinventory part so yeah
This is terribly confusing the way they've done this ngl
Is spigot built on top of vanilla or is it completely reprogrammed from the protocol?
You realise that this is always true right
I figured it out
yeah
did this instead
if (event.getEntity().getType() == (EntityType.SLIME)) {
return;
}
event.setCancelled(true);```
silly mistake haha
thanks for scrolling up and still trying to help though! Appreciate it
isn't this whole thing the same as
if (event.getEntity().getType() != EntityType.SLIME) {
setCancelled(true);
}
or is there sth else you are doing before the second if
its actually after, I replace the entity with a slime
How to check if offlineplayer exists?
I did have this section as part of my code but it did loop
public void SlimeReplace(EntitySpawnEvent event) {
if (event.getEntity().getType() != EntityType.SLIME || event.getEntity().getType() != EntityType.PLAYER || event.getEntity().getType() != EntityType.DROPPED_ITEM) {
event.setCancelled(true);
if (event.getLocation().getWorld() == Bukkit.getWorld("rpg")) {
Location center = new Location(Bukkit.getWorld("rpg"), 68, 69, 125);
Double distance = 75D;
Location location = event.getLocation();
if (location.distanceSquared(center) <= distance * distance) {
Entity ent = Bukkit.getWorld("rpg").spawnEntity(event.getLocation(), EntityType.SLIME);
Slime slime = (Slime) ent;
}
}
}
}
}
``` this code was giving the error which does have that
plus other stuff
no what im saying is
your first if statement is still useless
suppose A || B but ~A -> B, then A || B is always true
Before I begin, this idea has come from me experimenting with numerous plugins as I plan my server to death. Real shoutout to @NoLogic with his Vivaldi plugin for what I feel is the best seasons plugin out there right now. Now here we go!
Using a secondary world(s) to simulate seasons in Minecraft
To my understanding a plugin should have the capability of modifying blocks, tracking movement, altering game states/rules, force texture packs, alter files, and enabling chunks.
What should be possible to simulate seasons without seriously altering biomes or being global projections across the server while also controlling good tps for a immersive world, this would give the most controlling form of seasonal support in vanilla Minecraft. It plays as this, a world (A) is generated with another world (B) that should be exactly the same. World A serves as one season, most likely summer. World B serves as a winter variation of the world.
The worlds both A and B will be generated by seed if the server is just normal Minecraft. If using custom maps World A would be generated with whatever features (new generation or custom map) then copied to world B. (raw region files for optimization). This second option would most likely be the optimal way to do it even if its vanilla Minecraft seed generation.
Next, we alter World B to be winter. This is done by having a loaded chunk alternate through the world checking ever chunk. This is while the server would be offline from player use, in server setup or when setting up this plugin or to play catch up on the following functions. World B is modified using functions to modify blocks so that (based on biome type, an uploaded image map, or coordinate/height-based settings) So that regions are snow covered, and water now ice.
Now we have world A in summer and world B in Winter. Hit the start button and players join. These players actions will be tracked in the following way to keep world B synced to world A. Real time editing could be enabled so that new blocks made or destroyed are detected including all attributes such as generation, changes in block states, items in chests, accounting for seasonal variation etc) and is copied into a currently FROZEN world B. world B should be programmed where the only block changes made can be done by this interaction between World A and B. Functionally World B is dead. It will have world game rules to disable for example natural decay of snow in the winter world even in say a desert. If tps becomes an issue, the changes could be saved to a file that will chronologically act it out in World B when server tps improves or set up for a maintenance.
Winter approaches and the server now must load world B and unload A. In this process it tells the server to use a winter version resource pack instead of vanilla summer or unloaded one. The plugin also updates all player locations in world B to match world A. Server reboots, players join and now are in a winter tone of their world where the texture pack with optifiine would be used to solve ambience, textures, biome colors, rain to snow based on biome, sound, you name it) to account for the visual aspect, so that it snow in a plains biome that has been altered to be covered in snow.
Pros to this: With techniques to minimize server resources when making the opposite variation world or worlds, players can enjoy exploring without lag. Then they can explore complete chunks that are already loaded into another seasonal type. This is due to the pre scan of making seasonal affects across an entire world before the server starts up and having a function that when new chunks are generated load additional resources to make it seasonal type of the current world a player is in, adding a layer to current world gen (which can be copied to the other worlds later).
The downsides is players would be forced to use a resource pack and the server would be down between seasons for a restart. .
Thoughts?
ehm… why?
having 4 worlds that are exactly the same is not minimizing resources
also instead of using 4 worlds you could just fake biomes for snowing and stuff like that
but creating 4 worlds that would need to be constantly updated for changes will definitely cause issues
Hello
how can I open workbench and set result and metric? when I use CraftingInventory craftingInventory = (CraftingInventory) player.openWorkbench(null, true); craftingInventory.setResult(item); player.openInventory(craftingInventory);, the error occursjava.lang.ClassCastException: class org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryView cannot be cast to class org.bukkit.inventory.CraftingInventory (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryView and org.bukkit.inventory.CraftingInventory are in unnamed module of loader 'app')
and when I use CraftingInventory craftingInventory = (CraftingInventory) Bukkit.createInventory(player, InventoryType.CRAFTING, "e"); craftingInventory.setResult(item); player.openInventory(craftingInventory);the error occurs Caused by: java.lang.IllegalArgumentException: Cannot open an inventory of type CRAFTING
no more google threads :/
workbench
its called crafting table now XD
so u cant open a crafting table inventory
try this
p.openInventory(inv); ```
InvType from crafting to workbench
hmm thanks you but still error occurs ```CraftingInventory craftingInventory = (CraftingInventory) Bukkit.createInventory(player, InventoryType.WORKBENCH, "e");
craftingInventory.setResult(item);
player.openInventory(craftingInventory);````aused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.inventory.CraftingInventory (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom and org.bukkit.inventory.CraftingInventory are in unnamed module of loader 'app')`
that returns CraftInventoryView and is not the same as a inventory
different classes
CraftInventoryCustom
and
CraftingInventory
org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventoryCustom
is this nms?
weird name
so you want to set a recipe on the workbench when a player opens a workbench with right click or with a command?
hnmm
nop
when player right clicks book
open workbench, set result of item and metric
uhh is there no solution? 😦
its is totally doable
anyone know the best way to convert a HashMap's values into a List
i think
.toList
lol
googl
its not a thing?
can you tell me the solution?
I can't find any google result or thread
i dont want to store the keys tho i just want to store the values
i want to put them into a list
bump
apparently ArrayList<>(myHashMap.values()) this is a arraylist constructor?
it should work right ?
Still trying to figure out how to cancel the bow pulling
like its possible
but idk how
pretty sure theres a event for that
right click?
check for bow
cancel
?
bow pulling
not bow shoot
I already cancelled the interact event
oh
but that just prevents it from shooting
packets
its still draws/pulls back the bow
ye but wich xD
its client sided hmmm
I have do some testing and come up with this.
InventoryView inventoryView = player.openWorkbench(null, true);
CraftingInventory craftingInventory = (CraftingInventory) inventoryView.getTopInventory();
craftingInventory.setResult(new ItemStack(Material.BARRIER));
player.updateInventory();
and it works, it set the result and you need to update the inventory otherwise you will got a visual bug.
what are you trying to do?
does anyone have a link to protocol Lib discord?
just to convert the values of a hashmap to a ArrayList
Oh, Map#values then
yeah ik i was messing around and intellij gave me that
uhh
removed the snapshot part and it works
i cant find the discord for protocolLib
bro, just go to their resource page on spigot
