0.5.1
This commit is contained in:
parent
0d910d3baf
commit
bfa7c94a8f
16 changed files with 143 additions and 127 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@
|
|||
.project
|
||||
api/
|
||||
*.iml
|
||||
worlds/
|
||||
|
||||
.gradle/
|
||||
gradle.properties
|
||||
|
|
|
@ -81,7 +81,7 @@ dependencies {
|
|||
}
|
||||
|
||||
group = 'gq.unurled'
|
||||
version = '0.4.9'
|
||||
version = '0.5.1'
|
||||
description = 'Raxen'
|
||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public final class Raxen extends JavaPlugin {
|
|||
|
||||
private static final String prefix = "<aqua>Rx</aqua><light_purple>></light_purple> ";
|
||||
@Getter
|
||||
private static String version = "0.4.9";
|
||||
private static String version = "0.5.1";
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
private static Raxen plugin;
|
||||
|
|
|
@ -2,48 +2,45 @@ package gq.unurled.raxen.components.dungeons;
|
|||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.dungeons.types.MonsterType;
|
||||
import gq.unurled.raxen.components.dungeons.types.forest.ForestMonster;
|
||||
import gq.unurled.raxen.components.entity.other.RaxenEntity;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static gq.unurled.raxen.utils.DungeonUtils.getRadiusFromRank;
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
|
||||
public class Dungeon {
|
||||
|
||||
private String name;
|
||||
@Getter private String name;
|
||||
|
||||
private Rank rank;
|
||||
@Getter private Rank rank;
|
||||
|
||||
private Gate gate;
|
||||
@Getter private Gate gate;
|
||||
|
||||
private Map<String, RaxenEntity> monster = new HashMap();
|
||||
@Getter private Map<String, RaxenEntity> monster = new HashMap();
|
||||
|
||||
/**
|
||||
* The Type of the Dungeon
|
||||
*/
|
||||
private Types types;
|
||||
@Getter private Types types;
|
||||
|
||||
/**
|
||||
* Monster Types
|
||||
*/
|
||||
private MonsterType monsterType;
|
||||
@Getter private MonsterType monsterType;
|
||||
|
||||
private Location location;
|
||||
private Integer radius;
|
||||
@Getter private Location location;
|
||||
@Getter private Integer radius;
|
||||
|
||||
public Dungeon(String name, Rank rank, Types types, MonsterType mType) {
|
||||
this.name = name;
|
||||
this.rank = rank;
|
||||
this.types = types;
|
||||
this.monsterType = mType;
|
||||
generateGate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
|||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Gate {
|
||||
|
||||
|
|
|
@ -1,21 +1,34 @@
|
|||
package gq.unurled.raxen.components.dungeons.types;
|
||||
|
||||
import gq.unurled.raxen.components.dungeons.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface MonsterType {
|
||||
import java.util.Random;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class MonsterType {
|
||||
public enum type {;
|
||||
|
||||
private Double rate;
|
||||
public String ID;
|
||||
public Class clazz;
|
||||
|
||||
type(Double rate, String ID, Class clazz) {
|
||||
this.rate = rate;
|
||||
this.ID = ID;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public static type getTypeById(String ID) {
|
||||
public static @Nullable type getTypeById(String ID) {
|
||||
for (type type : type.values()) {
|
||||
if(type.ID.equals(ID)) {
|
||||
return type;
|
||||
|
@ -31,6 +44,7 @@ public interface MonsterType {
|
|||
public void setRate(Double rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
@ -38,7 +52,43 @@ public interface MonsterType {
|
|||
public void setID(String ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
|
||||
public Class getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public void getClazz(Class clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
}
|
||||
|
||||
void genMonster(World world, Rank rank);
|
||||
public void genMonster(World world, Rank rank) {
|
||||
Double x = 0.0;
|
||||
Double y = 100.0;
|
||||
Double z = 0.0;
|
||||
for (type type : type.values()) {
|
||||
type.name();
|
||||
Random r = new Random();
|
||||
int per = r.nextInt(100);
|
||||
if (per >= type.rate) {
|
||||
// spawn entity
|
||||
debug("Spawning Entity " + type.ID);
|
||||
Entity e = world.spawnEntity(new Location(world, x, y, z), EntityType.ARROW);
|
||||
// e = ((RaxenEntity) type.getClazz()).createEntity();
|
||||
e.setInvulnerable(true);
|
||||
BukkitTask task = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Location loc = new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY()-1, e.getLocation().getZ());
|
||||
if (loc.getBlock().getType() != Material.AIR) {
|
||||
e.setInvulnerable(false);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(Bukkit.getPluginManager().getPlugin("Raxen"), 0L, 20L);
|
||||
}
|
||||
x = 5.0 + ( 50.0 - 5.0 ) * r.nextDouble();
|
||||
z = 5.0 + ( 50.0 - 5.0 ) * r.nextDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package gq.unurled.raxen.components.dungeons.types.forest;
|
||||
|
||||
import gq.unurled.raxen.components.dungeons.Dungeon;
|
||||
import gq.unurled.raxen.components.dungeons.Rank;
|
||||
import gq.unurled.raxen.components.dungeons.Types;
|
||||
import gq.unurled.raxen.components.dungeons.types.MonsterType;
|
||||
|
||||
public class ForestDungeon extends Dungeon {
|
||||
public ForestDungeon(String name, Rank rank, Types types, MonsterType mType) {
|
||||
super(name, rank, types, mType);
|
||||
}
|
||||
|
||||
public ForestDungeon() {
|
||||
super("Forest", Rank.E, Types.FOREST, new ForestMonster());
|
||||
}
|
||||
}
|
|
@ -1,60 +1,13 @@
|
|||
package gq.unurled.raxen.components.dungeons.types.forest;
|
||||
|
||||
import gq.unurled.raxen.components.dungeons.Rank;
|
||||
import gq.unurled.raxen.components.dungeons.types.MonsterType;
|
||||
import gq.unurled.raxen.components.entity.other.custom.dungeon.forest.Elf;
|
||||
import gq.unurled.raxen.components.entity.other.custom.dungeon.forest.Wolf;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
public class ForestMonster extends MonsterType {
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
import static org.apache.commons.lang.math.RandomUtils.nextInt;
|
||||
|
||||
public class ForestMonster implements MonsterType {
|
||||
@Override
|
||||
public void genMonster(World world, Rank rank) {
|
||||
Double x = 0.0;
|
||||
Double y = 100.0;
|
||||
Double z = 0.0;
|
||||
for (type type : type.values()) {
|
||||
type.name();
|
||||
Random r = new Random();
|
||||
int per = r.nextInt(100);
|
||||
if (per >= type.rate) {
|
||||
// spawn entity
|
||||
debug("Spawning Entity " + type.ID);
|
||||
Entity e = world.spawnEntity(new Location(world, x, y, z), EntityType.ARROW);
|
||||
e.setInvulnerable(true);
|
||||
BukkitTask task = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Location loc = new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY()-1, e.getLocation().getZ());
|
||||
if (loc.getBlock().getType() != Material.AIR) {
|
||||
e.setInvulnerable(false);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(Bukkit.getPluginManager().getPlugin("Raxen"), 0L, 20L);
|
||||
}
|
||||
x = 5.0 + ( 50.0 - 5.0 ) * r.nextDouble();
|
||||
z = 5.0 + ( 50.0 - 5.0 ) * r.nextDouble();
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
enum type {
|
||||
@Getter enum type {
|
||||
ELF(50.0 ,"ELF", Elf.class),
|
||||
WOLF(50.0, "WOLF", Wolf.class);
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ import org.bukkit.entity.EntityType;
|
|||
|
||||
public class Elf extends RaxenEntity {
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
@Getter private final String name;
|
||||
|
||||
public Elf(Raxen main, String name, Integer level, Double health, Double strength) {
|
||||
super(main, name, level, health, strength);
|
||||
|
|
|
@ -9,8 +9,7 @@ import org.bukkit.entity.EntityType;
|
|||
|
||||
public class Wolf extends RaxenEntity {
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
@Getter private final String name;
|
||||
|
||||
|
||||
public Wolf(Raxen main, String name, Integer level, Double health, Double strength) {
|
||||
|
|
|
@ -28,11 +28,13 @@ public class Manager {
|
|||
private LootManager lootManager;
|
||||
@Getter
|
||||
private LibsManager libsManager;
|
||||
@Getter private DungeonsManager dungeonsManager;
|
||||
|
||||
@Getter private Multiverse multiverse;
|
||||
|
||||
public void set(Raxen main) {
|
||||
libsManager = new LibsManager(main);
|
||||
multiverse = new Multiverse();
|
||||
|
||||
worldManager = new WorldManager(main);
|
||||
storageManager = new StorageManager(main);
|
||||
|
@ -45,6 +47,6 @@ public class Manager {
|
|||
resourcePackManager = new ResourcePackManager(main);
|
||||
entityManager = new EntityManager(main);
|
||||
lootManager = new LootManager(main);
|
||||
multiverse = new Multiverse();
|
||||
dungeonsManager = new DungeonsManager(main);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,49 +32,7 @@ public class ItemManager {
|
|||
|
||||
public ItemManager(Raxen main) {
|
||||
this.main = main;
|
||||
register();
|
||||
}
|
||||
|
||||
private void example() {
|
||||
File customFile;
|
||||
FileConfiguration customConfig;
|
||||
customFile = new File(main.getDataFolder() + "/Items/", "/example.yml");
|
||||
|
||||
if (!customFile.exists()) {
|
||||
customFile.getParentFile().mkdirs();
|
||||
try {
|
||||
customFile.createNewFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Item Manager saving new File.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
customConfig = new YamlConfiguration();
|
||||
try {
|
||||
customConfig.load(customFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("<red>super lore wahou");
|
||||
if (customConfig.get("name") == null) {
|
||||
customConfig.set("id", "minecraft_id_of_item");
|
||||
customConfig.set("customId", "id_of_item_used_to_identify_it");
|
||||
customConfig.set("name", "<red>Name of the Item");
|
||||
customConfig.set("health", 100);
|
||||
customConfig.set("defense", 50);
|
||||
customConfig.set("speed", 100);
|
||||
customConfig.set("strength", 100);
|
||||
customConfig.set("custom_ability","fireball");
|
||||
customConfig.set("custom_model_data", 123);
|
||||
customConfig.set("lore",lore);
|
||||
try {
|
||||
customConfig.save(customFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// register();
|
||||
}
|
||||
|
||||
private void register() {
|
||||
|
|
|
@ -1,11 +1,32 @@
|
|||
package gq.unurled.raxen.manager.server;
|
||||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.dungeons.Dungeon;
|
||||
import gq.unurled.raxen.components.dungeons.Gate;
|
||||
import gq.unurled.raxen.components.dungeons.types.forest.ForestDungeon;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DungeonsManager {
|
||||
|
||||
private Raxen main;
|
||||
|
||||
private HashMap<UUID, Gate> gates = new HashMap<>();
|
||||
|
||||
private HashMap<String, Dungeon> dungeons = new HashMap<>();
|
||||
|
||||
public DungeonsManager(Raxen main) {
|
||||
this.main = main;
|
||||
registerDungeons();
|
||||
}
|
||||
|
||||
public void registerDungeons() {
|
||||
ForestDungeon forestDungeon = new ForestDungeon();
|
||||
dungeons.put("FOREST", forestDungeon);
|
||||
|
||||
for (String s : dungeons.keySet()) {
|
||||
main.getManager().getWorldManager().loadWorld(dungeons.get(s).getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,16 @@ package gq.unurled.raxen.manager.server;
|
|||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.*;
|
||||
import static gq.unurled.raxen.utils.Utils.error;
|
||||
|
||||
public class WorldManager {
|
||||
|
||||
|
@ -34,8 +37,6 @@ public class WorldManager {
|
|||
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 removeWorld(String name) {
|
||||
|
@ -82,19 +83,20 @@ public class WorldManager {
|
|||
}
|
||||
|
||||
public void loadWorld(String name) {
|
||||
File world = new File(pluginFolder + name + "/");
|
||||
File world = new File(pluginFolder + "/" + name + "/");
|
||||
if (!world.exists() || !world.isDirectory()) {
|
||||
error("Loading world " + name + ". Folder don't exists.");
|
||||
error("Loading world " + name + ". Folder " + world.getAbsolutePath() + " don't exists.");
|
||||
return;
|
||||
}
|
||||
File newWorld = new File(worldFolder + name);
|
||||
File newWorld = new File(worldFolder + "/" + name);
|
||||
try {
|
||||
log(colorTextComp("<aqua>Copping world " + world.getName() + ".</aqua>"), colorTextComp("<blue>From " + world.getAbsolutePath() + " to " + newWorld.getAbsolutePath() +".</blue>"));
|
||||
copyDirectory(world.getAbsolutePath(), newWorld.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
error("Error while Loading world " + name + " at coping data.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
worldManager.loadWorld(name);
|
||||
worldManager.addWorld(world.getName(), World.Environment.NORMAL, null, null, false, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,10 +18,8 @@ import org.bukkit.inventory.Inventory;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Utils {
|
||||
|
||||
|
@ -84,6 +82,19 @@ public class Utils {
|
|||
.serialize(minimessage.deserialize(string)));
|
||||
}
|
||||
|
||||
public static String textCompToString(TextComponent comp) {
|
||||
MiniMessage minimessage = MiniMessage.builder()
|
||||
.tags(TagResolver.builder()
|
||||
.resolver(StandardTags.color())
|
||||
.resolver(StandardTags.decorations())
|
||||
.resolver(StandardTags.reset())
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
return ChatColor.translateAlternateColorCodes('&', LegacyComponentSerializer.legacyAmpersand()
|
||||
.serialize(comp));
|
||||
}
|
||||
|
||||
public static String decolor(String string) {
|
||||
return MiniMessage.miniMessage().stripTags(string);
|
||||
}
|
||||
|
@ -146,6 +157,14 @@ public class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
public static void log(TextComponent... strings) {
|
||||
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
|
||||
assert main != null;
|
||||
for(TextComponent string : strings) {
|
||||
main.getServer().sendMessage(string);
|
||||
}
|
||||
}
|
||||
|
||||
public static void warn(String... strings) {
|
||||
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
|
||||
assert main != null;
|
||||
|
|
|
@ -10,8 +10,8 @@ public class Multiverse {
|
|||
private MVWorldManager worldManager;
|
||||
|
||||
public Multiverse() {
|
||||
this.worldManager = core.getMVWorldManager();
|
||||
this.core = (MultiverseCore) Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core");
|
||||
this.worldManager = core.getMVWorldManager();
|
||||
}
|
||||
|
||||
public MVWorldManager getWorldManager() {
|
||||
|
|
Loading…
Reference in a new issue