Skip to content

Commit

Permalink
Hopefully fixed /back and /home, /sethome on MP
Browse files Browse the repository at this point in the history
  • Loading branch information
woutwoot committed Nov 9, 2014
1 parent 31ad0e6 commit 8e563e5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
11 changes: 5 additions & 6 deletions src/main/java/net/doubledoordev/d3commands/D3Commands.java
@@ -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;
Expand All @@ -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;
Expand All @@ -32,8 +30,8 @@ public class D3Commands implements ID3Mod

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;

Expand All @@ -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
Expand Down
Expand Up @@ -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;
}

/**
Expand Down
Expand Up @@ -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"));
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 8e563e5

Please sign in to comment.