mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
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:
parent
f5d220e7a3
commit
a22c04a725
@ -13,16 +13,6 @@ public class vMinecraft extends Plugin {
|
||||
vMinecraftSettings.getInstance().loadSettings();
|
||||
vMinecraftUsers.getInstance().loadUsers();
|
||||
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() {
|
||||
|
@ -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){
|
||||
if (player.canUseCommand("/hide")){
|
||||
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");
|
||||
hidden.remove(player.getName());
|
||||
updateInvisibleForAll();
|
||||
List<Player> playerList = etc.getServer().getPlayerList();
|
||||
for (Player p : playerList)
|
||||
{
|
||||
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());
|
||||
vMinecraftParty.sendNotInvisible(player);
|
||||
log.log(Level.INFO, player.getName() + " reappeared");
|
||||
player.sendMessage(Colors.Rose + "You have reappeared!");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
hidden.put(player.getName(), player);
|
||||
player.sendMessage(Colors.DarkPurple + "You are now invisible");
|
||||
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));
|
||||
}
|
||||
}
|
||||
vMinecraftParty.sendInvisible(player);
|
||||
log.log(Level.INFO, player.getName() + " went invisible");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
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()
|
||||
{
|
||||
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())
|
||||
{
|
||||
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);
|
||||
player.sendMessage(Colors.Rose + "/tpback data reset to spawn");
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -1213,11 +1176,14 @@ player.sendMessage(Colors.Rose + "You have reappeared!");
|
||||
if(player.canUseCommand("/tpback")){
|
||||
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)
|
||||
+ Colors.LightBlue + " has teleported to "
|
||||
+ vMinecraftChat.getName(playerTarget));
|
||||
}
|
||||
log.log(Level.INFO, player.getName() + " teleported to " +
|
||||
playerTarget.getName());
|
||||
|
||||
player.teleportTo(playerTarget);
|
||||
|
||||
}
|
||||
@ -1543,9 +1509,11 @@ player.sendMessage(Colors.Rose + "You have reappeared!");
|
||||
}
|
||||
|
||||
playerTarget.setHealth(0);
|
||||
if(!vMinecraftUsers.getProfile(player).isSilent()){
|
||||
vMinecraftChat.gmsg(player, vMinecraftChat.getName(player)
|
||||
+ Colors.LightBlue + " has slain "
|
||||
+ vMinecraftChat.getName(playerTarget));
|
||||
}
|
||||
//Otherwise output error to the user
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -21,6 +21,7 @@ public class vMinecraftListener extends PluginListener {
|
||||
if(vMinecraftSettings.getInstance().isFrozen(player.getName())){
|
||||
player.teleportTo(from);
|
||||
}
|
||||
vMinecraftCommands.updateInvisibleForAll();
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
@ -105,6 +106,7 @@ public class vMinecraftListener extends PluginListener {
|
||||
player.sendMessage(Colors.DarkPurple + "Set your own spawn with /sethome");
|
||||
}
|
||||
vMinecraftUsers.getProfile(player).isDead(false);
|
||||
if(!vMinecraftUsers.getProfile(player).isSilent())
|
||||
vMinecraftChat.gmsg(Colors.Gray + player.getName() + " " + vMinecraftSettings.randomDeathMsg());
|
||||
}
|
||||
return false;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import java.util.ArrayList;
|
||||
public class vMinecraftParty {
|
||||
|
||||
//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)
|
||||
+ 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,8 @@ class PlayerList
|
||||
party,
|
||||
tpxyz;
|
||||
|
||||
private boolean dead;
|
||||
private boolean dead,
|
||||
silent;
|
||||
|
||||
char defaultColor;
|
||||
|
||||
@ -508,6 +509,21 @@ class PlayerList
|
||||
nickName = newNick;
|
||||
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
|
||||
public void setParty(String newParty)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user