mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-09 20:31:28 +01:00
Updated to 1.7.2, needs testing!
This commit is contained in:
parent
780145cf78
commit
998dbe4873
@ -106,7 +106,7 @@ public class DConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Add Item to Stacks
|
||||
// Add Item to Stacks
|
||||
ItemStack istack = new ItemStack(itemId, itemSize, (short) itemData);
|
||||
if (itemEnchantment != null) {
|
||||
istack.addEnchantment(itemEnchantment, itemLvlEnchantment);
|
||||
|
@ -61,8 +61,8 @@ public class DPlayer {
|
||||
|
||||
this.player = player;
|
||||
this.world = world;
|
||||
|
||||
this.savePlayer = new DSavePlayer(player.getName(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), player.getLevel(),
|
||||
|
||||
this.savePlayer = new DSavePlayer(player.getName(), player.getUniqueId().toString(), player.getLocation(), player.getInventory().getContents(), player.getInventory().getArmorContents(), player.getLevel(),
|
||||
player.getTotalExperience(), (int) player.getHealth(), player.getFoodLevel(), player.getFireTicks(), player.getGameMode(), player.getActivePotionEffects());
|
||||
|
||||
this.player.getInventory().clear();
|
||||
|
@ -24,6 +24,7 @@ public class DSavePlayer {
|
||||
|
||||
// Variables
|
||||
private String playerName;
|
||||
private String uuid;
|
||||
|
||||
private Location oldLocation;
|
||||
private ItemStack[] oldInventory;
|
||||
@ -36,11 +37,12 @@ public class DSavePlayer {
|
||||
private GameMode oldGamemode;
|
||||
private Collection<PotionEffect> oldPotionEffects;
|
||||
|
||||
public DSavePlayer(String playerName, Location oldLocation, ItemStack[] oldInventory, ItemStack[] oldArmor, int oldLvl, int oldExp, int oldHealth, int oldFoodLevel, int oldFireTicks,
|
||||
public DSavePlayer(String playerName, String uuid, Location oldLocation, ItemStack[] oldInventory, ItemStack[] oldArmor, int oldLvl, int oldExp, int oldHealth, int oldFoodLevel, int oldFireTicks,
|
||||
GameMode oldGamemode, Collection<PotionEffect> oldPotionEffects) {
|
||||
savePlayers.add(this);
|
||||
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid;
|
||||
|
||||
this.oldLocation = oldLocation;
|
||||
this.oldInventory = oldInventory;
|
||||
@ -76,7 +78,7 @@ public class DSavePlayer {
|
||||
DUtility.secureTeleport(onlinePlayer, this.oldLocation);
|
||||
} else {
|
||||
/* Player is offline */
|
||||
Player offlinePlayer = p.getOfflinePlayer(this.playerName, this.oldLocation);
|
||||
Player offlinePlayer = p.getOfflinePlayer(this.playerName, this.uuid, this.oldLocation);
|
||||
if (offlinePlayer != null) {
|
||||
offlinePlayer.getInventory().setContents(this.oldInventory);
|
||||
offlinePlayer.getInventory().setArmorContents(this.oldArmor);
|
||||
@ -104,6 +106,7 @@ public class DSavePlayer {
|
||||
FileConfiguration configFile = new YamlConfiguration();
|
||||
|
||||
for (DSavePlayer savePlayer : savePlayers) {
|
||||
configFile.set(savePlayer.playerName + ".uuid", savePlayer.uuid);
|
||||
configFile.set(savePlayer.playerName + ".oldGamemode", savePlayer.oldGamemode.getValue());
|
||||
configFile.set(savePlayer.playerName + ".oldFireTicks", savePlayer.oldFireTicks);
|
||||
configFile.set(savePlayer.playerName + ".oldFoodLevel", savePlayer.oldFoodLevel);
|
||||
@ -133,7 +136,9 @@ public class DSavePlayer {
|
||||
FileConfiguration configFile = YamlConfiguration.loadConfiguration(new File(p.getDataFolder(), "savePlayers.yml"));
|
||||
|
||||
for (String playerName : configFile.getKeys(false)) {
|
||||
|
||||
// Load uuid
|
||||
String uuid = configFile.getString(playerName + ".uuid");
|
||||
|
||||
// Load inventory data
|
||||
ArrayList<ItemStack> oldInventoryList = (ArrayList<ItemStack>) configFile.get(playerName + ".oldInventory");
|
||||
ArrayList<ItemStack> oldArmorList = (ArrayList<ItemStack>) configFile.get(playerName + ".oldArmor");
|
||||
@ -160,7 +165,7 @@ public class DSavePlayer {
|
||||
+ ".oldLocation.z"), configFile.getInt(playerName + ".oldLocation.yaw"), configFile.getInt(playerName + ".oldLocation.pitch"));
|
||||
|
||||
// Create Player
|
||||
DSavePlayer savePlayer = new DSavePlayer(playerName, oldLocation, oldInventory, oldArmor, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGamemode, oldPotionEffects);
|
||||
DSavePlayer savePlayer = new DSavePlayer(playerName, uuid, oldLocation, oldInventory, oldArmor, oldLvl, oldExp, oldHealth, oldFoodLevel, oldFireTicks, oldGamemode, oldPotionEffects);
|
||||
savePlayer.reset();
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,12 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R3.MinecraftServer;
|
||||
import net.minecraft.server.v1_6_R3.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_7_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_7_R1.PlayerInteractManager;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -20,8 +22,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -432,23 +434,20 @@ public class P extends JavaPlugin {
|
||||
return NumberUtils.toInt(string, 0);
|
||||
}
|
||||
|
||||
public Player getOfflinePlayer(String player) {
|
||||
public Player getOfflinePlayer(String player, String uuid) {
|
||||
Player pplayer = null;
|
||||
try {
|
||||
// See if the player has data files
|
||||
|
||||
// Find the player folder
|
||||
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
|
||||
|
||||
// Find player name
|
||||
|
||||
for (File playerfile : playerfolder.listFiles()) {
|
||||
String filename = playerfile.getName();
|
||||
String playername = filename.substring(0, filename.length() - 4);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, playername);
|
||||
|
||||
if (playername.trim().equalsIgnoreCase(player)) {
|
||||
// This player plays on the server!
|
||||
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
||||
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager(server.getWorldServer(0)));
|
||||
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
|
||||
Player target = (entity == null) ? null : (Player) entity.getBukkitEntity();
|
||||
if (target != null) {
|
||||
target.loadData();
|
||||
@ -462,23 +461,20 @@ public class P extends JavaPlugin {
|
||||
return pplayer;
|
||||
}
|
||||
|
||||
public Player getOfflinePlayer(String player, Location location) {
|
||||
public Player getOfflinePlayer(String player, String uuid, Location location) {
|
||||
Player pplayer = null;
|
||||
try {
|
||||
// See if the player has data files
|
||||
|
||||
// Find the player folder
|
||||
File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
|
||||
|
||||
// Find player name
|
||||
|
||||
for (File playerfile : playerfolder.listFiles()) {
|
||||
String filename = playerfile.getName();
|
||||
String playername = filename.substring(0, filename.length() - 4);
|
||||
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, playername);
|
||||
|
||||
if (playername.trim().equalsIgnoreCase(player)) {
|
||||
// This player plays on the server!
|
||||
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
||||
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager(server.getWorldServer(0)));
|
||||
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
|
||||
entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
entity.world = ((CraftWorld) location.getWorld()).getHandle();
|
||||
Player target = (entity == null) ? null : (Player) entity.getBukkitEntity();
|
||||
|
Loading…
Reference in New Issue
Block a user