Remove sit stop location correction
This commit is contained in:
parent
bafc260459
commit
d14172203c
@ -1,7 +1,6 @@
|
|||||||
package com.cnaude.chairs;
|
package com.cnaude.chairs;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -13,10 +12,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@ -68,21 +64,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
new PacketListener(protocolManager, this);
|
new PacketListener(protocolManager, this);
|
||||||
for (final Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
final Location loc = getPlayerSitstoploc(player.getName());
|
|
||||||
if (loc != null)
|
|
||||||
{
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
player.teleport(loc);
|
|
||||||
player.setSneaking(false);
|
|
||||||
}
|
|
||||||
},1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,7 +71,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
protocolManager.getAsynchronousManager().unregisterAsyncHandlers(this);
|
protocolManager.getAsynchronousManager().unregisterAsyncHandlers(this);
|
||||||
protocolManager = null;
|
protocolManager = null;
|
||||||
for (String pName : new HashSet<String>(sit.keySet())) {
|
for (String pName : new HashSet<String>(sit.keySet())) {
|
||||||
savePlayerSitstoploc(pName);
|
|
||||||
ejectPlayerOnDisable(Bukkit.getPlayerExact(pName));
|
ejectPlayerOnDisable(Bukkit.getPlayerExact(pName));
|
||||||
}
|
}
|
||||||
if (ignoreList != null) {
|
if (ignoreList != null) {
|
||||||
@ -185,37 +165,6 @@ public class Chairs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void savePlayerSitstoploc(String player)
|
|
||||||
{
|
|
||||||
FileConfiguration plconfig = new YamlConfiguration();
|
|
||||||
Location sitstop = sitstopteleportloc.get(player);
|
|
||||||
plconfig.set(player+".world", sitstop.getWorld().getName());
|
|
||||||
plconfig.set(player+".xyz", sitstop.toVector());
|
|
||||||
plconfig.set(player+".pitch", sitstop.getPitch());
|
|
||||||
plconfig.set(player+".yaw", sitstop.getYaw());
|
|
||||||
try {
|
|
||||||
plconfig.save(new File(getDataFolder(),"playersdata"+File.separator+player+".yml"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected Location getPlayerSitstoploc(String player)
|
|
||||||
{
|
|
||||||
File plfile = new File(getDataFolder(),"playersdata"+File.separator+player+".yml");
|
|
||||||
if (plfile.exists())
|
|
||||||
{
|
|
||||||
FileConfiguration plconfig = YamlConfiguration.loadConfiguration(plfile);
|
|
||||||
World world = Bukkit.getWorld(plconfig.getString(player+".world"));
|
|
||||||
Vector xyz = plconfig.getVector(player+".xyz");
|
|
||||||
Location sitstop = new Location(world,xyz.getX(),xyz.getY(),xyz.getZ());
|
|
||||||
sitstop.setPitch((float) plconfig.getDouble(player+".pitch"));
|
|
||||||
sitstop.setYaw((float) plconfig.getDouble(player+".yaw"));
|
|
||||||
plfile.delete();
|
|
||||||
return sitstop;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
autoRotate = getConfig().getBoolean("auto-rotate");
|
autoRotate = getConfig().getBoolean("auto-rotate");
|
||||||
signCheck = getConfig().getBoolean("sign-check");
|
signCheck = getConfig().getBoolean("sign-check");
|
||||||
|
@ -34,12 +34,7 @@ public class EventListener implements Listener {
|
|||||||
@EventHandler(priority=EventPriority.LOWEST,ignoreCancelled=true)
|
@EventHandler(priority=EventPriority.LOWEST,ignoreCancelled=true)
|
||||||
public void onJoin(PlayerJoinEvent e)
|
public void onJoin(PlayerJoinEvent e)
|
||||||
{
|
{
|
||||||
Player player = e.getPlayer();
|
|
||||||
Location loc = plugin.getPlayerSitstoploc(player.getName());
|
|
||||||
if (loc != null)
|
|
||||||
{
|
|
||||||
player.teleport(loc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOWEST)
|
@EventHandler(priority=EventPriority.LOWEST)
|
||||||
@ -48,7 +43,6 @@ public class EventListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (plugin.sit.containsKey(player.getName()))
|
if (plugin.sit.containsKey(player.getName()))
|
||||||
{
|
{
|
||||||
plugin.savePlayerSitstoploc(player.getName());
|
|
||||||
plugin.unSitPlayer(player,true);
|
plugin.unSitPlayer(player,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user