Added silent mode, made invisible players update for all players on player movement, this should stop cloning/issues with invisibility. Moved some functions into vMinecraftParty... considering renaming this to vMinecraftFunctions or something similar.

This commit is contained in:
nossr50 2011-01-05 07:09:51 -08:00
parent f5d220e7a3
commit a22c04a725
5 changed files with 55 additions and 62 deletions

View File

@ -13,16 +13,6 @@ public class vMinecraft extends Plugin {
vMinecraftSettings.getInstance().loadSettings(); vMinecraftSettings.getInstance().loadSettings();
vMinecraftUsers.getInstance().loadUsers(); vMinecraftUsers.getInstance().loadUsers();
vMinecraftCommands.loadCommands(); vMinecraftCommands.loadCommands();
/*while(true){
if (etc.getServer().getTime() == 0){
vMinecraftChat.gmsg(Colors.Rose + "The sun has risen, it is now safe to punch trees");
}
if (etc.getServer().getTime() == 13000){
vMinecraftChat.gmsg(Colors.Rose + "What a terrible night to have a curse");
}
}
*
*/
} }
public void disable() { public void disable() {

View File

@ -208,6 +208,15 @@ private static HashMap<String, Player> hidden = new HashMap<String, Player>();
} }
} }
} }
public static int silent(Player player, String[] args){
if(player.canUseCommand("/silent")){
vMinecraftUsers.getProfile(player).setSilent();
player.sendMessage(Colors.DarkPurple + "You are now silent");
return EXIT_SUCCESS;
}
return EXIT_FAIL;
}
//Will make a player disappear or reappear
public static int hide(Player player, String[] args){ public static int hide(Player player, String[] args){
if (player.canUseCommand("/hide")){ if (player.canUseCommand("/hide")){
if(hidden.get(player.getName()) != null) { if(hidden.get(player.getName()) != null) {
@ -215,63 +224,19 @@ private static HashMap<String, Player> hidden = new HashMap<String, Player>();
player.sendMessage(Colors.DarkPurple + "You are no longer invisible"); player.sendMessage(Colors.DarkPurple + "You are no longer invisible");
hidden.remove(player.getName()); hidden.remove(player.getName());
updateInvisibleForAll(); updateInvisibleForAll();
List<Player> playerList = etc.getServer().getPlayerList(); vMinecraftParty.sendNotInvisible(player);
for (Player p : playerList) log.log(Level.INFO, player.getName() + " reappeared");
{
if (vMinecraftParty.getDistance(player, p) < vMinecraftSettings.range && p.getUser() != player.getUser())
{
p.getUser().a.b(new d(player.getUser()));
}
}
log.log(Level.INFO, "{0} reappeared.", player.getName());
player.sendMessage(Colors.Rose + "You have reappeared!"); player.sendMessage(Colors.Rose + "You have reappeared!");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
hidden.put(player.getName(), player); hidden.put(player.getName(), player);
player.sendMessage(Colors.DarkPurple + "You are now invisible"); player.sendMessage(Colors.DarkPurple + "You are now invisible");
for (Player p : etc.getServer().getPlayerList()) vMinecraftParty.sendInvisible(player);
{ log.log(Level.INFO, player.getName() + " went invisible");
if (vMinecraftParty.getDistance(player, p) <= vMinecraftSettings.range && p.getUser() != player.getUser())
{
p.getUser().a.b(new dv(player.getUser().g));
}
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
return EXIT_FAIL; return EXIT_FAIL;
} }
public void reappear(Player player)
{
if (hidden.get(player.getName()) != null)
{
hidden.remove(player.getName());
// make someone really disappear if there's any doubt, should remove
// cloning
updateInvisibleForAll();
List<Player> playerList = etc.getServer().getPlayerList();
for (Player p : playerList)
{
if (vMinecraftParty.getDistance(player, p) < vMinecraftSettings.range && p.getUser() != player.getUser())
{
// new d (player.getUser() )
// new Packet20NamedEntitySpawn player EntityPlayerMP )
p.getUser().a.b(new d(player.getUser()));
}
}
log.log( Level.INFO, "{0} reappeared.", player.getName());
player.sendMessage(Colors.Rose + "You have reappeared!");
}
}
public void reappearAll()
{
log.info("Everyone is going reappear.");
for (Player InvisiblePlayer : hidden.values())
{
reappear(InvisiblePlayer);
}
hidden.clear();
}
public static void updateInvisibleForAll() public static void updateInvisibleForAll()
{ {
List<Player> playerList = etc.getServer().getPlayerList(); List<Player> playerList = etc.getServer().getPlayerList();
@ -282,7 +247,6 @@ player.sendMessage(Colors.Rose + "You have reappeared!");
if (vMinecraftParty.getDistance(InvisiblePlayer, p) <= vMinecraftSettings.range && p.getUser() != InvisiblePlayer.getUser()) if (vMinecraftParty.getDistance(InvisiblePlayer, p) <= vMinecraftSettings.range && p.getUser() != InvisiblePlayer.getUser())
{ {
p.getUser().a.b(new dv(InvisiblePlayer.getUser().g)); p.getUser().a.b(new dv(InvisiblePlayer.getUser().g));
// players.add(p);
} }
} }
} }
@ -339,7 +303,6 @@ player.sendMessage(Colors.Rose + "You have reappeared!");
vMinecraftUsers.getProfile(player).setTpback(cxyz); vMinecraftUsers.getProfile(player).setTpback(cxyz);
player.sendMessage(Colors.Rose + "/tpback data reset to spawn"); player.sendMessage(Colors.Rose + "/tpback data reset to spawn");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -1213,11 +1176,14 @@ player.sendMessage(Colors.Rose + "You have reappeared!");
if(player.canUseCommand("/tpback")){ if(player.canUseCommand("/tpback")){
player.sendMessage(Colors.DarkPurple + "Your previous location has been stored, use /tpback to return."); player.sendMessage(Colors.DarkPurple + "Your previous location has been stored, use /tpback to return.");
} }
if(!vMinecraftUsers.getProfile(player).isSilent()){
vMinecraftChat.gmsg( player, vMinecraftChat.getName(player) vMinecraftChat.gmsg( player, vMinecraftChat.getName(player)
+ Colors.LightBlue + " has teleported to " + Colors.LightBlue + " has teleported to "
+ vMinecraftChat.getName(playerTarget)); + vMinecraftChat.getName(playerTarget));
}
log.log(Level.INFO, player.getName() + " teleported to " + log.log(Level.INFO, player.getName() + " teleported to " +
playerTarget.getName()); playerTarget.getName());
player.teleportTo(playerTarget); player.teleportTo(playerTarget);
} }
@ -1543,9 +1509,11 @@ player.sendMessage(Colors.Rose + "You have reappeared!");
} }
playerTarget.setHealth(0); playerTarget.setHealth(0);
if(!vMinecraftUsers.getProfile(player).isSilent()){
vMinecraftChat.gmsg(player, vMinecraftChat.getName(player) vMinecraftChat.gmsg(player, vMinecraftChat.getName(player)
+ Colors.LightBlue + " has slain " + Colors.LightBlue + " has slain "
+ vMinecraftChat.getName(playerTarget)); + vMinecraftChat.getName(playerTarget));
}
//Otherwise output error to the user //Otherwise output error to the user
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -21,6 +21,7 @@ public class vMinecraftListener extends PluginListener {
if(vMinecraftSettings.getInstance().isFrozen(player.getName())){ if(vMinecraftSettings.getInstance().isFrozen(player.getName())){
player.teleportTo(from); player.teleportTo(from);
} }
vMinecraftCommands.updateInvisibleForAll();
} }
//===================================================================== //=====================================================================
@ -105,6 +106,7 @@ public class vMinecraftListener extends PluginListener {
player.sendMessage(Colors.DarkPurple + "Set your own spawn with /sethome"); player.sendMessage(Colors.DarkPurple + "Set your own spawn with /sethome");
} }
vMinecraftUsers.getProfile(player).isDead(false); vMinecraftUsers.getProfile(player).isDead(false);
if(!vMinecraftUsers.getProfile(player).isSilent())
vMinecraftChat.gmsg(Colors.Gray + player.getName() + " " + vMinecraftSettings.randomDeathMsg()); vMinecraftChat.gmsg(Colors.Gray + player.getName() + " " + vMinecraftSettings.randomDeathMsg());
} }
return false; return false;

