0.1.2 prepare for redis support and new control system
This commit is contained in:
parent
d224397c87
commit
b149003e0a
14 changed files with 231 additions and 19 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,7 +7,6 @@
|
|||
|
||||
# IntelliJ
|
||||
out/
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
|
|
23
build.gradle
23
build.gradle
|
@ -5,10 +5,11 @@ plugins {
|
|||
id 'java'
|
||||
id 'io.papermc.paperweight.userdev' version '1.5.5'
|
||||
id 'maven-publish'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
}
|
||||
|
||||
group = 'me.unurled.sacredrealms'
|
||||
version = '0.1.1'
|
||||
version = '0.1.2'
|
||||
def minecraft_version = '1.20.1'
|
||||
|
||||
repositories {
|
||||
|
@ -42,6 +43,9 @@ dependencies {
|
|||
compileOnly ("net.citizensnpcs:citizens-main:2.0.32-SNAPSHOT") {
|
||||
exclude group: '*', module: '*'
|
||||
}
|
||||
|
||||
// Redis
|
||||
implementation "redis.clients:jedis:4.3.1"
|
||||
}
|
||||
|
||||
def targetJavaVersion = 17
|
||||
|
@ -54,6 +58,19 @@ java {
|
|||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveClassifier.set('')
|
||||
}
|
||||
|
||||
tasks {
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
options.release = targetJavaVersion
|
||||
|
@ -97,7 +114,7 @@ def serverDir = file("${project.buildDir}/server")
|
|||
def serverJar = file("${serverDir}/paper-${minecraft_version}.jar")
|
||||
def pluginsDir = file("${serverDir}/plugins")
|
||||
def pluginJar = file("${pluginsDir}/${archivesBaseName}.jar")
|
||||
def buildJar = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
|
||||
def buildJar = file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")
|
||||
def semver = minecraft_version.tokenize('.')
|
||||
|
||||
tasks.register('prepare') {
|
||||
|
@ -133,7 +150,7 @@ tasks.register('start', JavaExec) {
|
|||
|
||||
classpath = files(serverJar)
|
||||
workingDir = serverDir
|
||||
main = 'io.papermc.paperclip.Main'
|
||||
mainClass = 'io.papermc.paperclip.Main'
|
||||
jvmArgs = [ '-Ddisable.watchdog=true', '-Dcom.mojang.eula.agree=true' ]
|
||||
args = [ '--nogui' ]
|
||||
standardInput = System.in
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package me.unurled.sacredrealms.cutscenes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -161,6 +159,21 @@ public class Cutscene {
|
|||
tasks.put(p, task);
|
||||
}
|
||||
|
||||
// TODO: implement correctly isPlaying
|
||||
boolean isPlaying(Player p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: implement correctly clear
|
||||
void clear(Player p) {
|
||||
|
||||
}
|
||||
|
||||
// TODO: implement correctly pause
|
||||
public void pause(Player p) {
|
||||
|
||||
}
|
||||
|
||||
public void stop(Player p) {
|
||||
PersistentDataContainer pdc = p.getPersistentDataContainer();
|
||||
if (pdc.has(PLAYING)) {
|
||||
|
@ -174,7 +187,6 @@ public class Cutscene {
|
|||
pdc.remove(PLAYING);
|
||||
if (tasks.get(p) != null)
|
||||
tasks.get(p).cancel();
|
||||
// TODO: replace player to it's original location
|
||||
Location loc = Cutscenes.getInstance().getOriginalLocation(p);
|
||||
if (loc != null) {
|
||||
p.teleport(loc);
|
||||
|
@ -198,7 +210,7 @@ public class Cutscene {
|
|||
}
|
||||
|
||||
public void calculateMarkers() {
|
||||
if (markers.size() == 0)
|
||||
if (markers.isEmpty())
|
||||
return;
|
||||
for (int i = 0 ; i < markers.size() ; i++) {
|
||||
if (i < markers.size() - 1) {
|
||||
|
|
|
@ -4,7 +4,9 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import me.unurled.sacredrealms.cutscenes.commands.BlockCommand;
|
||||
import me.unurled.sacredrealms.cutscenes.commands.CutsceneCommand;
|
||||
import me.unurled.sacredrealms.cutscenes.commands.NPCCommand;
|
||||
import me.unurled.sacredrealms.cutscenes.parse.CutsceneParser;
|
||||
import me.unurled.sacredrealms.cutscenes.parse.MarkerParser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -28,28 +30,39 @@ public final class Cutscenes extends JavaPlugin {
|
|||
|
||||
private static Logger LOGGER = LoggerFactory.getLogger("Cutscenes");
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
instance = this;
|
||||
|
||||
CutsceneCommand command = new CutsceneCommand();
|
||||
getCommand("cutscenes").setExecutor(command);
|
||||
getCommand("cutscenes").setTabCompleter(command);
|
||||
saveDefaultConfig();
|
||||
|
||||
commands();
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
void commands() {
|
||||
CutsceneCommand cutsceneCommand = new CutsceneCommand();
|
||||
getCommand("cutscenes").setExecutor(cutsceneCommand);
|
||||
getCommand("cutscenes").setTabCompleter(cutsceneCommand);
|
||||
|
||||
NPCCommand npcCommand = new NPCCommand();
|
||||
getCommand("csnpc").setExecutor(npcCommand);
|
||||
getCommand("csnpc").setTabCompleter(npcCommand);
|
||||
|
||||
BlockCommand blockCommand = new BlockCommand();
|
||||
getCommand("csblock").setExecutor(blockCommand);
|
||||
getCommand("csblock").setTabCompleter(blockCommand);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
cutscenes = new ArrayList<>();
|
||||
currentPlayingCutscenes = new HashMap<>();
|
||||
originalLocation = new HashMap<>();
|
||||
cutscenesId = new ArrayList<>();
|
||||
|
||||
// TODO: detect all cutscenes in the cutscenes folder and load them.
|
||||
detectAndParseAllCutscenes();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,6 +146,18 @@ public final class Cutscenes extends JavaPlugin {
|
|||
return currentPlayingCutscenes;
|
||||
}
|
||||
|
||||
// TODO: make it save the changes
|
||||
public void createCutscene(String id) {
|
||||
Cutscene cutscene = new Cutscene(id, id);
|
||||
addCutscene(cutscene);
|
||||
}
|
||||
|
||||
// TODO: make it save the changes
|
||||
public void removeCutscene(String id) {
|
||||
Cutscene cutscene = getCutscene(id);
|
||||
removeCutscene(cutscene);
|
||||
}
|
||||
|
||||
public void addCutscene(Cutscene cutscene) {
|
||||
LOGGER.info("Adding cutscene " + cutscene.getID().toUpperCase() + " to the list of cutscenes!");
|
||||
cutscenes.add(cutscene);
|
||||
|
@ -165,6 +190,14 @@ public final class Cutscenes extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public void pauseCutscenes(Player p) {
|
||||
for (Cutscene cutscene : currentPlayingCutscenes.keySet()) {
|
||||
if (currentPlayingCutscenes.get(cutscene).equals(p)) {
|
||||
cutscene.stop(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopCutscenesForAllPlayers() {
|
||||
for (Cutscene cutscene : currentPlayingCutscenes.keySet()) {
|
||||
cutscene.stop(currentPlayingCutscenes.get(cutscene));
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package me.unurled.sacredrealms.cutscenes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class MarkerInterpolator {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package me.unurled.sacredrealms.cutscenes.commands;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BlockCommand implements TabExecutor {
|
||||
|
||||
// TODO: make it work :shurg:
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender,
|
||||
@NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package me.unurled.sacredrealms.cutscenes.commands;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CameraCommand implements TabExecutor {
|
||||
|
||||
// TODO: make it work :shurg:
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender,
|
||||
@NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
package me.unurled.sacredrealms.cutscenes;
|
||||
package me.unurled.sacredrealms.cutscenes.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.unurled.sacredrealms.cutscenes.Cutscenes;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -60,6 +61,14 @@ public class CutsceneCommand implements TabExecutor {
|
|||
Cutscenes.getInstance().stopCutscene(Bukkit.getPlayer(args[1]));
|
||||
return true;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("create")) {
|
||||
Cutscenes.getInstance().createCutscene(args[1].toUpperCase());
|
||||
sender.sendMessage(Component.text("Created cutscene " + args[1].toUpperCase()).color(TextColor.color(0, 255, 0)));
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||
Cutscenes.getInstance().removeCutscene(args[1].toUpperCase());
|
||||
sender.sendMessage(Component.text("Removed cutscene " + args[1].toUpperCase()).color(TextColor.color(255, 0, 0)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
|
@ -99,6 +108,8 @@ public class CutsceneCommand implements TabExecutor {
|
|||
complete.add("play");
|
||||
complete.add("list");
|
||||
complete.add("reload");
|
||||
complete.add("create");
|
||||
complete.add("remove");
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
|
@ -116,7 +127,7 @@ public class CutsceneCommand implements TabExecutor {
|
|||
result.add(p.getName());
|
||||
}
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("play")) {
|
||||
} else if (args[0].equalsIgnoreCase("play") || args[0].equalsIgnoreCase("remove")) {
|
||||
for (String s : Cutscenes.getInstance().getCutscenesId()) {
|
||||
if (s.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(s);
|
||||
|
@ -138,4 +149,16 @@ public class CutsceneCommand implements TabExecutor {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return """
|
||||
<gold>Cutscene usage:
|
||||
<gray>/cs play <cutscene_id> <player>
|
||||
<gray>/cs stop <player>
|
||||
<gray>/cs list
|
||||
<gray>/cs reload
|
||||
<gray>/cs create <cutscene_id>
|
||||
<gray>/cs remove <cutscene_id>""";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package me.unurled.sacredrealms.cutscenes.commands;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class NPCCommand implements TabExecutor {
|
||||
|
||||
// TODO: make it work :shurg:
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender,
|
||||
@NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package me.unurled.sacredrealms.cutscenes.data;
|
||||
|
||||
import me.unurled.sacredrealms.cutscenes.Cutscenes;
|
||||
import redis.clients.jedis.JedisPooled;
|
||||
|
||||
// TODO: implement redis correctly...
|
||||
/**
|
||||
* RedisHandler
|
||||
* Structure of data retention :
|
||||
* ---
|
||||
* Location = world, x, y, z, yaw, pitch
|
||||
* ---
|
||||
* sr:cs:cutscene_id:property | value
|
||||
* property = name, marker_id, start, end
|
||||
* ---
|
||||
* sr:mk:marker_id:property | value
|
||||
* property = name, cutscene_id, start, [frame_locs], time_between_frames, overall_time
|
||||
*/
|
||||
public class RedisHandler {
|
||||
|
||||
JedisPooled jedis;
|
||||
|
||||
public RedisHandler() {
|
||||
this.jedis = new JedisPooled(
|
||||
Cutscenes.getInstance().getConfig().getString("redis_uri", "localhost"),
|
||||
Cutscenes.getInstance().getConfig().getInt("redis_port", 6379)
|
||||
);
|
||||
}
|
||||
|
||||
public void set(String key, String value) {
|
||||
jedis.set(key, value);
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return jedis.get(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.unurled.sacredrealms.cutscenes.event;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class Quit implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
// TODO: management when player quits (and then joins again)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package me.unurled.sacredrealms.cutscenes.parse;
|
||||
|
||||
import me.unurled.sacredrealms.cutscenes.Cutscenes;
|
||||
import me.unurled.sacredrealms.cutscenes.Frame;
|
||||
import me.unurled.sacredrealms.cutscenes.Marker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
|
2
src/main/resources/config.yml
Normal file
2
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
redis_uri: "localhost"
|
||||
redis_port: 6379
|
|
@ -11,6 +11,10 @@ commands:
|
|||
cutscenes:
|
||||
aliases: cs
|
||||
description: cutscenes command
|
||||
csnpc:
|
||||
description: cutscene npc command
|
||||
csblock:
|
||||
description: cutscene block command
|
||||
|
||||
permissions:
|
||||
cutscenes.admin:
|
||||
|
|
Loading…
Reference in a new issue