Skip to content
Permalink
Browse files

Hopefully fixed /back and /home, /sethome on MP

  • Loading branch information...
woutwoot committed Nov 9, 2014
1 parent 31ad0e6 commit 8e563e5186e7bc82fa48d8fed2b8ea2b8c09ef5e
@@ -1,6 +1,7 @@
package net.doubledoordev.d3commands;

import cpw.mods.fml.client.config.IConfigElement;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
@@ -14,10 +15,7 @@
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

import static net.doubledoordev.d3commands.util.Constants.MODID;
import static net.doubledoordev.d3commands.util.Constants.NAME;
@@ -32,8 +30,8 @@

private PlayerDeathEventHandler pdEventHandler = new PlayerDeathEventHandler();

public Map<EntityPlayerMP, Location> deathlog = new HashMap<>();
public Map<EntityPlayerMP, Location> homes = new HashMap<>();
public Map<UUID, Location> deathlog = new HashMap<>();
public Map<UUID, Location> homes = new HashMap<>();

public Configuration configuration;

@@ -43,6 +41,7 @@ public void preInit(FMLPreInitializationEvent event)
configuration = new Configuration(event.getSuggestedConfigurationFile());
syncConfig();
MinecraftForge.EVENT_BUS.register(pdEventHandler);
//FMLCommonHandler.instance().bus().register(pdEventHandler); Do I need this?
}

@Override
@@ -68,14 +68,14 @@ public boolean isUsernameIndex(final String[] args, final int userIndex)
@Override
public void processCommand(ICommandSender sender, String[] args)
{
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
if(D3Commands.instance.deathlog.containsKey(player)){
Location locto = D3Commands.instance.deathlog.get(player);
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
if(D3Commands.instance.deathlog.containsKey(player.getUniqueID())){
Location locto = D3Commands.instance.deathlog.get(player.getUniqueID());
teleportPlayer(sender, player, locto);
System.out.println("Teleported " + player.getDisplayName() + " back to death point:" + player.getPlayerCoordinates());
}else{
System.out.println("Could not find a death point to return to for " + player.getCommandSenderName() + ".");
}

System.out.println("Teleported " + player.getDisplayName() + " back to death point:" + player.getPlayerCoordinates());
return;
}

/**
@@ -57,8 +57,8 @@ public void processCommand(final ICommandSender sender, final String[] args)
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
if (args.length == 0)
{
if(D3Commands.instance.homes.containsKey(player)){
teleportPlayer(player, D3Commands.instance.homes.get(player));
if(D3Commands.instance.homes.containsKey(player.getUniqueID())){
teleportPlayer(player, D3Commands.instance.homes.get(player.getUniqueID()));
player.addChatMessage(new ChatComponentText("Teleported back to your home."));
}else{
player.addChatMessage(new ChatComponentText("You don't have a home set. Use /sethome"));
@@ -61,7 +61,7 @@ public void processCommand(final ICommandSender sender, final String[] args)
if (args.length == 0)
{
Location loc = new Location(player.getPlayerCoordinates(), player.dimension);
D3Commands.instance.homes.put(player, loc);
D3Commands.instance.homes.put(player.getUniqueID(), loc);
player.addChatMessage(new ChatComponentText("Your home has been set."));
}
else
@@ -50,7 +50,7 @@ public void onPlayerDeath(LivingDeathEvent event)
ChunkCoordinates coo = player.getPlayerCoordinates();
int dimension = player.dimension;
Location loc = new Location(coo, dimension);
D3Commands.instance.deathlog.put(player, loc);
D3Commands.instance.deathlog.put(player.getUniqueID(), loc);
}
}

0 comments on commit 8e563e5

Please sign in to comment.
You can’t perform that action at this time.