Skip to content

Commit

Permalink
start work on lights moving when ring zoom event occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-hydrogen committed Apr 19, 2022
1 parent 5362ea5 commit d653a74
Show file tree
Hide file tree
Showing 15 changed files with 457 additions and 142 deletions.
26 changes: 17 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,22 @@

<dependencies>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.0-SNAPSHOT</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand All @@ -118,7 +124,7 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>22.0.0</version>
<version>23.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -138,11 +144,13 @@
<version>4.7.0</version>
<scope>provided</scope>
</dependency>
<!-- needs to be updated to 2.2.4
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<groupId>io.github.skytasul</groupId>
<artifactId>guardianbeam</artifactId>
<version>2.2.3</version>
<scope>compile</scope>
</dependency>
-->
</dependencies>
</project>
11 changes: 8 additions & 3 deletions src/main/java/exposed/hydrogen/nightclub/Nightclub.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
import exposed.hydrogen.nightclub.commands.LightUniverseCommand;
import exposed.hydrogen.nightclub.json.LightJSONReader;
import exposed.hydrogen.nightclub.json.LightJSONWriter;
import exposed.hydrogen.nightclub.light.*;
import exposed.hydrogen.nightclub.light.Light;
import exposed.hydrogen.nightclub.light.LightUniverse;
import exposed.hydrogen.nightclub.light.LightUniverseManager;
import exposed.hydrogen.nightclub.light.data.LightData;
import exposed.hydrogen.nightclub.light.data.LightPattern;
import exposed.hydrogen.nightclub.light.data.LightType;
import exposed.hydrogen.nightclub.light.event.LightChannel;
import exposed.hydrogen.nightclub.light.event.LightSpeedChannel;
import lombok.Getter;
Expand Down Expand Up @@ -42,10 +47,10 @@ public final class Nightclub extends JavaPlugin {
@Override
public void onEnable() {
GSON = new GsonBuilder()
.serializeNulls()
.setPrettyPrinting()
.registerTypeAdapter(LightUniverse.class, new LightUniverse.LightUniverseInstanceCreator())
.registerTypeAdapter(Light.class, new Light.LightUniverseInstanceCreator())
.registerTypeAdapter(Light.class, new Light.LightInstanceCreator())
.registerTypeAdapter(LightData.class, new LightData.LightDataInstanceCreator())
.create();

protocolManager = ProtocolLibrary.getProtocolManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.JsonArray;
import exposed.hydrogen.nightclub.Nightclub;
import exposed.hydrogen.nightclub.light.Light;
import exposed.hydrogen.nightclub.light.event.LightChannel;
import lombok.Getter;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -96,7 +97,7 @@ private void handle(LightEvent event, List<LightEvent> events) {
// Ring spin
case 8 -> this.getClass();
// Toggle ring zoom
case 9 -> this.getClass();
case 9 -> Nightclub.getLightUniverseManager().getLoadedUniverse().getLights().forEach(Light::ringZoom);

// Rotation speed multiplier for left lasers
case 12 -> LightChannel.LEFT_ROTATING_LASERS.setSpeed(event.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import exposed.hydrogen.nightclub.Nightclub;
import exposed.hydrogen.nightclub.light.*;
import exposed.hydrogen.nightclub.light.Light;
import exposed.hydrogen.nightclub.light.LightUniverse;
import exposed.hydrogen.nightclub.light.LightUniverseManager;
import exposed.hydrogen.nightclub.light.data.LightData;
import exposed.hydrogen.nightclub.light.data.LightPattern;
import exposed.hydrogen.nightclub.light.data.LightPatternData;
import exposed.hydrogen.nightclub.light.data.LightType;
import exposed.hydrogen.nightclub.light.event.LightChannel;
import exposed.hydrogen.nightclub.light.event.LightSpeedChannel;
import exposed.hydrogen.nightclub.util.Location;
Expand Down Expand Up @@ -548,8 +554,81 @@ public static void onRemoveLightID(CommandSender sender, String[] args) {
light.on(new Color(0x0066ff));
}
}

@Subcommand("ringzoom")
@CommandAlias("rz")
@Description("Modify a Light's ring zoom movement")
@CommandPermission("nightclub.light")
public class LightRingMoveCommand extends BaseCommand {

@Subcommand("setlocation")
@CommandAlias("sl")
@Description("Set the pitch and yaw")
@CommandPermission("nightclub.light")
public static void onSetLocation(CommandSender sender, Player player, String[] args) {
List<CommandError> errors = isUnloaded();
errors.add(player == null ? CommandError.COMMAND_SENT_FROM_CONSOLE : CommandError.VALID);
errors.add(!(args.length == 2) ? CommandError.TOO_LITTLE_ARGUMENTS : CommandError.VALID);
if (errors.stream().anyMatch(error -> error != CommandError.VALID)) {
sender.sendMessage(Util.formatErrors(errors));
return;
}
if (args.length >= 2) {
try {
light.getData().getRingMovementData().setPitchYaw(new Location(0, 0, 0, Util.parseNumber(args[0]), Util.parseNumber(args[1]))); // pitch and yaw
} catch (ParseException e) {
errors.add(CommandError.INVALID_ARGUMENT);
sender.sendMessage(Util.formatErrors(errors));
return;
}
} else {
light.getData().getRingMovementData().setPitchYaw(Location.getFromBukkitLocation(player.getLocation().add(0, 1, 0)));
}
light.buildLasers();
light.on(new Color(0x000000));
}

@Subcommand("distance")
@CommandAlias("d")
@Description("Alter distance")
@CommandPermission("nightclub.light")
public static void onModifyDistance(CommandSender sender, String[] args) {
List<CommandError> errors = isUnloaded(args, 1);
try {
light.getData().getRingMovementData().setDistance(Util.parseNumber(args[0]).doubleValue());
} catch (ParseException e) {
errors.add(CommandError.INVALID_ARGUMENT);
}
if (errors.stream().anyMatch(error -> error != CommandError.VALID)) {
sender.sendMessage(Util.formatErrors(errors));
return;
}
light.buildLasers();
light.on(new Color(0x0066ff));
}

@Subcommand("time")
@CommandAlias("t")
@Description("Alter time to move")
@CommandPermission("nightclub.light")
public static void onModifyTime(CommandSender sender, String[] args) {
List<CommandError> errors = isUnloaded(args, 1);
try {
light.getData().getRingMovementData().setDuration(Util.parseNumber(args[0]).doubleValue());
} catch (ParseException e) {
errors.add(CommandError.INVALID_ARGUMENT);
}
if (errors.stream().anyMatch(error -> error != CommandError.VALID)) {
sender.sendMessage(Util.formatErrors(errors));
return;
}
light.buildLasers();
light.on(new Color(0x0066ff));
}
}
}


@Subcommand("control")
@CommandAlias("c")
@Description("Control a light, for example, turn it on or off")
Expand Down Expand Up @@ -599,6 +678,5 @@ public static void onFlashOff(CommandSender sender) {
}
light.flashOff(new Color(0x0066ff));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import exposed.hydrogen.nightclub.Nightclub;
import exposed.hydrogen.nightclub.light.Light;
import exposed.hydrogen.nightclub.light.LightUniverse;
import exposed.hydrogen.nightclub.light.LightUniverseManager;
import exposed.hydrogen.nightclub.light.event.LightChannel;
Expand Down Expand Up @@ -215,5 +216,24 @@ public static void onFlashOff(CommandSender sender, String[] args) {
sender.sendMessage(Util.formatErrors(errors));
}
}

@Subcommand("ringzoom")
@Description("rz")
@CommandPermission("nightclub.lightuniverse")
public static void onRingZoom(CommandSender sender) {
List<CommandError> errors = isUnloaded();
try {
Nightclub.getLightUniverseManager().getLoadedUniverse().getLights().forEach(Light::ringZoom);
} catch (IllegalArgumentException e) {
errors.add(CommandError.INVALID_ARGUMENT);
} catch (ArrayIndexOutOfBoundsException e) {
errors.add(CommandError.TOO_LITTLE_ARGUMENTS);
}
if (errors.stream().anyMatch(error -> error != CommandError.VALID)) {
sender.sendMessage(Util.formatErrors(errors));
}
}


}
}
Loading

0 comments on commit d653a74

Please sign in to comment.