Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into ridecounter-map-fixes
Browse files Browse the repository at this point in the history
siebsie23 committed Jul 2, 2024
2 parents 453c882 + e42e226 commit db18549
Showing 15 changed files with 293 additions and 57 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ on:
workflow_dispatch:

env:
MINECRAFT_VERSION: 1.20.4
MINECRAFT_VERSION: 1.20.6

jobs:
build:
@@ -23,10 +23,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Java 17
- name: Set up Java 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: maven
- uses: SpraxDev/Action-SpigotMC@v4
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ on:
branches: [ "master" ]

env:
MINECRAFT_VERSION: 1.20.4
MINECRAFT_VERSION: 1.20.6

jobs:
build:
@@ -24,10 +24,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Java 17
- name: Set up Java 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: maven
- uses: SpraxDev/Action-SpigotMC@v4
8 changes: 8 additions & 0 deletions docs/plugin_update.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,14 @@ and download the latest BuildTools.

Run BuildTools with the '--remapped' option, or in the gui with 'Remapped Jars'.

## 2. Update Java and Maven if necessary

BuildTools will notify you when it needs a Java update. However, check maven as well if it is using the latest Java version.

`mvn -version`

You may have to change your JAVA_HOME environment variable.

## 2. Add new build profile to pom.xml
```xml
<profile>
40 changes: 24 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -38,12 +38,12 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17.0.5</java.version>
<java.versioneasy>17</java.versioneasy>
<maven.compiler.source>17.0.5</maven.compiler.source>
<maven.compiler.target>17.0.5</maven.compiler.target>
<java.version>21.0.3</java.version>
<java.versioneasy>21</java.versioneasy>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>

<minecraft.version.short></minecraft.version.short>
<minecraft.version.short></minecraft.version.short> <!-- Filled by profile -->
<minecraft.version.short.spigot>${minecraft.version.short}</minecraft.version.short.spigot>
<minecraft.version.apiversion></minecraft.version.apiversion>
<minecraft.version>${minecraft.version.short}-R0.1-SNAPSHOT</minecraft.version>
@@ -62,7 +62,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -87,12 +87,12 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.12.3</version>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.1.0</version>
<version>5.3.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -110,19 +110,19 @@
<dependency>
<groupId>dev.cerus.maps</groupId>
<artifactId>common</artifactId>
<version>3.8.3</version>
<version>3.8.5</version>
<scope>compile</scope> <!-- "provided" if the maps plugin is on the server, "compile" if not -->
</dependency>
<dependency>
<groupId>dev.cerus.maps</groupId>
<artifactId>plugin</artifactId>
<version>3.8.3</version>
<version>3.8.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -147,7 +147,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.13.0</version>
<configuration>
<fork>true</fork>
<meminitial>512m</meminitial>
@@ -159,7 +159,7 @@
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.4</version>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
@@ -213,7 +213,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.0</version>
<configuration>
<relocations>
<relocation>
@@ -292,12 +292,20 @@
</profile>
<profile>
<id>jrides-1.20.4</id>
<properties>
<minecraft.version.short>1.20.4</minecraft.version.short>
<minecraft.version.short.spigot>1.20.4</minecraft.version.short.spigot>
<minecraft.version.apiversion>1.20</minecraft.version.apiversion>
</properties>
</profile>
<profile>
<id>jrides-1.20.6</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<minecraft.version.short>1.20.4</minecraft.version.short>
<minecraft.version.short.spigot>1.20.4</minecraft.version.short.spigot>
<minecraft.version.short>1.20.6</minecraft.version.short>
<minecraft.version.short.spigot>1.20.6</minecraft.version.short.spigot>
<minecraft.version.apiversion>1.20</minecraft.version.apiversion>
</properties>
</profile>
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ public void setRideOverviewMapId(int rideOverviewMapId) {
public void setTrains(List<TrainHandle> trains) {
this.trains = trains;
trains.forEach(t -> t.setCoasterHandle(this));
this.visualisationTool = ParticleTrackVisualisationTool.fromTrack(getWorld(), track, 20, trains);
this.visualisationTool = ParticleTrackVisualisationTool.fromTrack(track, 20, trains);
}

public List<TrainHandle> getTrains() {
Original file line number Diff line number Diff line change
@@ -18,47 +18,48 @@
package com.jverbruggen.jrides.animator.coaster.tool;

import com.jverbruggen.jrides.animator.coaster.TrainHandle;
import com.jverbruggen.jrides.common.particle.Particle;
import com.jverbruggen.jrides.common.particle.ParticleSpawner;
import com.jverbruggen.jrides.models.entity.Player;
import com.jverbruggen.jrides.models.math.Vector3;
import com.jverbruggen.jrides.models.ride.coaster.track.Track;
import com.jverbruggen.jrides.models.ride.coaster.train.CoasterCart;
import com.jverbruggen.jrides.models.ride.section.Section;
import org.bukkit.Location;
import org.bukkit.Particle;
import com.jverbruggen.jrides.serviceprovider.ServiceProvider;
import org.bukkit.World;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class ParticleTrackVisualisationTool extends ParticleVisualisationTool {
private List<Location> locations;
private World world;
private List<Location> sectionSplitLocations;
private List<TrainHandle> trains;
private final List<Vector3> locations;
private final List<Vector3> sectionSplitLocations;
private final List<TrainHandle> trains;
private final ParticleSpawner particleSpawner;

public ParticleTrackVisualisationTool(World world, List<Location> locations, List<Location> sectionSplitLocations, List<TrainHandle> trains){
public ParticleTrackVisualisationTool(List<Vector3> locations, List<Vector3> sectionSplitLocations, List<TrainHandle> trains){
super(5);
this.world = world;
this.locations = locations;
this.sectionSplitLocations = sectionSplitLocations;
this.trains = trains;
this.particleSpawner = ServiceProvider.getSingleton(ParticleSpawner.class);
}

public static ParticleTrackVisualisationTool fromTrack(World world, Track track, int takeOneInX, List<TrainHandle> trains){
public static ParticleTrackVisualisationTool fromTrack(Track track, int takeOneInX, List<TrainHandle> trains){
List<Vector3> positions = track.getAllPositions();

List<Location> sectionSplitLocations = track.getSections().stream()
.map(s -> s.getParentTrack().getLocationFor(s.getEndFrame()).toBukkitLocation(world))
List<Vector3> sectionSplitLocations = track.getSections().stream()
.map(s -> s.getParentTrack().getLocationFor(s.getEndFrame()))
.collect(Collectors.toList());

List<Location> locations = IntStream
List<Vector3> locations = IntStream
.range(0, positions.size())
.filter(i -> i % takeOneInX == 0)
.mapToObj(i -> positions.get(i).toBukkitLocation(world))
.mapToObj(positions::get)
.collect(Collectors.toList());

return new ParticleTrackVisualisationTool(world, locations, sectionSplitLocations, trains);
return new ParticleTrackVisualisationTool(locations, sectionSplitLocations, trains);
}

@Override
@@ -69,25 +70,24 @@ public void tick(){
}

public void spawnVisualisationParticles(Player player){
org.bukkit.entity.Player bukkitPlayer = player.getBukkitPlayer();
for(Location location : locations){
bukkitPlayer.spawnParticle(Particle.VILLAGER_HAPPY, location, 1, 0.01, 0.01, 0.01, 0);
for(Vector3 location : locations){
particleSpawner.spawnParticle(player, Particle.TRACK_PARTICLE, location, 1, 0.01, 0.01, 0.01);
}
for(Location splitSectionLocation : sectionSplitLocations){
bukkitPlayer.spawnParticle(Particle.CRIT_MAGIC, splitSectionLocation, 5, 0.01, 1, 0.01, 0);
for(Vector3 splitSectionLocation : sectionSplitLocations){
particleSpawner.spawnParticle(player, Particle.SECTION_DIVIDER_PARTICLE, splitSectionLocation, 5, 0.01, 1, 0.01);
}
for(TrainHandle train : trains){
bukkitPlayer.spawnParticle(Particle.DRIP_WATER, train.getTrain().getCurrentHeadLocation().toBukkitLocation(world), 5, 0.01, 1, 0.01, 0);
particleSpawner.spawnParticle(player, Particle.TRAIN_HEAD_PARTICLE, train.getTrain().getCurrentHeadLocation(), 5, 0.01, 1, 0.01);
for(CoasterCart cart : train.getTrain().getCarts()){
bukkitPlayer.spawnParticle(Particle.VILLAGER_HAPPY, cart.getPosition().toBukkitLocation(world), 5, 0.01, 1, 0.01, 0);
particleSpawner.spawnParticle(player, Particle.CART_PARTICLE, cart.getPosition(), 5, 0.01, 1, 0.01);

Section cartSection = cart.getFrame().getSection();
if(cart.getWheelDistance() != 0) {
bukkitPlayer.spawnParticle(Particle.HEART, cartSection.getLocationFor(cart.getFrame().clone().add(cart.getWheelDistance())).toBukkitLocation(world), 1, 0.01, 1, 0.01, 0);
bukkitPlayer.spawnParticle(Particle.HEART, cartSection.getLocationFor(cart.getFrame().clone().add(-cart.getWheelDistance())).toBukkitLocation(world), 1, 0.01, 1, 0.01, 0);
particleSpawner.spawnParticle(player, Particle.CART_WHEEL_DISTANCE_PARTICLE, cartSection.getLocationFor(cart.getFrame().clone().add(cart.getWheelDistance())), 1, 0.01, 1, 0.01);
particleSpawner.spawnParticle(player, Particle.CART_WHEEL_DISTANCE_PARTICLE, cartSection.getLocationFor(cart.getFrame().clone().add(-cart.getWheelDistance())), 1, 0.01, 1, 0.01);
}
}
bukkitPlayer.spawnParticle(Particle.DRIP_LAVA, train.getTrain().getCurrentTailLocation().toBukkitLocation(world), 5, 0.01, 1, 0.01, 0);
particleSpawner.spawnParticle(player, Particle.TRAIN_TAIL_PARTICLE, train.getTrain().getCurrentTailLocation(), 5, 0.01, 1, 0.01);
}
}
}
Original file line number Diff line number Diff line change
@@ -17,18 +17,19 @@

package com.jverbruggen.jrides.animator.coaster.tool;

import com.jverbruggen.jrides.common.particle.Particle;
import com.jverbruggen.jrides.common.particle.ParticleSpawner;
import com.jverbruggen.jrides.models.entity.Player;
import com.jverbruggen.jrides.models.ride.coaster.train.Train;
import org.bukkit.Particle;
import org.bukkit.World;
import com.jverbruggen.jrides.serviceprovider.ServiceProvider;

public class ParticleTrainVisualisationTool extends ParticleVisualisationTool {
private World world;
private Train train;
private final ParticleSpawner particleSpawner;
private final Train train;

public ParticleTrainVisualisationTool(World world, Train train){
public ParticleTrainVisualisationTool(Train train){
super(5);
this.world = world;
this.particleSpawner = ServiceProvider.getSingleton(ParticleSpawner.class);
this.train = train;
}

@@ -40,7 +41,6 @@ public void tick(){
}

public void spawnVisualisationParticles(Player player){
org.bukkit.entity.Player bukkitPlayer = player.getBukkitPlayer();
bukkitPlayer.spawnParticle(Particle.VILLAGER_HAPPY, train.getCurrentHeadLocation().toBukkitLocation(world), 1, 0.01, 0.01, 0.01, 0);
particleSpawner.spawnParticle(player, Particle.TRAIN_HEAD_PARTICLE, train.getCurrentHeadLocation(), 1, 0.01, 0.01, 0.01);
}
}
44 changes: 44 additions & 0 deletions src/main/java/com/jverbruggen/jrides/common/Tuple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/************************************************************************************************************
* GPLv3 License *
* *
* Copyright (c) 2024-2024 JVerbruggen *
* https://github.com/JVerbruggen/jrides *
* *
* This software is protected under the GPLv3 license, *
* that can be found in the project's LICENSE file. *
* *
* In short, permission is hereby granted that anyone can copy, modify and distribute this software. *
* You have to include the license and copyright notice with each and every distribution. You can use *
* this software privately or commercially. Modifications to the code have to be indicated, and *
* distributions of this code must be distributed with the same license, GPLv3. The software is provided *
* without warranty. The software author or license can not be held liable for any damages *
* inflicted by the software. *
************************************************************************************************************/

package com.jverbruggen.jrides.common;

public class Tuple<A, B> {
private A a;
private B b;

public Tuple(A var0, B var1) {
this.a = var0;
this.b = var1;
}

public A getA() {
return this.a;
}

public void setA(A var0) {
this.a = var0;
}

public B getB() {
return this.b;
}

public void setB(B var0) {
this.b = var0;
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/jverbruggen/jrides/common/particle/Particle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/************************************************************************************************************
* GPLv3 License *
* *
* Copyright (c) 2024-2024 JVerbruggen *
* https://github.com/JVerbruggen/jrides *
* *
* This software is protected under the GPLv3 license, *
* that can be found in the project's LICENSE file. *
* *
* In short, permission is hereby granted that anyone can copy, modify and distribute this software. *
* You have to include the license and copyright notice with each and every distribution. You can use *
* this software privately or commercially. Modifications to the code have to be indicated, and *
* distributions of this code must be distributed with the same license, GPLv3. The software is provided *
* without warranty. The software author or license can not be held liable for any damages *
* inflicted by the software. *
************************************************************************************************************/

package com.jverbruggen.jrides.common.particle;

public enum Particle {
TRACK_PARTICLE,
SECTION_DIVIDER_PARTICLE,
TRAIN_HEAD_PARTICLE,
TRAIN_TAIL_PARTICLE,
CART_PARTICLE,
CART_WHEEL_DISTANCE_PARTICLE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/************************************************************************************************************
* GPLv3 License *
* *
* Copyright (c) 2024-2024 JVerbruggen *
* https://github.com/JVerbruggen/jrides *
* *
* This software is protected under the GPLv3 license, *
* that can be found in the project's LICENSE file. *
* *
* In short, permission is hereby granted that anyone can copy, modify and distribute this software. *
* You have to include the license and copyright notice with each and every distribution. You can use *
* this software privately or commercially. Modifications to the code have to be indicated, and *
* distributions of this code must be distributed with the same license, GPLv3. The software is provided *
* without warranty. The software author or license can not be held liable for any damages *
* inflicted by the software. *
************************************************************************************************************/

package com.jverbruggen.jrides.common.particle;

import com.jverbruggen.jrides.models.entity.Player;
import com.jverbruggen.jrides.models.math.Vector3;

public interface ParticleSpawner {
void spawnParticle(Player player, Particle particle, Vector3 location, int amount, double v0, double v1, double v2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/************************************************************************************************************
* GPLv3 License *
* *
* Copyright (c) 2024-2024 JVerbruggen *
* https://github.com/JVerbruggen/jrides *
* *
* This software is protected under the GPLv3 license, *
* that can be found in the project's LICENSE file. *
* *
* In short, permission is hereby granted that anyone can copy, modify and distribute this software. *
* You have to include the license and copyright notice with each and every distribution. You can use *
* this software privately or commercially. Modifications to the code have to be indicated, and *
* distributions of this code must be distributed with the same license, GPLv3. The software is provided *
* without warranty. The software author or license can not be held liable for any damages *
* inflicted by the software. *
************************************************************************************************************/

package com.jverbruggen.jrides.common.particle;

import org.bukkit.Bukkit;

public class ParticleSpawnerFactory {
public static ParticleSpawner getParticleSpawner(){
String currentVersion = Bukkit.getVersion();
ParticleSpawner particleSpawner = null;

if(currentVersion.contains("1.19.2")
|| currentVersion.contains("1.20.1")
|| currentVersion.contains("1.20.2")
|| currentVersion.contains("1.20.3")
|| currentVersion.contains("1.20.4")){
particleSpawner = new ParticleSpawner_Pre_1_20_5();
}else if(currentVersion.contains("1.20.5")
|| currentVersion.contains("1.20.6")){
particleSpawner = new ParticleSpawner_1_20_5();
}

if(particleSpawner == null)
throw new RuntimeException("No particle spawner implemented for bukkit version '" + currentVersion + "'");

return particleSpawner;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/************************************************************************************************************
* GPLv3 License *
* *
* Copyright (c) 2024-2024 JVerbruggen *
* https://github.com/JVerbruggen/jrides *
* *
* This software is protected under the GPLv3 license, *
* that can be found in the project's LICENSE file. *
* *
* In short, permission is hereby granted that anyone can copy, modify and distribute this software. *
* You have to include the license and copyright notice with each and every distribution. You can use *
* this software privately or commercially. Modifications to the code have to be indicated, and *
* distributions of this code must be distributed with the same license, GPLv3. The software is provided *
* without warranty. The software author or license can not be held liable for any damages *
* inflicted by the software. *
************************************************************************************************************/

package com.jverbruggen.jrides.common.particle;

public class ParticleSpawner_1_20_5 extends ParticleSpawner_Pre_1_20_5 {

@Override
protected org.bukkit.Particle getBukkitParticle(Particle particle){
String particleName = switch (particle){
case TRACK_PARTICLE -> "HAPPY_VILLAGER";
case SECTION_DIVIDER_PARTICLE -> "CRIT";
case TRAIN_HEAD_PARTICLE -> "DRIPPING_WATER";
case TRAIN_TAIL_PARTICLE -> "DRIPPING_LAVA";
case CART_PARTICLE -> "HAPPY_VILLAGER";
case CART_WHEEL_DISTANCE_PARTICLE -> "HEART";
};
return org.bukkit.Particle.valueOf(particleName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/************************************************************************************************************
* GPLv3 License *
* *
* Copyright (c) 2024-2024 JVerbruggen *
* https://github.com/JVerbruggen/jrides *
* *
* This software is protected under the GPLv3 license, *
* that can be found in the project's LICENSE file. *
* *
* In short, permission is hereby granted that anyone can copy, modify and distribute this software. *
* You have to include the license and copyright notice with each and every distribution. You can use *
* this software privately or commercially. Modifications to the code have to be indicated, and *
* distributions of this code must be distributed with the same license, GPLv3. The software is provided *
* without warranty. The software author or license can not be held liable for any damages *
* inflicted by the software. *
************************************************************************************************************/

package com.jverbruggen.jrides.common.particle;

import com.jverbruggen.jrides.JRidesPlugin;
import com.jverbruggen.jrides.models.entity.Player;
import com.jverbruggen.jrides.models.math.Vector3;

public class ParticleSpawner_Pre_1_20_5 implements ParticleSpawner{

protected org.bukkit.Particle getBukkitParticle(Particle particle){
String particleName = switch (particle){
case TRACK_PARTICLE -> "VILLAGER_HAPPY";
case SECTION_DIVIDER_PARTICLE -> "CRIT_MAGIC";
case TRAIN_HEAD_PARTICLE -> "DRIP_WATER";
case TRAIN_TAIL_PARTICLE -> "DRIP_LAVA";
case CART_PARTICLE -> "VILLAGER_HAPPY";
case CART_WHEEL_DISTANCE_PARTICLE -> "HEART";
};
return org.bukkit.Particle.valueOf(particleName);
}

@Override
public void spawnParticle(Player player, Particle particle, Vector3 location, int amount, double v0, double v1, double v2) {
player.getBukkitPlayer().spawnParticle(
getBukkitParticle(particle),
location.toBukkitLocation(JRidesPlugin.getWorld()),
amount, v0, v1, v2, 0);
}
}
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@

package com.jverbruggen.jrides.effect;

import com.jverbruggen.jrides.common.Tuple;
import com.jverbruggen.jrides.config.ConfigManager;
import com.jverbruggen.jrides.config.trigger.TriggerConfig;
import com.jverbruggen.jrides.effect.handle.EffectTriggerHandle;
@@ -27,8 +28,6 @@
import com.jverbruggen.jrides.models.ride.RideType;
import com.jverbruggen.jrides.models.ride.coaster.track.Track;
import com.jverbruggen.jrides.serviceprovider.ServiceProvider;
import net.minecraft.util.Tuple;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;

import java.util.*;
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@
import com.jverbruggen.jrides.animator.coaster.trackbehaviour.factory.TrackBehaviourFactory;
import com.jverbruggen.jrides.animator.coaster.trackbehaviour.result.CartMovementFactory;
import com.jverbruggen.jrides.common.MenuSessionManager;
import com.jverbruggen.jrides.common.particle.ParticleSpawner;
import com.jverbruggen.jrides.common.particle.ParticleSpawnerFactory;
import com.jverbruggen.jrides.config.ConfigManager;
import com.jverbruggen.jrides.config.trigger.TriggerConfigFactory;
import com.jverbruggen.jrides.control.controller.RideControllerFactory;
@@ -86,6 +88,7 @@ public static void configureStage2(JavaPlugin plugin){
File dataFolder = plugin.getDataFolder();

ServiceProvider.register(MenuSessionManager.class, new MenuSessionManager());
ServiceProvider.register(ParticleSpawner.class, ParticleSpawnerFactory.getParticleSpawner());
ServiceProvider.register(MessageAgentManager.class, new MessageAgentManager());
ServiceProvider.register(RideCounterManager.class, new RideCounterManager());
ServiceProvider.register(ControlModeFactory.class, new ControlModeFactory());

0 comments on commit db18549

Please sign in to comment.