mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 01:57:53 +01:00
Merge branch 'v3.0' of git@github-home:webbukkit/dynmap.git into v3.0
This commit is contained in:
commit
0445814ef5
@ -19,7 +19,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['marker'];
|
||||
$path = htmlspecialchars($_REQUEST['marker']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -19,7 +19,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['tile'];
|
||||
$path = htmlspecialchars($_REQUEST['tile']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -19,7 +19,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['marker'];
|
||||
$path = htmlspecialchars($_REQUEST['marker']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -19,7 +19,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['tile'];
|
||||
$path = htmlspecialchars($_REQUEST['tile']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -17,7 +17,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['marker'];
|
||||
$path = htmlspecialchars($_REQUEST['marker']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -17,7 +17,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['tile'];
|
||||
$path = htmlspecialchars($_REQUEST['tile']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -24,7 +24,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['marker'];
|
||||
$path = htmlspecialchars($_REQUEST['marker']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -24,7 +24,7 @@ if (strcmp($userid, '-guest-')) {
|
||||
$loggedin = true;
|
||||
}
|
||||
|
||||
$path = $_REQUEST['tile'];
|
||||
$path = htmlspecialchars($_REQUEST['tile']);
|
||||
if ((!isset($path)) || strstr($path, "..")) {
|
||||
header('HTTP/1.0 500 Error');
|
||||
echo "<h1>500 Error</h1>";
|
||||
|
@ -93,6 +93,9 @@ public class AsyncChunkProvider118_2 {
|
||||
}
|
||||
//prepare data synchronously
|
||||
CompletableFuture<?> future = CompletableFuture.supplyAsync(() -> {
|
||||
//Null will mean that we save with spigot methods, which may be risky on async
|
||||
//Since we're not in main thread, it now refuses new tasks because of shutdown, the risk is lower
|
||||
if (!Bukkit.isPrimaryThread()) return null;
|
||||
try {
|
||||
return getAsyncSaveData.invoke(null, world.getHandle(), c);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
@ -103,15 +106,21 @@ public class AsyncChunkProvider118_2 {
|
||||
if (++currChunks > MapManager.mapman.getMaxChunkLoadsPerTick()) {
|
||||
try {
|
||||
Thread.sleep(25); //hold the lock so other threads also won't stress main thread
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
//save data asynchronously
|
||||
return () -> {
|
||||
Object o = null;
|
||||
try {
|
||||
return (NBTTagCompound) save.invoke(null, world.getHandle(), c, future.get());
|
||||
} catch (ReflectiveOperationException | ExecutionException | InterruptedException e) {
|
||||
o = future.get();
|
||||
return (NBTTagCompound) save.invoke(null, world.getHandle(), c, o);
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
//We tried to use simple spigot methods at shutdown and failed, hopes for reading from disk
|
||||
if (o == null) return null;
|
||||
throw new RuntimeException(e);
|
||||
} catch (ReflectiveOperationException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -61,7 +61,14 @@ public class MapChunkCache118_2 extends GenericMapChunkCache {
|
||||
try {
|
||||
CompletableFuture<NBTTagCompound> nbt = provider.getChunk(((CraftWorld) w).getHandle(), chunk.x, chunk.z);
|
||||
return () -> {
|
||||
NBTTagCompound compound = nbt.join();
|
||||
NBTTagCompound compound;
|
||||
try {
|
||||
compound = nbt.get();
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return compound == null ? null : parseChunkFromNBT(new NBT.NBTCompound(compound));
|
||||
};
|
||||
} catch (InvocationTargetException | IllegalAccessException ignored) {
|
||||
|
@ -92,6 +92,9 @@ public class AsyncChunkProvider119 {
|
||||
}
|
||||
//prepare data synchronously
|
||||
CompletableFuture<?> future = CompletableFuture.supplyAsync(() -> {
|
||||
//Null will mean that we save with spigot methods, which may be risky on async
|
||||
//Since we're not in main thread, it now refuses new tasks because of shutdown, the risk is lower
|
||||
if (!Bukkit.isPrimaryThread()) return null;
|
||||
try {
|
||||
return getAsyncSaveData.invoke(null, world.getHandle(), c);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
@ -102,15 +105,21 @@ public class AsyncChunkProvider119 {
|
||||
if (++currChunks > MapManager.mapman.getMaxChunkLoadsPerTick()) {
|
||||
try {
|
||||
Thread.sleep(25); //hold the lock so other threads also won't stress main thread
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
//save data asynchronously
|
||||
return () -> {
|
||||
Object o = null;
|
||||
try {
|
||||
return (NBTTagCompound) save.invoke(null, world.getHandle(), c, future.get());
|
||||
} catch (ReflectiveOperationException | ExecutionException | InterruptedException e) {
|
||||
o = future.get();
|
||||
return (NBTTagCompound) save.invoke(null, world.getHandle(), c, o);
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
//We tried to use simple spigot methods at shutdown and failed, hopes for reading from disk
|
||||
if (o == null) return null;
|
||||
throw new RuntimeException(e);
|
||||
} catch (ReflectiveOperationException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -58,7 +59,14 @@ public class MapChunkCache119 extends GenericMapChunkCache {
|
||||
try {
|
||||
CompletableFuture<NBTTagCompound> nbt = provider.getChunk(((CraftWorld) w).getHandle(), chunk.x, chunk.z);
|
||||
return () -> {
|
||||
NBTTagCompound compound = nbt.join();
|
||||
NBTTagCompound compound;
|
||||
try {
|
||||
compound = nbt.get();
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return compound == null ? null : parseChunkFromNBT(new NBT.NBTCompound(compound));
|
||||
};
|
||||
} catch (InvocationTargetException | IllegalAccessException ignored) {
|
||||
|
@ -11,6 +11,6 @@ description = 'bukkit-helper'
|
||||
dependencies {
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version:'1.7.10-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version:'1.10.2-R0.1-SNAPSHOT'
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version:'2.8.9'
|
||||
}
|
||||
|
@ -28,6 +28,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.12",
|
||||
"fabric": ">=0.17.0",
|
||||
"minecraft": "1.16.x"
|
||||
"minecraft": ["1.16.4", "1.16.5"]
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.13.3",
|
||||
"fabric": ">=0.47.8",
|
||||
"minecraft": ">=1.18.2"
|
||||
"minecraft": "1.18.2"
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.8",
|
||||
"fabric": ">=0.58.5",
|
||||
"minecraft": ">=1.19.1"
|
||||
"minecraft": ["1.19.1", "1.19.2"]
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.6",
|
||||
"fabric": ">=0.55.2",
|
||||
"minecraft": "1.19.x"
|
||||
"minecraft": "1.19"
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version: '1.7.10-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version: '1.10.2-R0.1-SNAPSHOT'
|
||||
implementation 'com.nijikokun.bukkit:Permissions:3.1.6'
|
||||
implementation 'me.lucko.luckperms:luckperms-api:4.3'
|
||||
implementation 'net.luckperms:api:5.0'
|
||||
implementation('com.github.MilkBowl:VaultAPI:1.7') { transitive = false }
|
||||
compileOnly 'net.skinsrestorer:skinsrestorer-api:14.1.+'
|
||||
compileOnly 'net.skinsrestorer:skinsrestorer-api:14.2.+'
|
||||
implementation project(":dynmap-api")
|
||||
implementation project(path: ":DynmapCore", configuration: "shadow")
|
||||
implementation group: 'ru.tehkode', name: 'PermissionsEx', version: '1.19.1'
|
||||
|
@ -1,43 +0,0 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class Armor {
|
||||
/**
|
||||
* http://www.minecraftwiki.net/wiki/Item_Durability#Armor_durability
|
||||
* We rely on getArmorContents() to return 4 armor pieces in the order
|
||||
* of: boots, pants, chest, helmet
|
||||
*/
|
||||
private static final int armorPoints[] = {3, 6, 8, 3};
|
||||
|
||||
public static final int getArmorPoints(Player player) {
|
||||
int currentDurability = 0;
|
||||
int baseDurability = 0;
|
||||
int baseArmorPoints = 0;
|
||||
ItemStack[] itm = new ItemStack[4];
|
||||
PlayerInventory inv = player.getInventory();
|
||||
itm[0] = inv.getBoots();
|
||||
itm[1]= inv.getLeggings();
|
||||
itm[2] = inv.getChestplate();
|
||||
itm[3] = inv.getHelmet();
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(itm[i] == null) continue;
|
||||
int dur = itm[i].getDurability();
|
||||
int max = itm[i].getType().getMaxDurability();
|
||||
if(max <= 0) continue;
|
||||
if(i == 2)
|
||||
max = max + 1; /* Always 1 too low for chestplate */
|
||||
else
|
||||
max = max - 3; /* Always 3 too high, versus how client calculates it */
|
||||
baseDurability += max;
|
||||
currentDurability += max - dur;
|
||||
baseArmorPoints += armorPoints[i];
|
||||
}
|
||||
int ap = 0;
|
||||
if(baseDurability > 0)
|
||||
ap = ((baseArmorPoints - 1) * currentDurability) / baseDurability + 1;
|
||||
return ap;
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -728,7 +729,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@Override
|
||||
public int getArmorPoints() {
|
||||
if(player != null)
|
||||
return Armor.getArmorPoints(player);
|
||||
return (int) player.getAttribute(Attribute.GENERIC_ARMOR).getValue();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user