small update
This commit is contained in:
@@ -6,6 +6,7 @@ import java.io.*;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
@@ -21,6 +22,7 @@ public class Config {
|
|||||||
public static boolean advanced_setting_save_respawn_status;
|
public static boolean advanced_setting_save_respawn_status;
|
||||||
public static boolean advanced_setting_save_bossbar;
|
public static boolean advanced_setting_save_bossbar;
|
||||||
public static boolean advanced_setting_glowing_fix;
|
public static boolean advanced_setting_glowing_fix;
|
||||||
|
//public static boolean advanced_setting_can_spawn_not_the_end;
|
||||||
public static boolean advanced_setting_backslash_split_reward;
|
public static boolean advanced_setting_backslash_split_reward;
|
||||||
public static String damage_visible_mode;
|
public static String damage_visible_mode;
|
||||||
public static int damage_statistics_limit;
|
public static int damage_statistics_limit;
|
||||||
@@ -98,10 +100,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
public static void copyFile(String source, String dest,boolean replace) {
|
public static void copyFile(File source, String dest, boolean replace) {
|
||||||
if (source == null || source.equals("")) return;
|
|
||||||
source = source.replace('\\', '/');
|
|
||||||
File inFile = new File("plugins/EnderDragon", source);
|
|
||||||
File outFile = new File("plugins/EnderDragon", dest);
|
File outFile = new File("plugins/EnderDragon", dest);
|
||||||
int lastIndex = dest.lastIndexOf('/');
|
int lastIndex = dest.lastIndexOf('/');
|
||||||
File outDir = new File("plugins/EnderDragon", dest.substring(0, Math.max(lastIndex, 0)));
|
File outDir = new File("plugins/EnderDragon", dest.substring(0, Math.max(lastIndex, 0)));
|
||||||
@@ -110,8 +109,8 @@ public class Config {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!outFile.exists() || replace) {
|
if (!outFile.exists() || replace) {
|
||||||
InputStream in = new FileInputStream(inFile);
|
InputStream in = Files.newInputStream(source.toPath());
|
||||||
OutputStream out = new FileOutputStream(outFile);
|
OutputStream out = Files.newOutputStream(outFile.toPath());
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
int len;
|
int len;
|
||||||
while ((len = in.read(buf)) > 0) {
|
while ((len = in.read(buf)) > 0) {
|
||||||
@@ -121,9 +120,15 @@ public class Config {
|
|||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
Lang.error("Failed to copy file: "+inFile.getPath()+" -> "+outFile.getPath());
|
Lang.error("Failed to copy file: "+source.getPath()+" -> "+outFile.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void copyFile(String source, String dest,boolean replace) {
|
||||||
|
if (source == null || source.equals("")) return;
|
||||||
|
source = source.replace('\\', '/');
|
||||||
|
File inFile = new File("plugins/EnderDragon", source);
|
||||||
|
copyFile(inFile, dest, replace);
|
||||||
|
}
|
||||||
public static void saveDirectoryResource(String srcDirectory,boolean replace) {
|
public static void saveDirectoryResource(String srcDirectory,boolean replace) {
|
||||||
String destDirectory = new File(plugin.getDataFolder(),srcDirectory).getPath();
|
String destDirectory = new File(plugin.getDataFolder(),srcDirectory).getPath();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import java.io.File;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -37,6 +38,8 @@ public class DragonManager {
|
|||||||
static final ArrayList<MyDragon> dragons = new ArrayList<>();
|
static final ArrayList<MyDragon> dragons = new ArrayList<>();
|
||||||
static final Map<String, MyDragon> mp = new HashMap<>();
|
static final Map<String, MyDragon> mp = new HashMap<>();
|
||||||
public static List<String> dragon_names = new ArrayList<>();
|
public static List<String> dragon_names = new ArrayList<>();
|
||||||
|
public static final Map<UUID,DragonInfo> existing_dragon = new ConcurrentHashMap<>();
|
||||||
|
public static final Map<String,DragonInfo> main_dragon = new ConcurrentHashMap<>();
|
||||||
private static int sum = 0;
|
private static int sum = 0;
|
||||||
private static final int[][] nxt = {{3,0},{0,3},{-3,0},{0,-3}};
|
private static final int[][] nxt = {{3,0},{0,3},{-3,0},{0,-3}};
|
||||||
private static final int[][] nxt_2 = {{2,0},{0,2},{-2,0},{0,-2}};
|
private static final int[][] nxt_2 = {{2,0},{0,2},{-2,0},{0,-2}};
|
||||||
@@ -485,6 +488,39 @@ public class DragonManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used to initialize. DON'T use this if speed is essential.
|
||||||
|
* @param world world
|
||||||
|
* @return The dragon found in this world.
|
||||||
|
*/
|
||||||
|
public static EnderDragon getEnderDragon(final World world){
|
||||||
|
if(world.getEnvironment() != World.Environment.THE_END){
|
||||||
|
return world.getEntitiesByClass(EnderDragon.class).iterator().next();
|
||||||
|
}
|
||||||
|
if(Version.mcMainVersion >= 16){
|
||||||
|
DragonBattle battle = world.getEnderDragonBattle();
|
||||||
|
assert battle != null;
|
||||||
|
return battle.getEnderDragon();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Object battle = getEnderDragonBattle(world);
|
||||||
|
assert battle != null;
|
||||||
|
Field k = EnderDragonBattleClass.getDeclaredField("k");
|
||||||
|
k.setAccessible(true);
|
||||||
|
Object dragonKilled = k.get(battle);
|
||||||
|
if((boolean) dragonKilled) return null;
|
||||||
|
Field m = EnderDragonBattleClass.getDeclaredField("m");
|
||||||
|
m.setAccessible(true);
|
||||||
|
Object uuid = m.get(battle);
|
||||||
|
// Field d = EnderDragonBattleClass.getDeclaredField("d");
|
||||||
|
// d.setAccessible(true);
|
||||||
|
// Object worldServer = d.get(battle);
|
||||||
|
return (EnderDragon) Bukkit.getEntity((UUID) uuid);
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static Location getEndPortalLocation(final World world){
|
public static Location getEndPortalLocation(final World world){
|
||||||
if(world == null) return null;
|
if(world == null) return null;
|
||||||
if(world.getEnvironment() != World.Environment.THE_END) return null;
|
if(world.getEnvironment() != World.Environment.THE_END) return null;
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
package pers.xanadu.enderdragon.metadata;
|
package pers.xanadu.enderdragon.metadata;
|
||||||
|
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
|
||||||
public class DragonInfo {
|
public class DragonInfo {
|
||||||
|
private final EnderDragon handle;
|
||||||
public String unique_name;
|
public String unique_name;
|
||||||
public DragonInfo(String unique_name){
|
public DragonInfo(final EnderDragon dragon, String unique_name){
|
||||||
|
this.handle = dragon;
|
||||||
this.unique_name = unique_name;
|
this.unique_name = unique_name;
|
||||||
}
|
}
|
||||||
|
public EnderDragon getHandle(){
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,5 +97,7 @@ advanced_setting:
|
|||||||
world_env_fix: false
|
world_env_fix: false
|
||||||
save_respawn_status: false
|
save_respawn_status: false
|
||||||
save_bossbar: false
|
save_bossbar: false
|
||||||
|
# to do: 允许在非末地环境使用/ed spawn或respawn复活末影龙
|
||||||
|
# can_spawn_not_the_end: false
|
||||||
backslash_split:
|
backslash_split:
|
||||||
reward: false
|
reward: false
|
||||||
@@ -96,5 +96,7 @@ advanced_setting:
|
|||||||
world_env_fix: false
|
world_env_fix: false
|
||||||
save_respawn_status: false
|
save_respawn_status: false
|
||||||
save_bossbar: false
|
save_bossbar: false
|
||||||
|
# to-do
|
||||||
|
# can_spawn_not_the_end: false
|
||||||
backslash_split:
|
backslash_split:
|
||||||
reward: false
|
reward: false
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
name: EnderDragon
|
name: EnderDragon
|
||||||
version: 2.5.0-dev
|
version: 2.5.0
|
||||||
main: pers.xanadu.enderdragon.EnderDragon
|
main: pers.xanadu.enderdragon.EnderDragon
|
||||||
author: Xanadu13
|
author: Xanadu13
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
|||||||
Reference in New Issue
Block a user