Merge pull request #6 from Hynse/folia

update verison
This commit is contained in:
MidnightTale 2023-04-13 14:58:38 +07:00 • committed by GitHub
commit 71447fc717
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 23 deletions

View file

@ -5,7 +5,7 @@ plugins {
def loader = 'folia' def loader = 'folia'
def server = '1.19.4' def server = '1.19.4'
group = 'xyz.hynse' group = 'xyz.hynse'
version = "1.2-${server}-${loader}" version = "1.3-${server}-${loader}"
repositories { repositories {
mavenCentral() mavenCentral()

View file

@ -39,6 +39,7 @@ public class FoliaFlow extends JavaPlugin implements Listener {
@Override @Override
public void onEnable() { public void onEnable() {
super.onEnable(); super.onEnable();
// Get the region scheduler for the server // Get the region scheduler for the server
try { try {
RegionScheduler schedulerblock = getServer().getRegionScheduler(); RegionScheduler schedulerblock = getServer().getRegionScheduler();
@ -56,31 +57,34 @@ public class FoliaFlow extends JavaPlugin implements Listener {
} catch (NullPointerException block) { } catch (NullPointerException block) {
getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)"); getServer().getLogger().info("Region Scheduler erorr (likly chunky it not load)");
} }
try { AsyncScheduler scheduler = getServer().getAsyncScheduler();
AsyncScheduler scheduler = getServer().getAsyncScheduler(); task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> {
task = scheduler.runAtFixedRate(this, (scheduledTask) -> getScheduler().runTask(this, () -> { for (World world : Bukkit.getWorlds()) {
for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) {
for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) {
if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0);
//Location loc = entity.getLocation(); Location loc = entity.getLocation();
//debug("Falling block spawned at location " + loc); if (loc.distance(centerLoc) <= 1) {
// Set the initial velocity of the falling block only if it doesn't have a velocity stored
// Set the initial velocity of the falling block only if it doesn't have a velocity stored if (!velocitiesMap.containsKey(entity)) {
if (!velocitiesMap.containsKey(entity)) { try {
int index = counter % 4; int index = counter % 4;
counter++; counter++;
Vector velocity = velocities[index]; Vector velocity = velocities[index];
entity.setVelocity(velocity); entity.setVelocity(velocity);
velocitiesMap.put(entity, velocity); // Store the velocity in the map velocitiesMap.put(entity, velocity); // Store the velocity in the map
movingBlocks.add(entity.getLocation()); // Add the location to the set movingBlocks.add(entity.getLocation()); // Add the location to the set
} catch (NullPointerException e) {
// Handle the exception here, for example:
e.printStackTrace();
getServer().getLogger().info("An error occurred: " + e.getMessage());
}
}
}
} }
} }
} }
} }), 0L, 1L, TimeUnit.MILLISECONDS);
}), 0L, 1L, TimeUnit.MILLISECONDS);
} catch (NullPointerException e) {
getServer().getLogger().info("AsyncScheduler erorr (likly chunky it not load)");
}
getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(this, this);
getServer().getConsoleSender().sendMessage(""); getServer().getConsoleSender().sendMessage("");
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ "); getServer().getConsoleSender().sendMessage(ChatColor.GREEN + " ______________ ");