View File

@ -1,4 +1,3 @@
import java.util.ArrayList;
public class vMinecraftParty { public class vMinecraftParty {
//Check if two players are in the same party //Check if two players are in the same party
@ -14,4 +13,22 @@ public class vMinecraftParty {
return Math.sqrt(Math.pow(player1.getX() - player2.getX(), 2) + Math.pow(player1.getY() - player2.getY(), 2) return Math.sqrt(Math.pow(player1.getX() - player2.getX(), 2) + Math.pow(player1.getY() - player2.getY(), 2)
+ Math.pow(player1.getZ() - player2.getZ(), 2)); + Math.pow(player1.getZ() - player2.getZ(), 2));
} }
public static void sendInvisible(Player player){
for (Player p : etc.getServer().getPlayerList())
{
if (vMinecraftParty.getDistance(player, p) <= vMinecraftSettings.range && p.getUser() != player.getUser())
{
p.getUser().a.b(new dv(player.getUser().g));
}
}
}
public static void sendNotInvisible(Player player){
for (Player p : etc.getServer().getPlayerList())
{
if (vMinecraftParty.getDistance(player, p) < vMinecraftSettings.range && p.getUser() != player.getUser())
{
p.getUser().a.b(new d(player.getUser()));
}
}
}
} }

View File

@ -156,7 +156,8 @@ class PlayerList
party, party,
tpxyz; tpxyz;
private boolean dead; private boolean dead,
silent;
char defaultColor; char defaultColor;
@ -508,6 +509,21 @@ class PlayerList
nickName = newNick; nickName = newNick;
save(); save();
} }
public void setSilent(){
silent = true;
}
public void disableSilent(){
silent = false;
}
public boolean isSilent(){
if(silent == true){
return true;
}
else {
return false;
}
}
//Store the player's party //Store the player's party
public void setParty(String newParty) public void setParty(String newParty)
{ {