Skip to content

Commit

Permalink
Merge pull request #81 from josemmo/develop
Browse files Browse the repository at this point in the history
v1.2.8
  • Loading branch information
josemmo authored Feb 2, 2023
2 parents 1fd4319 + 3977d02 commit 2d09397
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 252 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ jobs:
else
url="https://github.com/dmulloy2/ProtocolLib/releases/download/4.8.0/ProtocolLib.jar"
fi
mkdir -p ./server/plugins
mkdir -p ./server/plugins/ProtocolLib
wget -q "$url" -O ./server/plugins/ProtocolLib.jar
echo -e "global:\n auto updater:\n notify: false\n download: false" > ./server/plugins/ProtocolLib/config.yml
# Install plugin
- name: Install plugin
Expand Down
414 changes: 194 additions & 220 deletions automata/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion automata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"start": "node index.js"
},
"dependencies": {
"mineflayer": "^4.5.1",
"mineflayer": "^4.8.0",
"rcon-client": "^4.2.3"
}
}
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.josemmo.bukkit.plugin</groupId>
<artifactId>YamipaPlugin</artifactId>
<version>1.2.7</version>
<version>1.2.8</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down Expand Up @@ -45,9 +45,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.dmulloy2</groupId>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>eebb99fa37</version>
<version>5.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -76,7 +76,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<version>24.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
25 changes: 6 additions & 19 deletions src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,6 @@ public class YamipaPlugin extends JavaPlugin {
return scheduler;
}

/**
* Get configuration value
* @param path Configuration key path
* @param defaultValue Default value
* @return Configuration value
*/
private @NotNull String getConfigValue(@NotNull String path, @NotNull String defaultValue) {
String value = getConfig().getString(path);
return (value == null) ? defaultValue : value;
}

@Override
public void onLoad() {
instance = this;
Expand All @@ -79,7 +68,7 @@ public void onLoad() {
@Override
public void onEnable() {
// Initialize logger
verbose = getConfig().getBoolean("verbose");
verbose = getConfig().getBoolean("verbose", false);
if (verbose) {
info("Running on VERBOSE mode");
}
Expand All @@ -89,9 +78,9 @@ public void onEnable() {

// Read plugin configuration paths
Path basePath = getDataFolder().toPath();
String imagesPath = getConfigValue("images-path", "images");
String cachePath = getConfigValue("cache-path", "cache");
String dataPath = getConfigValue("data-path", "images.dat");
String imagesPath = getConfig().getString("images-path", "images");
String cachePath = getConfig().getString("cache-path", "cache");
String dataPath = getConfig().getString("data-path", "images.dat");

// Create image storage
storage = new ImageStorage(
Expand All @@ -106,10 +95,8 @@ public void onEnable() {

// Create image renderer
boolean animateImages = getConfig().getBoolean("animate-images", true);
if (animateImages) {
FakeImage.enableAnimation();
info("Enabled image animation support");
}
FakeImage.configure(animateImages);
info(animateImages ? "Enabled image animation support" : "Image animation support is disabled");
renderer = new ImageRenderer(basePath.resolve(dataPath).toString());
renderer.start();

Expand Down
19 changes: 13 additions & 6 deletions src/main/java/io/josemmo/bukkit/plugin/renderer/FakeImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ public class FakeImage extends FakeEntity {
private int currentStep = -1; // Current animation step

/**
* Enable plugin-wide image animation support
* Configure class
* @param animImages Animate images
*/
public static void enableAnimation() {
animateImages = true;
public static void configure(boolean animImages) {
animateImages = animImages;
}

/**
Expand Down Expand Up @@ -518,10 +519,16 @@ private void invalidate() {
*/
private void nextStep() {
currentStep = (currentStep + 1) % numOfSteps;
for (Player player : observingPlayers) {
for (FakeItemFrame frame : frames) {
frame.render(player, currentStep);
try {
for (Player player : observingPlayers) {
for (FakeItemFrame frame : frames) {
frame.render(player, currentStep);
}
}
} catch (ConcurrentModificationException e) {
// We can safely ignore this exception as it will just result
// in a dropped step (all `observingPlayers` modifications are
// called from the same thread).
}
}
}
14 changes: 14 additions & 0 deletions src/main/java/io/josemmo/bukkit/plugin/renderer/ImageRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import io.josemmo.bukkit.plugin.utils.CsvConfiguration;
import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.*;
import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -437,4 +439,16 @@ public void onPlayerMove(@NotNull PlayerMoveEvent event) {
if (event.getFrom().getChunk().equals(event.getTo().getChunk())) return;
onPlayerLocationChange(event.getPlayer(), event.getTo());
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onVehicleMove(@NotNull VehicleMoveEvent event) {
List<Entity> passengers = event.getVehicle().getPassengers();
if (passengers.isEmpty()) return;
if (event.getFrom().getChunk().equals(event.getTo().getChunk())) return;
for (Entity passenger : passengers) {
if (passenger instanceof Player) {
onPlayerLocationChange((Player) passenger, event.getTo());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
* World Area IDs represent groups of 16 chunks arranged in a 4x4 square.
*/
public class WorldAreaId {
private static boolean USE_WORLD_VIEW_DISTANCE = true;
private static final Map<String, Integer> SIZES_PER_WORLD = new HashMap<>();
private final World world;
private final int x;
private final int z;
Expand Down Expand Up @@ -67,7 +70,11 @@ public WorldAreaId(@NotNull World world, int x, int z) {
}

// Calculate neighborhood size from world's view distance
int size = (USE_WORLD_VIEW_DISTANCE ? world.getViewDistance() : Bukkit.getServer().getViewDistance()) / 4;
// NOTE: World size is cached to prevent issues with plugins that modify it at runtime
int size = SIZES_PER_WORLD.computeIfAbsent(world.getName(), (__) -> {
int distance = USE_WORLD_VIEW_DISTANCE ? world.getViewDistance() : Bukkit.getServer().getViewDistance();
return distance / 4;
});

// Size 3 (16-chunks radius)
// ···XXX···
Expand Down

0 comments on commit 2d09397

Please sign in to comment.