diff --git a/Changelog.txt b/Changelog.txt index afffbfa26..fb48a4cd8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -15,6 +15,7 @@ Version 1.4.00-dev + Added '/party create ' 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. diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index f13d58700..faf7bc3c9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -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; + } } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java index e1073cde2..45b148bf0 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java @@ -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,54 +51,100 @@ public class PtpCommand implements CommandExecutor { return true; } - Player target = plugin.getServer().getPlayer(args[0]); - - if (player.equals(target)) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); - return true; - } - - if (target == null) { - player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); - return true; - } - - if (target.isDead()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); - return true; - } - - if (PartyManager.inSameParty(player, target)) { - if (Users.getProfile(target).getPtpEnabled()) { - McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.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()); - } else { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", new Object[] { target.getName() })); - } + if (args[0].equalsIgnoreCase("accept")) { + return acceptTeleportRequest(sender, args); } else { - player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() })); - return true; + return sendTeleportRequest(sender, args); } - return true; - default: sender.sendMessage(usage); return true; } } - private boolean toggle(CommandSender sender, String[] args) { + private boolean sendTeleportRequest(CommandSender sender, String[] args) { + Player player = (Player) sender; + Player target = plugin.getServer().getPlayer(args[0]); + + if (player.equals(target)) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); + return true; + } + + if (target == null) { + player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + return true; + } + + if (target.isDead()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); + return true; + } + + if (PartyManager.inSameParty(player, target)) { + if (Users.getProfile(target).getPtpEnabled()) { + 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; + } + + 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("Commands.ptp.NoRequests")); + } + return true; + } + + private boolean denyTeleportRequest(CommandSender sender, String[] args) { + Player player = (Player) sender; + PlayerProfile playerProfile = Users.getProfile(player); + + 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 togglePartyTeleportation(CommandSender sender, String[] args) { Player player = (Player) sender; PlayerProfile profile = Users.getProfile(player); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 4794f1b87..22425fe9d 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -463,6 +463,10 @@ Commands.Party.Toggle=[[RED]]- Toggle Party Chat Commands.Party= [[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)