-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
359 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
dependencies { | ||
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT") | ||
compileOnly("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") | ||
compileOnly(project(":multiversion:common")) | ||
compileOnly("io.papermc:paperlib:1.0.8") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dependencies { | ||
compileOnly ("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") | ||
compileOnly ("org.spigotmc:spigot:1.20") | ||
compileOnly(project(":multiversion:common")) | ||
compileOnly("io.papermc:paperlib:1.0.8") | ||
} |
47 changes: 47 additions & 0 deletions
47
multiversion/v1_20_R1/src/main/java/iridiumcore/multiversion/MultiVersion_V1_20_R1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package iridiumcore.multiversion; | ||
|
||
import com.cryptomorin.xseries.XMaterial; | ||
import com.iridium.iridiumcore.multiversion.MultiVersion; | ||
import io.papermc.lib.PaperLib; | ||
import org.bukkit.Chunk; | ||
import org.bukkit.ChunkSnapshot; | ||
import org.bukkit.World; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Interface for working with methods that were changed during an update by Spigot. | ||
*/ | ||
public class MultiVersion_V1_20_R1 extends MultiVersion { | ||
|
||
public MultiVersion_V1_20_R1(JavaPlugin javaPlugin) { | ||
super(javaPlugin); | ||
} | ||
|
||
/** | ||
* Returns the material at a position in a chunk. | ||
* | ||
* @param chunk The snapshot of the chunk where the position is in | ||
* @param x The relative x position of the block in the chunk | ||
* @param y The relative y position of the block in the chunk | ||
* @param z The relative z position of the block in the chunk | ||
* @return The material at the provided position in the chunk | ||
*/ | ||
@Override | ||
public XMaterial getMaterialAtPosition(ChunkSnapshot chunk, int x, int y, int z) { | ||
return XMaterial.matchXMaterial(chunk.getBlockType(x, y, z)); | ||
} | ||
|
||
@Override | ||
public boolean isPassable(Block block) { | ||
return block.isPassable(); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Chunk> getChunkAt(World world, int x, int z) { | ||
return PaperLib.getChunkAtAsync(world, x, z, true); | ||
} | ||
|
||
} |
123 changes: 123 additions & 0 deletions
123
multiversion/v1_20_R1/src/main/java/iridiumcore/nms/NMS_V1_20_R1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package iridiumcore.nms; | ||
|
||
import com.iridium.iridiumcore.Color; | ||
import com.iridium.iridiumcore.nms.NMS; | ||
import net.minecraft.server.MinecraftServer; | ||
import org.bukkit.*; | ||
import org.bukkit.World.Environment; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Interface for working with the net.minecraft.server package. | ||
* Version-specific, so it has to be implemented for every version we support. | ||
* This is the implementation for v1_20_R1. | ||
*/ | ||
public class NMS_V1_20_R1 implements NMS { | ||
|
||
/** | ||
* Deletes a block faster than with Spigots implementation. | ||
* See | ||
* https://www.spigotmc.org/threads/methods-for-changing-massive-amount-of-blocks-up-to-14m-blocks-s.395868/ | ||
* for more information. | ||
* | ||
* @param location The location of the block which should be deleted | ||
*/ | ||
@Override | ||
public void deleteBlockFast(Location location) { | ||
location.getBlock().setType(Material.AIR, false); | ||
} | ||
|
||
/** | ||
* Sends the provided chunk to all the specified players. | ||
* Used for updating chunks. | ||
* | ||
* @param players The player which should see the updated chunk | ||
* @param chunk The chunk which should be updated | ||
*/ | ||
@Override | ||
public void sendChunk(List<Player> players, org.bukkit.Chunk chunk) { | ||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ()); | ||
|
||
/* | ||
* net.minecraft.world.level.chunk.Chunk chunkLevel = ((CraftChunk) | ||
* chunk).getHandle(); | ||
* ClientboundLevelChunkWithLightPacket refresh = new | ||
* ClientboundLevelChunkWithLightPacket(chunkLevel, chunkLevel.q.l_(), null, | ||
* null, true); | ||
* for (Player player : players) { | ||
* ((CraftPlayer) player).getHandle().b.a(refresh); | ||
* } | ||
*/ | ||
} | ||
|
||
/** | ||
* Sends a colored world border to the specified Player with the provided size | ||
* and center location. | ||
* The size is half of the length of one side of the border. | ||
* | ||
* @param player The Player which should see the border | ||
* @param color The color of the border | ||
* @param size The size of this border, see the description above for | ||
* more information | ||
* @param centerLocation The center of the border | ||
*/ | ||
@Override | ||
public void sendWorldBorder(Player player, Color color, double size, Location centerLocation) { | ||
|
||
WorldBorder worldBorder = Bukkit.getServer().createWorldBorder(); | ||
|
||
// WorldBorder worldBorder = new WorldBorder(); | ||
// worldBorder.world = ((CraftWorld) centerLocation.getWorld()).getHandle(); | ||
if(centerLocation.getWorld().getEnvironment() == Environment.NETHER) | ||
worldBorder.setCenter(centerLocation.getBlockX()*8 + 0.5, centerLocation.getBlockZ()*8 + 0.5); | ||
else | ||
worldBorder.setCenter(centerLocation.getBlockX() + 0.5, centerLocation.getBlockZ() + 0.5); | ||
|
||
|
||
if (color == Color.OFF) { | ||
worldBorder.setSize(Integer.MAX_VALUE); | ||
} else { | ||
worldBorder.setSize(size); | ||
} | ||
|
||
worldBorder.setDamageAmount(0); | ||
worldBorder.setDamageBuffer(0); | ||
|
||
if (color == Color.RED) { | ||
worldBorder.setSize(size - 0.1D, 20000000L); | ||
} else if (color == Color.GREEN) { | ||
worldBorder.setSize( size+0.1D, 20000000L); | ||
} | ||
|
||
player.setWorldBorder(worldBorder); | ||
} | ||
|
||
/** | ||
* Sends a title with the provided properties to the Player. | ||
* | ||
* @param player The Player which should see the title | ||
* @param title The upper message of the title | ||
* @param subtitle The lower message of the title | ||
* @param fadeIn The amount of time this title should fade in in ticks | ||
* @param displayTime The amount of time this title should stay fully visible in | ||
* ticks | ||
* @param fadeOut The amount of time this title should fade out in ticks | ||
*/ | ||
@Override | ||
public void sendTitle(Player player, String title, String subtitle, int fadeIn, int displayTime, int fadeOut) { | ||
player.sendTitle( | ||
ChatColor.translateAlternateColorCodes('&', title), | ||
ChatColor.translateAlternateColorCodes('&', subtitle), | ||
fadeIn, | ||
displayTime, | ||
fadeOut); | ||
} | ||
|
||
@Override | ||
public double[] getTPS() { | ||
return MinecraftServer.getServer().recentTps; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dependencies { | ||
compileOnly ("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") | ||
compileOnly ("org.spigotmc:spigot:1.20.2") | ||
compileOnly(project(":multiversion:common")) | ||
compileOnly("io.papermc:paperlib:1.0.8") | ||
} |
47 changes: 47 additions & 0 deletions
47
multiversion/v1_20_R2/src/main/java/iridiumcore/multiversion/MultiVersion_V1_20_R2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package iridiumcore.multiversion; | ||
|
||
import com.cryptomorin.xseries.XMaterial; | ||
import com.iridium.iridiumcore.multiversion.MultiVersion; | ||
import io.papermc.lib.PaperLib; | ||
import org.bukkit.Chunk; | ||
import org.bukkit.ChunkSnapshot; | ||
import org.bukkit.World; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Interface for working with methods that were changed during an update by Spigot. | ||
*/ | ||
public class MultiVersion_V1_20_R2 extends MultiVersion { | ||
|
||
public MultiVersion_V1_20_R2(JavaPlugin javaPlugin) { | ||
super(javaPlugin); | ||
} | ||
|
||
/** | ||
* Returns the material at a position in a chunk. | ||
* | ||
* @param chunk The snapshot of the chunk where the position is in | ||
* @param x The relative x position of the block in the chunk | ||
* @param y The relative y position of the block in the chunk | ||
* @param z The relative z position of the block in the chunk | ||
* @return The material at the provided position in the chunk | ||
*/ | ||
@Override | ||
public XMaterial getMaterialAtPosition(ChunkSnapshot chunk, int x, int y, int z) { | ||
return XMaterial.matchXMaterial(chunk.getBlockType(x, y, z)); | ||
} | ||
|
||
@Override | ||
public boolean isPassable(Block block) { | ||
return block.isPassable(); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Chunk> getChunkAt(World world, int x, int z) { | ||
return PaperLib.getChunkAtAsync(world, x, z, true); | ||
} | ||
|
||
} |
123 changes: 123 additions & 0 deletions
123
multiversion/v1_20_R2/src/main/java/iridiumcore/nms/NMS_V1_20_R2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package iridiumcore.nms; | ||
|
||
import com.iridium.iridiumcore.Color; | ||
import com.iridium.iridiumcore.nms.NMS; | ||
import net.minecraft.server.MinecraftServer; | ||
import org.bukkit.*; | ||
import org.bukkit.World.Environment; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Interface for working with the net.minecraft.server package. | ||
* Version-specific, so it has to be implemented for every version we support. | ||
* This is the implementation for v1_20_R2. | ||
*/ | ||
public class NMS_V1_20_R2 implements NMS { | ||
|
||
/** | ||
* Deletes a block faster than with Spigots implementation. | ||
* See | ||
* https://www.spigotmc.org/threads/methods-for-changing-massive-amount-of-blocks-up-to-14m-blocks-s.395868/ | ||
* for more information. | ||
* | ||
* @param location The location of the block which should be deleted | ||
*/ | ||
@Override | ||
public void deleteBlockFast(Location location) { | ||
location.getBlock().setType(Material.AIR, false); | ||
} | ||
|
||
/** | ||
* Sends the provided chunk to all the specified players. | ||
* Used for updating chunks. | ||
* | ||
* @param players The player which should see the updated chunk | ||
* @param chunk The chunk which should be updated | ||
*/ | ||
@Override | ||
public void sendChunk(List<Player> players, org.bukkit.Chunk chunk) { | ||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ()); | ||
|
||
/* | ||
* net.minecraft.world.level.chunk.Chunk chunkLevel = ((CraftChunk) | ||
* chunk).getHandle(); | ||
* ClientboundLevelChunkWithLightPacket refresh = new | ||
* ClientboundLevelChunkWithLightPacket(chunkLevel, chunkLevel.q.l_(), null, | ||
* null, true); | ||
* for (Player player : players) { | ||
* ((CraftPlayer) player).getHandle().b.a(refresh); | ||
* } | ||
*/ | ||
} | ||
|
||
/** | ||
* Sends a colored world border to the specified Player with the provided size | ||
* and center location. | ||
* The size is half of the length of one side of the border. | ||
* | ||
* @param player The Player which should see the border | ||
* @param color The color of the border | ||
* @param size The size of this border, see the description above for | ||
* more information | ||
* @param centerLocation The center of the border | ||
*/ | ||
@Override | ||
public void sendWorldBorder(Player player, Color color, double size, Location centerLocation) { | ||
|
||
WorldBorder worldBorder = Bukkit.getServer().createWorldBorder(); | ||
|
||
// WorldBorder worldBorder = new WorldBorder(); | ||
// worldBorder.world = ((CraftWorld) centerLocation.getWorld()).getHandle(); | ||
if(centerLocation.getWorld().getEnvironment() == Environment.NETHER) | ||
worldBorder.setCenter(centerLocation.getBlockX()*8 + 0.5, centerLocation.getBlockZ()*8 + 0.5); | ||
else | ||
worldBorder.setCenter(centerLocation.getBlockX() + 0.5, centerLocation.getBlockZ() + 0.5); | ||
|
||
|
||
if (color == Color.OFF) { | ||
worldBorder.setSize(Integer.MAX_VALUE); | ||
} else { | ||
worldBorder.setSize(size); | ||
} | ||
|
||
worldBorder.setDamageAmount(0); | ||
worldBorder.setDamageBuffer(0); | ||
|
||
if (color == Color.RED) { | ||
worldBorder.setSize(size - 0.1D, 20000000L); | ||
} else if (color == Color.GREEN) { | ||
worldBorder.setSize( size+0.1D, 20000000L); | ||
} | ||
|
||
player.setWorldBorder(worldBorder); | ||
} | ||
|
||
/** | ||
* Sends a title with the provided properties to the Player. | ||
* | ||
* @param player The Player which should see the title | ||
* @param title The upper message of the title | ||
* @param subtitle The lower message of the title | ||
* @param fadeIn The amount of time this title should fade in in ticks | ||
* @param displayTime The amount of time this title should stay fully visible in | ||
* ticks | ||
* @param fadeOut The amount of time this title should fade out in ticks | ||
*/ | ||
@Override | ||
public void sendTitle(Player player, String title, String subtitle, int fadeIn, int displayTime, int fadeOut) { | ||
player.sendTitle( | ||
ChatColor.translateAlternateColorCodes('&', title), | ||
ChatColor.translateAlternateColorCodes('&', subtitle), | ||
fadeIn, | ||
displayTime, | ||
fadeOut); | ||
} | ||
|
||
@Override | ||
public double[] getTPS() { | ||
return MinecraftServer.getServer().recentTps; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters