mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Party teleportation now requires the target player to confirm the teleport request before the teleportation takes place.
This commit is contained in:
parent
765199eba3
commit
d744c6a46d
@ -15,6 +15,7 @@ Version 1.4.00-dev
|
||||
+ Added '/party create <name>' command, use this to create a party
|
||||
+ Added '/party disband' command, kicks out all members and deletes the party
|
||||
+ Added '/ptp toggle' command, to disable party teleportation.
|
||||
+ Added '/ptp accept' and '/ptp deny' commands
|
||||
= Fixed mod config files loading / generating when they shouldn't have
|
||||
= Fixed bug where Green Terra could activate on crops that weren't fully grown.
|
||||
= Fixed several typos relating to locale string display
|
||||
@ -42,6 +43,7 @@ Version 1.4.00-dev
|
||||
! Changed the way party commands work, use /party ? to check how to use the new commands
|
||||
! Changed McMMOChatEvent to contain the plugin that the event originated from.
|
||||
! Changed Excavation to have individual XP values for each block type, rather than a base XP value.
|
||||
! Changed the way party teleportation works. When using /ptp, the target player needs to confirm the teleport before it takes place.
|
||||
|
||||
Version 1.3.14
|
||||
+ Added new Hylian Luck skill to Herbalism.
|
||||
|
@ -31,6 +31,7 @@ public class PlayerProfile {
|
||||
/* Party Stuff */
|
||||
private Party party;
|
||||
private Party invite;
|
||||
private String ptpRequest;
|
||||
private boolean ptpEnabled = true;
|
||||
|
||||
/* Toggles */
|
||||
@ -1244,4 +1245,24 @@ public class PlayerProfile {
|
||||
public void togglePtpUse() {
|
||||
ptpEnabled = !ptpEnabled;
|
||||
}
|
||||
|
||||
public void setPtpRequest(String ptpRequest) {
|
||||
this.ptpRequest = ptpRequest;
|
||||
}
|
||||
|
||||
public String getPtpRequest() {
|
||||
return ptpRequest;
|
||||
}
|
||||
|
||||
public boolean hasPtpRequest() {
|
||||
if (ptpRequest != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removePtpRequest() {
|
||||
ptpRequest = null;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,10 @@ public class PtpCommand implements CommandExecutor {
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
return toggle(sender, args);
|
||||
return togglePartyTeleportation(sender, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("deny")) {
|
||||
return denyTeleportRequest(sender, args);
|
||||
}
|
||||
|
||||
if (profile.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
|
||||
@ -48,6 +51,21 @@ public class PtpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("accept")) {
|
||||
return acceptTeleportRequest(sender, args);
|
||||
}
|
||||
else {
|
||||
return sendTeleportRequest(sender, args);
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sendTeleportRequest(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if (player.equals(target)) {
|
||||
@ -67,35 +85,66 @@ public class PtpCommand implements CommandExecutor {
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
if (Users.getProfile(target).getPtpEnabled()) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
|
||||
Users.getProfile(target).setPtpRequest(player.getName());
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request", new Object[] {player.getName()}));
|
||||
return true;
|
||||
}else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", new Object[] { target.getName() }));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean acceptTeleportRequest(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (playerProfile.hasPtpRequest()) {
|
||||
|
||||
Player target = plugin.getServer().getPlayer(playerProfile.getPtpRequest());
|
||||
|
||||
if (Users.getProfile(target).getPtpEnabled()) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, playerProfile.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
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());
|
||||
target.teleport(player);
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { player.getName() }));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { target.getName() }));
|
||||
playerProfile.setRecentlyHurt(System.currentTimeMillis());
|
||||
} else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", new Object[] { target.getName() }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
private boolean denyTeleportRequest(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
if (playerProfile.hasPtpRequest()) {
|
||||
Player target = plugin.getServer().getPlayer(playerProfile.getPtpRequest());
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Deny"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Denied", new Object[] { player.getName() }));
|
||||
playerProfile.removePtpRequest();
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean toggle(CommandSender sender, String[] args) {
|
||||
private boolean togglePartyTeleportation(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
|
@ -463,6 +463,10 @@ 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.ptp.NoRequests=[[RED]]You have no teleport requests at this time
|
||||
Commands.ptp.Request=[[YELLOW]]{0} [[GREEN]]wants to teleport to you. Use [[YELLOW]]/ptp accept [[GREEN]]or [[YELLOW]]/ptp deny
|
||||
Commands.ptp.Deny=[[YELLOW]]Teleport request denied.
|
||||
Commands.ptp.Denied=[[RED]]{0} has denied your teleport request.
|
||||
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}
|
||||
@ -526,6 +530,7 @@ 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.Join.Self=[[RED]]You can't join to yourself!
|
||||
Party.Unlocked=[[GRAY]]Party is unlocked
|
||||
Party.Disband=[[GRAY]]The party has been disbanded
|
||||
Party.Status.Locked=[[DARK_RED]](INVITE-ONLY)
|
||||
|
Loading…
Reference in New Issue
Block a user