Add /ptp toggle command

This commit is contained in:
TfT_02 2013-01-27 23:35:46 +01:00
parent e061acb44a
commit abd8223e41
3 changed files with 44 additions and 9 deletions

View File

@ -31,6 +31,7 @@ public class PlayerProfile {
/* Party Stuff */
private Party party;
private Party invite;
private boolean ptpEnabled = true;
/* Toggles */
private boolean loaded;
@ -1235,4 +1236,12 @@ public class PlayerProfile {
public void removeInvite() {
invite = null;
}
public boolean getPtpEnabled() {
return ptpEnabled;
}
public void togglePtpUse() {
ptpEnabled = !ptpEnabled;
}
}

View File

@ -39,6 +39,10 @@ public class PtpCommand implements CommandExecutor {
Player player = (Player) sender;
PlayerProfile profile = Users.getProfile(player);
if (args[0].equalsIgnoreCase("toggle")) {
return toggle(sender, args);
}
if (profile.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
return true;
@ -62,17 +66,21 @@ public class PtpCommand implements CommandExecutor {
}
if (PartyManager.inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
plugin.getServer().getPluginManager().callEvent(event);
if (Users.getProfile(target).getPtpEnabled()) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
if (event.isCancelled()) {
return true;
}
player.teleport(target);
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { target.getName() }));
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { player.getName() }));
profile.setRecentlyHurt(System.currentTimeMillis());
} else {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", new Object[] { target.getName() }));
}
player.teleport(target);
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { target.getName() }));
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { player.getName() }));
profile.setRecentlyHurt(System.currentTimeMillis());
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
@ -86,4 +94,19 @@ public class PtpCommand implements CommandExecutor {
return true;
}
}
private boolean toggle(CommandSender sender, String[] args) {
Player player = (Player) sender;
PlayerProfile profile = Users.getProfile(player);
if (profile.getPtpEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
}
profile.togglePtpUse();
return true;
}
}

View File

@ -461,6 +461,8 @@ Commands.Party.Quit=[[RED]]- Leave your current party
Commands.Party.Teleport=<player> [[RED]]- Teleport to party member
Commands.Party.Toggle=[[RED]]- Toggle Party Chat
Commands.Party=<party-name> [[RED]]- Create/Join designated party
Commands.ptp.Enabled=Party teleporting [[GREEN]]enabled
Commands.ptp.Disabled=Party teleporting [[RED]]disabled
Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--
Commands.PowerLevel.Capped=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} [[DARK_RED]]MAX LEVEL: [[YELLOW]]{1}
Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0}
@ -523,6 +525,7 @@ Party.Teleport.Hurt=[[RED]]You've been hurt in the last {0} seconds and cannnot
Party.Teleport.Player=[[GREEN]]You have teleported to {0}.
Party.Teleport.Self=[[RED]]You can't teleport to yourself!
Party.Teleport.Target=[[GREEN]]{0} has teleported to you.
Party.Teleport.Disabled=[[RED]]{0} doesn't allow party teleportation.
Party.Unlocked=[[GRAY]]Party is unlocked
Party.Disband=[[GRAY]]The party has been disbanded
Party.Status.Locked=[[DARK_RED]](INVITE-ONLY)