mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 09:51:12 +01:00
#645: Allow statistics to be accessed for offline players
This commit is contained in:
parent
2122c0b128
commit
aa3a2f2767
4 changed files with 353 additions and 64 deletions
|
@ -379,13 +379,13 @@
|
||||||
+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) {
|
+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) {
|
||||||
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
|
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
|
||||||
+ }
|
+ }
|
||||||
}
|
+ }
|
||||||
+
|
+
|
||||||
+ cserver.getPluginManager().callEvent(event);
|
+ cserver.getPluginManager().callEvent(event);
|
||||||
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
||||||
+ loginlistener.disconnect(event.getKickMessage());
|
+ loginlistener.disconnect(event.getKickMessage());
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
}
|
||||||
+ return entity;
|
+ return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,13 +466,13 @@
|
||||||
+ entityplayer1.setRespawnPosition(null, true, false);
|
+ entityplayer1.setRespawnPosition(null, true, false);
|
||||||
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F));
|
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F));
|
||||||
+ }
|
+ }
|
||||||
}
|
+ }
|
||||||
+
|
+
|
||||||
+ if (location == null) {
|
+ if (location == null) {
|
||||||
+ cworld = (CraftWorld) this.server.server.getWorlds().get(0);
|
+ cworld = (CraftWorld) this.server.server.getWorlds().get(0);
|
||||||
+ blockposition = entityplayer1.getSpawnPoint(cworld.getHandle());
|
+ blockposition = entityplayer1.getSpawnPoint(cworld.getHandle());
|
||||||
+ location = new Location(cworld, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
|
+ location = new Location(cworld, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
|
||||||
+ }
|
}
|
||||||
+
|
+
|
||||||
+ Player respawnPlayer = cserver.getPlayer(entityplayer1);
|
+ Player respawnPlayer = cserver.getPlayer(entityplayer1);
|
||||||
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
|
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
|
||||||
|
@ -658,7 +658,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerCount() {
|
public int getPlayerCount() {
|
||||||
@@ -710,26 +993,39 @@
|
@@ -710,33 +993,52 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
@ -695,15 +695,30 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) {
|
- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) {
|
||||||
+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) {
|
- UUID uuid = entityhuman.getUniqueID();
|
||||||
UUID uuid = entityhuman.getUniqueID();
|
|
||||||
- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.o.get(uuid);
|
- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.o.get(uuid);
|
||||||
+ ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) entityhuman.getStatisticManager();
|
+ // CraftBukkit start
|
||||||
|
+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) {
|
||||||
|
+ ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager();
|
||||||
|
+ return serverstatisticmanager == null ? getStatisticManager(entityhuman.getUniqueID(), entityhuman.getDisplayName().getString()) : serverstatisticmanager;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerStatisticManager getStatisticManager(UUID uuid, String displayName) {
|
||||||
|
+ EntityPlayer entityHuman = this.a(uuid);
|
||||||
|
+ ServerStatisticManager serverstatisticmanager = entityHuman == null ? null : (ServerStatisticManager) entityHuman.getStatisticManager();
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
if (serverstatisticmanager == null) {
|
if (serverstatisticmanager == null) {
|
||||||
File file = new File(this.server.getWorldServer(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "stats");
|
File file = new File(this.server.getWorldServer(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "stats");
|
||||||
@@ -744,7 +1040,7 @@
|
File file1 = new File(file, uuid + ".json");
|
||||||
|
|
||||||
|
if (!file1.exists()) {
|
||||||
|
- File file2 = new File(file, entityhuman.getDisplayName().getString() + ".json");
|
||||||
|
+ File file2 = new File(file, displayName + ".json"); // CraftBukkit
|
||||||
|
|
||||||
|
if (file2.exists() && file2.isFile()) {
|
||||||
|
file2.renameTo(file1);
|
||||||
|
@@ -744,7 +1046,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||||
|
@ -712,7 +727,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverstatisticmanager;
|
return serverstatisticmanager;
|
||||||
@@ -752,14 +1048,14 @@
|
@@ -752,14 +1054,14 @@
|
||||||
|
|
||||||
public AdvancementDataPlayer f(EntityPlayer entityplayer) {
|
public AdvancementDataPlayer f(EntityPlayer entityplayer) {
|
||||||
UUID uuid = entityplayer.getUniqueID();
|
UUID uuid = entityplayer.getUniqueID();
|
||||||
|
@ -729,7 +744,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
advancementdataplayer.a(entityplayer);
|
advancementdataplayer.a(entityplayer);
|
||||||
@@ -795,13 +1091,20 @@
|
@@ -795,13 +1097,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
|
|
@ -8,15 +8,19 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.minecraft.server.DimensionManager;
|
import net.minecraft.server.DimensionManager;
|
||||||
import net.minecraft.server.NBTTagCompound;
|
import net.minecraft.server.NBTTagCompound;
|
||||||
|
import net.minecraft.server.ServerStatisticManager;
|
||||||
import net.minecraft.server.WhiteListEntry;
|
import net.minecraft.server.WhiteListEntry;
|
||||||
import net.minecraft.server.WorldNBTStorage;
|
import net.minecraft.server.WorldNBTStorage;
|
||||||
import org.bukkit.BanList;
|
import org.bukkit.BanList;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
import org.bukkit.configuration.serialization.SerializableAs;
|
import org.bukkit.configuration.serialization.SerializableAs;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
@ -271,4 +275,200 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
||||||
public void removeMetadata(String metadataKey, Plugin plugin) {
|
public void removeMetadata(String metadataKey, Plugin plugin) {
|
||||||
server.getPlayerMetadata().removeMetadata(this, metadataKey, plugin);
|
server.getPlayerMetadata().removeMetadata(this, metadataKey, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ServerStatisticManager getStatisticManager() {
|
||||||
|
return server.getHandle().getStatisticManager(getUniqueId(), getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void incrementStatistic(Statistic statistic) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().incrementStatistic(statistic);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.incrementStatistic(manager, statistic);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrementStatistic(Statistic statistic) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().decrementStatistic(statistic);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.decrementStatistic(manager, statistic);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatistic(Statistic statistic) {
|
||||||
|
if (isOnline()) {
|
||||||
|
return getPlayer().getStatistic(statistic);
|
||||||
|
} else {
|
||||||
|
return CraftStatistic.getStatistic(getStatisticManager(), statistic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void incrementStatistic(Statistic statistic, int amount) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().incrementStatistic(statistic, amount);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.incrementStatistic(manager, statistic, amount);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrementStatistic(Statistic statistic, int amount) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().decrementStatistic(statistic, amount);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.decrementStatistic(manager, statistic, amount);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStatistic(Statistic statistic, int newValue) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().setStatistic(statistic, newValue);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.setStatistic(manager, statistic, newValue);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void incrementStatistic(Statistic statistic, Material material) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().incrementStatistic(statistic, material);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.incrementStatistic(manager, statistic, material);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrementStatistic(Statistic statistic, Material material) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().decrementStatistic(statistic, material);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.decrementStatistic(manager, statistic, material);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatistic(Statistic statistic, Material material) {
|
||||||
|
if (isOnline()) {
|
||||||
|
return getPlayer().getStatistic(statistic, material);
|
||||||
|
} else {
|
||||||
|
return CraftStatistic.getStatistic(getStatisticManager(), statistic, material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void incrementStatistic(Statistic statistic, Material material, int amount) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().incrementStatistic(statistic, material, amount);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.incrementStatistic(manager, statistic, material, amount);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrementStatistic(Statistic statistic, Material material, int amount) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().decrementStatistic(statistic, material, amount);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.decrementStatistic(manager, statistic, material, amount);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStatistic(Statistic statistic, Material material, int newValue) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().setStatistic(statistic, material, newValue);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.setStatistic(manager, statistic, material, newValue);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void incrementStatistic(Statistic statistic, EntityType entityType) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().incrementStatistic(statistic, entityType);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.incrementStatistic(manager, statistic, entityType);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrementStatistic(Statistic statistic, EntityType entityType) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().decrementStatistic(statistic, entityType);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.decrementStatistic(manager, statistic, entityType);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatistic(Statistic statistic, EntityType entityType) {
|
||||||
|
if (isOnline()) {
|
||||||
|
return getPlayer().getStatistic(statistic, entityType);
|
||||||
|
} else {
|
||||||
|
return CraftStatistic.getStatistic(getStatisticManager(), statistic, entityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().incrementStatistic(statistic, entityType, amount);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.incrementStatistic(manager, statistic, entityType, amount);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrementStatistic(Statistic statistic, EntityType entityType, int amount) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().decrementStatistic(statistic, entityType, amount);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.decrementStatistic(manager, statistic, entityType, amount);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
|
||||||
|
if (isOnline()) {
|
||||||
|
getPlayer().setStatistic(statistic, entityType, newValue);
|
||||||
|
} else {
|
||||||
|
ServerStatisticManager manager = getStatisticManager();
|
||||||
|
CraftStatistic.setStatistic(manager, statistic, entityType, newValue);
|
||||||
|
manager.a();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,12 @@ import net.minecraft.server.EntityTypes;
|
||||||
import net.minecraft.server.IRegistry;
|
import net.minecraft.server.IRegistry;
|
||||||
import net.minecraft.server.Item;
|
import net.minecraft.server.Item;
|
||||||
import net.minecraft.server.MinecraftKey;
|
import net.minecraft.server.MinecraftKey;
|
||||||
|
import net.minecraft.server.ServerStatisticManager;
|
||||||
import net.minecraft.server.StatisticList;
|
import net.minecraft.server.StatisticList;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
|
import org.bukkit.Statistic.Type;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
@ -188,4 +191,110 @@ public enum CraftStatistic {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic) {
|
||||||
|
incrementStatistic(manager, statistic, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrementStatistic(ServerStatisticManager manager, Statistic statistic) {
|
||||||
|
decrementStatistic(manager, statistic, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getStatistic(ServerStatisticManager manager, Statistic statistic) {
|
||||||
|
Validate.notNull(statistic, "Statistic cannot be null");
|
||||||
|
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
|
||||||
|
return manager.getStatisticValue(CraftStatistic.getNMSStatistic(statistic));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, int amount) {
|
||||||
|
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
||||||
|
setStatistic(manager, statistic, getStatistic(manager, statistic) + amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrementStatistic(ServerStatisticManager manager, Statistic statistic, int amount) {
|
||||||
|
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
||||||
|
setStatistic(manager, statistic, getStatistic(manager, statistic) - amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setStatistic(ServerStatisticManager manager, Statistic statistic, int newValue) {
|
||||||
|
Validate.notNull(statistic, "Statistic cannot be null");
|
||||||
|
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
|
||||||
|
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
|
||||||
|
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
|
||||||
|
manager.setStatistic(null, nmsStatistic, newValue);;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material) {
|
||||||
|
incrementStatistic(manager, statistic, material, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material) {
|
||||||
|
decrementStatistic(manager, statistic, material, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getStatistic(ServerStatisticManager manager, Statistic statistic, Material material) {
|
||||||
|
Validate.notNull(statistic, "Statistic cannot be null");
|
||||||
|
Validate.notNull(material, "Material cannot be null");
|
||||||
|
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
|
||||||
|
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
|
||||||
|
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
|
||||||
|
return manager.getStatisticValue(nmsStatistic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material, int amount) {
|
||||||
|
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
||||||
|
setStatistic(manager, statistic, material, getStatistic(manager, statistic, material) + amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material, int amount) {
|
||||||
|
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
||||||
|
setStatistic(manager, statistic, material, getStatistic(manager, statistic, material) - amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setStatistic(ServerStatisticManager manager, Statistic statistic, Material material, int newValue) {
|
||||||
|
Validate.notNull(statistic, "Statistic cannot be null");
|
||||||
|
Validate.notNull(material, "Material cannot be null");
|
||||||
|
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
|
||||||
|
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
|
||||||
|
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
|
||||||
|
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
|
||||||
|
manager.setStatistic(null, nmsStatistic, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType) {
|
||||||
|
incrementStatistic(manager, statistic, entityType, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType) {
|
||||||
|
decrementStatistic(manager, statistic, entityType, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType) {
|
||||||
|
Validate.notNull(statistic, "Statistic cannot be null");
|
||||||
|
Validate.notNull(entityType, "EntityType cannot be null");
|
||||||
|
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
|
||||||
|
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
|
||||||
|
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
|
||||||
|
return manager.getStatisticValue(nmsStatistic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType, int amount) {
|
||||||
|
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
||||||
|
setStatistic(manager, statistic, entityType, getStatistic(manager, statistic, entityType) + amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType, int amount) {
|
||||||
|
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
||||||
|
setStatistic(manager, statistic, entityType, getStatistic(manager, statistic, entityType) - amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType, int newValue) {
|
||||||
|
Validate.notNull(statistic, "Statistic cannot be null");
|
||||||
|
Validate.notNull(entityType, "EntityType cannot be null");
|
||||||
|
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
|
||||||
|
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
|
||||||
|
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
|
||||||
|
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
|
||||||
|
manager.setStatistic(null, nmsStatistic, newValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,6 @@ import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.Statistic.Type;
|
|
||||||
import org.bukkit.WeatherType;
|
import org.bukkit.WeatherType;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||||
|
@ -720,126 +719,92 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrementStatistic(Statistic statistic) {
|
public void incrementStatistic(Statistic statistic) {
|
||||||
incrementStatistic(statistic, 1);
|
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decrementStatistic(Statistic statistic) {
|
public void decrementStatistic(Statistic statistic) {
|
||||||
decrementStatistic(statistic, 1);
|
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatistic(Statistic statistic) {
|
public int getStatistic(Statistic statistic) {
|
||||||
Validate.notNull(statistic, "Statistic cannot be null");
|
return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic);
|
||||||
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
|
|
||||||
return getHandle().getStatisticManager().getStatisticValue(CraftStatistic.getNMSStatistic(statistic));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrementStatistic(Statistic statistic, int amount) {
|
public void incrementStatistic(Statistic statistic, int amount) {
|
||||||
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, amount);
|
||||||
setStatistic(statistic, getStatistic(statistic) + amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decrementStatistic(Statistic statistic, int amount) {
|
public void decrementStatistic(Statistic statistic, int amount) {
|
||||||
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, amount);
|
||||||
setStatistic(statistic, getStatistic(statistic) - amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStatistic(Statistic statistic, int newValue) {
|
public void setStatistic(Statistic statistic, int newValue) {
|
||||||
Validate.notNull(statistic, "Statistic cannot be null");
|
CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, newValue);
|
||||||
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
|
|
||||||
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
|
|
||||||
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
|
|
||||||
getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrementStatistic(Statistic statistic, Material material) {
|
public void incrementStatistic(Statistic statistic, Material material) {
|
||||||
incrementStatistic(statistic, material, 1);
|
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, material);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decrementStatistic(Statistic statistic, Material material) {
|
public void decrementStatistic(Statistic statistic, Material material) {
|
||||||
decrementStatistic(statistic, material, 1);
|
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, material);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatistic(Statistic statistic, Material material) {
|
public int getStatistic(Statistic statistic, Material material) {
|
||||||
Validate.notNull(statistic, "Statistic cannot be null");
|
return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic, material);
|
||||||
Validate.notNull(material, "Material cannot be null");
|
|
||||||
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
|
|
||||||
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
|
|
||||||
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
|
|
||||||
return getHandle().getStatisticManager().getStatisticValue(nmsStatistic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrementStatistic(Statistic statistic, Material material, int amount) {
|
public void incrementStatistic(Statistic statistic, Material material, int amount) {
|
||||||
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, material, amount);
|
||||||
setStatistic(statistic, material, getStatistic(statistic, material) + amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decrementStatistic(Statistic statistic, Material material, int amount) {
|
public void decrementStatistic(Statistic statistic, Material material, int amount) {
|
||||||
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, material, amount);
|
||||||
setStatistic(statistic, material, getStatistic(statistic, material) - amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStatistic(Statistic statistic, Material material, int newValue) {
|
public void setStatistic(Statistic statistic, Material material, int newValue) {
|
||||||
Validate.notNull(statistic, "Statistic cannot be null");
|
CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, material, newValue);
|
||||||
Validate.notNull(material, "Material cannot be null");
|
|
||||||
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
|
|
||||||
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
|
|
||||||
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
|
|
||||||
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
|
|
||||||
getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrementStatistic(Statistic statistic, EntityType entityType) {
|
public void incrementStatistic(Statistic statistic, EntityType entityType) {
|
||||||
incrementStatistic(statistic, entityType, 1);
|
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decrementStatistic(Statistic statistic, EntityType entityType) {
|
public void decrementStatistic(Statistic statistic, EntityType entityType) {
|
||||||
decrementStatistic(statistic, entityType, 1);
|
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatistic(Statistic statistic, EntityType entityType) {
|
public int getStatistic(Statistic statistic, EntityType entityType) {
|
||||||
Validate.notNull(statistic, "Statistic cannot be null");
|
return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic, entityType);
|
||||||
Validate.notNull(entityType, "EntityType cannot be null");
|
|
||||||
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
|
|
||||||
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
|
|
||||||
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
|
|
||||||
return getHandle().getStatisticManager().getStatisticValue(nmsStatistic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) {
|
public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) {
|
||||||
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, entityType, amount);
|
||||||
setStatistic(statistic, entityType, getStatistic(statistic, entityType) + amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decrementStatistic(Statistic statistic, EntityType entityType, int amount) {
|
public void decrementStatistic(Statistic statistic, EntityType entityType, int amount) {
|
||||||
Validate.isTrue(amount > 0, "Amount must be greater than 0");
|
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, entityType, amount);
|
||||||
setStatistic(statistic, entityType, getStatistic(statistic, entityType) - amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
|
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
|
||||||
Validate.notNull(statistic, "Statistic cannot be null");
|
CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, entityType, newValue);
|
||||||
Validate.notNull(entityType, "EntityType cannot be null");
|
|
||||||
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
|
|
||||||
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
|
|
||||||
net.minecraft.server.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
|
|
||||||
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
|
|
||||||
getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue