0.5.0 bis

Some world management system with multiverse. Also beginning to use dungeons/gates. Need to build maps to use in dungeons.
This commit is contained in:
unurled 2022-04-07 22:35:01 +02:00
parent 10c66d6fa4
commit 26cf701494
20 changed files with 300 additions and 77 deletions

View file

@ -13,7 +13,6 @@ repositories {
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://papermc.io/repo/repository/maven-public/')
}
@ -48,20 +47,23 @@ repositories {
maven {
url = 'https://repo.citizensnpcs.co/'
}
maven {
url = "https://repo.onarandombox.com/content/groups/public/"
}
mavenCentral()
}
dependencies {
//lombok stuff
// lombok stuff
implementation 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
//mongo stuff
implementation 'org.mongodb:mongodb-driver-sync:4.5.0'
implementation 'org.mongodb:bson:4.5.0'
implementation 'org.mongodb:mongodb-driver-core:4.5.0'
// mongo stuff
implementation 'org.mongodb:mongodb-driver-sync:4.5.1'
implementation 'org.mongodb:bson:4.5.1'
implementation 'org.mongodb:mongodb-driver-core:4.5.1'
implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2'
compileOnly 'io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT'
@ -69,10 +71,11 @@ dependencies {
compileOnly 'net.luckperms:api:5.4'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
compileOnly 'net.essentialsx:EssentialsX:2.19.4'
compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Core:2.0.1'
compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:2.0.1'
compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Core:2.1.0'
compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:2.1.0'
compileOnly 'me.clip:placeholderapi:2.11.1'
compileOnly 'net.citizensnpcs:citizens-main:2.0.29-SNAPSHOT'
compileOnly 'com.onarandombox.multiversecore:Multiverse-Core:4.3.1'
compileOnly fileTree(dir: 'libs', include: '*.jar')
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.18.2-R0.1-SNAPSHOT")
}
@ -103,9 +106,9 @@ tasks {
shadowJar {
dependencies {
include dependency('de.tr7zw:item-nbt-api-plugin:2.9.2')
include dependency('org.mongodb:mongodb-driver-sync:4.5.0')
include dependency('org.mongodb:bson:4.5.0')
include dependency('org.mongodb:mongodb-driver-core:4.5.0')
include dependency('org.mongodb:mongodb-driver-sync:4.5.1')
include dependency('org.mongodb:bson:4.5.1')
include dependency('org.mongodb:mongodb-driver-core:4.5.1')
}
relocate("de.tr7zw.changeme", "gq.unurled.libs.de.tr7zw")
relocate("de.tr7zw", "gq.unurled.libs.de.tr7zw")

View file

@ -22,5 +22,5 @@ Some RPG thing :
- basic isekai manga sort of monster and also high leveled op monster king of something => bosses
- outbreak if gate isn't closed in time
- loots:
- items of different rarities with multiple purpose => medicinal, combat related type, defensive etc...
- items of different rarities with multiple purpose => medicinal, combat related types, defensive etc...
- leveling system for the player

View file

@ -4,4 +4,5 @@
- [ ] make custom abilities (hard coded)
- [ ] make custom mods (hard coded)
- [ ] make gates
- [ ] a map
- [ ] a map
- [ ] a leveling system

View file

@ -39,8 +39,8 @@ public class SpawnEntity implements TabExecutor {
return false;
}
//example command : /entityspawn ZOMBIE "&cHello folks" 50 200
EntityType type = EntityType.valueOf(args[0]);
Entity e = player.getWorld().spawnEntity(player.getLocation(), type, false);
EntityType types = EntityType.valueOf(args[0]);
Entity e = player.getWorld().spawnEntity(player.getLocation(), types, false);
setNameSpacedKeys(e, "<red>Name", 100, 100,0,50,0,100,0,100,0);
e.customName(colorTextComp(args[1]));
e.setCustomNameVisible(true);
@ -50,8 +50,8 @@ public class SpawnEntity implements TabExecutor {
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
List<String> list = new ArrayList<>();
for (EntityType type : EntityType.values()) {
list.add(type.name());
for (EntityType types : EntityType.values()) {
list.add(types.name());
}
return list;
}

View file

@ -1,8 +1,11 @@
package gq.unurled.raxen.components.dungeons;
import gq.unurled.raxen.components.entity.other.RaxenEntity;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import static gq.unurled.raxen.utils.DungeonUtils.getRadiusFromRank;
@ -15,18 +18,20 @@ public class Dungeon {
private Gate gate;
private Map<UUID, RaxenEntity> monster = new HashMap();
/**
* The Type of the Dungeon
*/
private Type type;
private Types types;
private Location location;
private Integer radius;
public Dungeon(UUID uuid, Rank rank, Type type) {
public Dungeon(UUID uuid, Rank rank, Types types) {
this.uuid = uuid;
this.rank = rank;
this.type = type;
this.types = types;
}
/**
@ -34,13 +39,20 @@ public class Dungeon {
* TODO: Place the gate at a random place.
*/
public void generateGate() {
// -281.50 36.00 187.50 0.90 10.80
Location loc = new Location(Bukkit.getWorld("Liberty_City"), -284.0, 36.00, 187.50);
// -281.50 36.00 187.50
Location loc = new Location(Bukkit.getWorld("Liberty_City"), -284.0, 45.00, 187.50);
Integer radius = getRadiusFromRank(this.rank);
this.gate = new Gate(uuid, loc, radius);
}
/**
* TODO: Terrain Generation of the inside of the Dungeons
*/
public void generate() {
genMonster();
}
public void genMonster() {
}
}

View file

@ -1,7 +1,9 @@
package gq.unurled.raxen.components.dungeons;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.Random;
import java.util.UUID;
public class Gate {
@ -23,6 +25,42 @@ public class Gate {
}
public void genGate() {
// get which side it's gonna expand with radius
Random r = new Random();
Boolean xExpend = false;
if (r.nextInt(2) == 0) {
xExpend = true;
}
// place blocks
for (double i = 0; i <= Math.PI; i += Math.PI / portalRadius) {
double radius = Math.sin(i);
double y = Math.cos(i);
for (double a = 0; a < Math.PI * 2; a+= Math.PI / portalRadius) {
double x = Math.cos(a) * radius;
double z = Math.sin(a) * radius;
Location locc = new Location(loc.getWorld(), x, y, z);
loc.getBlock().setType(Material.NETHER_PORTAL);
}
}
/*
for (int n=0; n<portalRadius ; n++) {
Double x = loc.getX();
Double y = loc.getY();
Double z = loc.getZ();
if (xExpend) {
Location locc = new Location(loc.getWorld(), x + n, y + n, z);
locc.getBlock().setType(Material.NETHER_PORTAL);
locc = new Location(loc.getWorld(), loc.getX() - n, y-n, z);
locc.getBlock().setType(Material.NETHER_PORTAL);
}
}
*/
}
public Location getLoc() {
return loc;

View file

@ -1,20 +1,19 @@
package gq.unurled.raxen.components.dungeons;
public enum Type {
JUNGLE,
TROPICAL_JUNGLE,
PLAINS,
GRAVES,
CASTLE,
ABANDONED_CASTLE,
FIELD,
ICE_FOREST,
FOREST,
VOLCANO,
MOUNTAINS,
HIGH_MOUNTAINS,
CAVES,
LABYRINTH,
UNDERGROUND_LABYRINTH,
FOREST_LABYRINTH
import gq.unurled.raxen.components.entity.other.RaxenEntity;
import gq.unurled.raxen.components.lootchest.loots.LootItem;
import java.util.HashMap;
import java.util.Map;
public class Type {
public String name;
public Map<String, RaxenEntity> monster = new HashMap<>();
public Map<String, LootItem> lootItem = new HashMap<>();
// public Map<String, > chest
}

View file

@ -0,0 +1,20 @@
package gq.unurled.raxen.components.dungeons;
public enum Types {
JUNGLE,
TROPICAL_JUNGLE,
PLAINS,
GRAVES,
CASTLE,
ABANDONED_CASTLE,
FIELD,
ICE_FOREST,
FOREST,
VOLCANO,
MOUNTAINS,
HIGH_MOUNTAINS,
CAVES,
LABYRINTH,
UNDERGROUND_LABYRINTH,
FOREST_LABYRINTH
}

View file

@ -0,0 +1,69 @@
package gq.unurled.raxen.components.dungeons;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import gq.unurled.raxen.Raxen;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static gq.unurled.raxen.utils.Utils.*;
public class WorldManagement {
private Raxen main;
MVWorldManager worldManager;
/**
* String : name
* MultiverseWorld : a world that need to be registered
*/
private Map<String, MultiverseWorld> loadedWorlds = new HashMap<>();
private List<String> worlds = new ArrayList<>();
private File pluginFolder;
private File worldFolder;
public WorldManagement(Raxen main) {
this.main = main;
this.pluginFolder = new File(main.getDataFolder() + "/worlds/");
this.worldFolder = new File("worlds/");
this.worldManager = main.getManager().getMultiverse().getWorldManager();
worlds.add("Forest");
log(pluginFolder.getAbsolutePath(), "" + pluginFolder.isDirectory());
log(worldFolder.getAbsolutePath(), "" + worldFolder.isDirectory());
}
public void load() {
if (!pluginFolder.exists()) {
pluginFolder.mkdirs();
error("Please put in the folder " + pluginFolder.getAbsolutePath() + " all the needed worlds :");
for (String s : worlds) {
error(" - " + s + ",");
}
}
}
public void loadWorld(String name) {
File world = new File(pluginFolder + name + "/");
if (!world.exists() || !world.isDirectory()) {
error("Loading world " + name + ". Folder don't exists.");
}
File newWorld = new File(worldFolder + name);
try {
copyDirectory(world.getAbsolutePath(), newWorld.getAbsolutePath());
} catch (IOException e) {
error("Error while Loading world " + name + " at coping data.");
e.printStackTrace();
}
worldManager.loadWorld(name);
}
}

View file

@ -0,0 +1,6 @@
package gq.unurled.raxen.components.dungeons.types.forest;
public enum ForestMonster {
ELF,
WOLF
}

View file

@ -15,16 +15,15 @@ public class RaxenEntity {
private final Raxen main;
@Getter
private final String name;
@Getter
private Integer level;
@Getter
@Setter
private Double health;
@Getter
@Setter
private Double strength;
@Getter private final String name;
@Getter private Integer level;
@Getter @Setter private Double health;
@Getter @Setter private Double strength;
@Getter @Setter Boolean isAlive = false;
public RaxenEntity(Raxen main, String name, Integer level, Double health, Double strength) {
this.main = main;
@ -34,8 +33,8 @@ public class RaxenEntity {
this.strength = strength;
}
public Entity createEntity(EntityType type, String name, Location location) {
Entity e = location.getWorld().spawnEntity(location, type);
public Entity createEntity(EntityType types, String name, Location location) {
Entity e = location.getWorld().spawnEntity(location, types);
e.setCustomNameVisible(true);
e.customName(Component.text(name));

View file

@ -23,6 +23,8 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.ArrayList;
@ -32,7 +34,6 @@ import java.util.List;
import static gq.unurled.raxen.utils.Items.listItemStackDeserilize;
import static gq.unurled.raxen.utils.Items.setItemsToInventory;
import static gq.unurled.raxen.utils.Utils.debug;
import static gq.unurled.raxen.utils.Utils.warn;
public class PlayerConfig {
@ -44,7 +45,7 @@ public class PlayerConfig {
private Attributes attributes;
public PlayerConfig(Raxen main) {
PlayerConfig.main = main;
this.main = main;
sto = main.getManager().getStorageManager();
this.mongoDB = main.getManager().getLibsManager().getMongoDB();
this.mongoCollection = mongoDB.getMongoCollection();
@ -56,7 +57,7 @@ public class PlayerConfig {
mongoDB.close();
}
public void saveUsingMongoDB(Player player, Attributes attributes, String invstr, Integer reverse) {
public void saveUsingMongoDB(@NotNull Player player, Attributes attributes, String invstr, Integer reverse) {
debug(main, "Saving " + player.getName() + "'s data!");
Document doc = new Document("uuid", player.getUniqueId().toString())
.append("name", player.getName())
@ -125,7 +126,7 @@ public class PlayerConfig {
}
}
public void loadUsingMongoDB(Player player) {
public void loadUsingMongoDB(@NotNull Player player) {
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
if(playerDoc == null) {
debug(main, "Intiatilising Data for Player: " + player.getName());
@ -182,7 +183,7 @@ public class PlayerConfig {
playerManager.getRaxenPlayer(player).setInventory(inv);
}
public void savePlayerConfig(Player player) {
public void savePlayerConfig(@NotNull Player player) {
Attributes attributes = new Attributes(main);
Inventory inv = player.getInventory();
List<String> listInv = new ArrayList<String>();
@ -200,10 +201,24 @@ public class PlayerConfig {
}
debug(main, "saving...");
String storage = sto.getConfig().getString("storage");
saveUsingMongoDB(player, attributes, invstr, reverse);
Integer finalReverse = reverse;
String finalInvstr = invstr;
new BukkitRunnable() {
@Override
public void run() {
saveUsingMongoDB(player, attributes, finalInvstr, finalReverse);
}
}.runTaskAsynchronously(main);
debug(main, "using mongo");
if (storage == "MYSQL" || storage == "YML") {
saveUsingYml(player, attributes, invstr, reverse);
String finalInvstr1 = invstr;
Integer finalReverse1 = reverse;
new BukkitRunnable() {
@Override
public void run() {
saveUsingYml(player, attributes, finalInvstr1, finalReverse1);
}
}.runTaskAsynchronously(main);
debug(main, "using yml");
}
@ -214,18 +229,25 @@ public class PlayerConfig {
String st = StorageManager.getConfig().getString("storage");
String value = "";
if (st.equals("MONGODB")) {
loadUsingMongoDB(player);
new BukkitRunnable() {
@Override
public void run() {
loadUsingMongoDB(player);
}
}.runTaskAsynchronously(main);
value = "mongodb";
warn(main, "'" + st + "'");
}
else {
warn(main, "'" + st + "'");
} else {
value = "yml";
try {
loadUsingYml(player);
} catch (IOException e) {
e.printStackTrace();
}
new BukkitRunnable() {
@Override
public void run() {
try {
loadUsingYml(player);
} catch (IOException e) {
e.printStackTrace();
}
}
}.runTaskAsynchronously(main);
}
debug(main, "Player: " + player.getName() + " data successfully loaded using " + value);
}

View file

@ -3,6 +3,7 @@ package gq.unurled.raxen.manager;
import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.manager.entity.*;
import gq.unurled.raxen.manager.server.*;
import gq.unurled.raxen.utils.libs.Multiverse;
import lombok.Getter;
public class Manager {
@ -28,6 +29,8 @@ public class Manager {
@Getter
private LibsManager libsManager;
@Getter private Multiverse multiverse;
public void set(Raxen main) {
libsManager = new LibsManager(main);
@ -42,5 +45,6 @@ public class Manager {
resourcePackManager = new ResourcePackManager(main);
entityManager = new EntityManager(main);
lootManager = new LootManager(main);
multiverse = new Multiverse();
}
}

View file

@ -69,8 +69,4 @@ public class WorldManager {
worlds.put(world.getName(), world);
return world;
}
public World getWorld(String name) {
return Bukkit.getWorld(name);
}
}

View file

@ -1,10 +1,14 @@
package gq.unurled.raxen.utils;
import gq.unurled.raxen.components.dungeons.Rank;
import gq.unurled.raxen.components.dungeons.Types;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
public class DungeonUtils {
public static Integer getRadiusFromRank(Rank rank) {
public static Integer getRadiusFromRank(@NotNull Rank rank) {
Integer radius = 1;
switch (rank) {
case F:
@ -34,4 +38,9 @@ public class DungeonUtils {
}
return radius;
}
public static void fromTypeToMonster(Types types, Rank rank) {
Random r = new Random();
r.nextInt();
}
}

View file

@ -204,7 +204,7 @@ public class Items {
}
}
catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
throw new IOException("Unable to decode class types.", e);
}
}

View file

@ -18,6 +18,11 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Utils {
/**
@ -208,6 +213,17 @@ public class Utils {
return colorComp("<red>An Error has occurred. Please retry or contact an Admin.");
}
public static void copyDirectory(String sourceDirectoryLocation, String destinationDirectoryLocation) throws IOException {
Files.walk(Paths.get(sourceDirectoryLocation))
.forEach(source -> {
Path destination = Paths.get(destinationDirectoryLocation, source.toString()
.substring(sourceDirectoryLocation.length()));
try {
Files.copy(source, destination);
} catch (IOException e) {
e.printStackTrace();
}
});
}
}

View file

@ -0,0 +1,24 @@
package gq.unurled.raxen.utils.libs;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import org.bukkit.Bukkit;
public class Multiverse {
private MultiverseCore core;
private MVWorldManager worldManager;
public Multiverse() {
this.worldManager = core.getMVWorldManager();
this.core = (MultiverseCore) Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core");
}
public MVWorldManager getWorldManager() {
return worldManager;
}
public MultiverseCore getMultiverseCore() {
return core;
}
}

View file

@ -11,4 +11,9 @@
useResourcePack: false
resource_pack_url: "https://mc-packs.net/" # recommend to use https://mc-packs.net/ => free resource pack hoster (will eventually develop one myself but not atm)
resource_pack_sha1: "sha1hallo" # sha1 hash
debug: true
worlds:
forest:
enabled: true
debug: false

View file

@ -3,7 +3,7 @@ version: '${version}'
main: gq.unurled.raxen.Raxen
author: unurled
api-version: 1.18
depend: [ProtocolLib, PlaceholderAPI]
depend: [ProtocolLib, PlaceholderAPI, 'Multiverse-Core']
softdepend: [AureliumSkills, LuckPerms]
commands: