Skip to content

Commit

Permalink
Add '/promote' Command
Browse files Browse the repository at this point in the history
- Fix a bug where the wrong message was sent to players who join.
- Add a '/promote [<player>]' command that is an alias of the '/prom update <player_default_target> [<player>]' command.
- Update the help command.
- Remove some unnecessary comments.
  • Loading branch information
aappleton8 committed Sep 30, 2018
1 parent 56aae5b commit bf0563c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 12 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion PromoteOneself/Information.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is a general plugin information file that is shipped inside the exported .jar file of the plugin. More information can be found on this plugin's GitHub page. This file was last updated for plugin version 1.0.0.2.
This is a general plugin information file that is shipped inside the exported .jar file of the plugin. More information can be found on this plugin's GitHub page. This file was last updated for plugin version 1.0.0.3.


Commands:
Expand Down
5 changes: 4 additions & 1 deletion PromoteOneself/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: PromoteOneself
main: me.PromoteOneselfPackage.PromoteOneself.Classes.PromoteOneselfMainClass
version: 1.0.0.2
version: 1.0.0.3
description: A plugin which lets people achieve aims to work up through a server's ranking system
author: aappleton3
database: false
Expand All @@ -9,6 +9,9 @@ commands:
promoteoneself:
description: Command to show the command for help
usage: /promoteoneself
promote:
description: An alternative form of the command /prom update <default_next_target> [<player>]
usage: /promote [<player>]
prom:
description: Commands that update a player's status
usage: /prom <arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void helpPages(CommandSender sender, int page) {
sender.sendMessage(ChatColor.AQUA + "/posset reload [argument]" + ChatColor.WHITE + " - Reload the plugin's configuration files ");
sender.sendMessage(ChatColor.AQUA + "/posset player <arguments>" + ChatColor.WHITE + " - Reset, add or remove a player in, to or from the promotion tree ");
sender.sendMessage(ChatColor.AQUA + "/posset set <arguments>" + ChatColor.WHITE + " - Set various values for players, aim, targets and settings ");
sender.sendMessage(ChatColor.AQUA + "/promote [<player>]" + ChatColor.WHITE + " - An alias of " + ChatColor.AQUA + "/prom update <default_next_target> [<player>] ");
}
}
public void helpCommand(CommandSender sender, String command, String firstArgument) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ else if (plugin.yc.configuration.getBoolean("startInPromotionTree") == true) {
ua.addPlayer(defaultFirstTarget, spId, rpId, true);
}
if ((exempt == false) && plugin.yc.configuration.getBoolean("remindOnJoin")) {
if (plugin.yd.configuration.getBoolean("players." + spId + ".finished") == true) {
if (plugin.yd.configuration.getBoolean("players." + spId + ".finished") == false) {
String target = plugin.yd.configuration.getString("players." + spId + ".target");
Bukkit.getPlayer(rpId).sendMessage(ChatColor.AQUA + plugin.logger.getName(true) + "Your current target (" + target + ") requires the aims: " + plugin.yc.configuration.getStringList("targets." + target + ".aims"));
}
else if (plugin.yd.configuration.getBoolean("players." + spId + ".finished") == false) {
else if (plugin.yd.configuration.getBoolean("players." + spId + ".finished") == true) {
Bukkit.getPlayer(rpId).sendMessage(ChatColor.GREEN + plugin.logger.getName(true) + "You have obtained the highest self-promotion possible. ");
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import java.util.Set;

import org.bukkit.ChatColor;
//import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
//import org.bukkit.entity.Player;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
Expand All @@ -18,7 +18,7 @@

import org.black_ixx.playerpoints.PlayerPoints;

public class PromoteOneselfMainClass extends JavaPlugin{
public class PromoteOneselfMainClass extends JavaPlugin implements CommandExecutor {
public static PromoteOneselfMainClass plugin;

public final LoggingClass logger = new LoggingClass(this, "Minecraft");
Expand Down Expand Up @@ -127,7 +127,24 @@ public void saveConfig() {
}

public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (commandLabel.equalsIgnoreCase("promoteoneself")) {
if (commandLabel.equalsIgnoreCase("promote")) {
if (args.length == 0) {
if (sender instanceof Player) {
ua.promoteCommand(sender, ((Player)sender).getName());
}
else {
logger.messageSender(sender, "wrongarrangement", "");
}
}
else if (args.length == 1) {
ua.promoteCommand(sender, args[0]);
}
else {
logger.messageSender(sender, "help", null);
return false;
}
}
else if (commandLabel.equalsIgnoreCase("promoteoneself")) {
ch.helpPages(sender);
}
else if (commandLabel.equalsIgnoreCase("prom")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,15 +726,12 @@ else if (plugin.yc.configuration.getString("aims." + i + ".type").equalsIgnoreCa
player.sendMessage("Your target is now " + nextTarget);
}
if (runTheCommands == false) {
//sender.sendMessage("runTheCommands == false");
// No action required
}
else if (plugin.yc.configuration.getString("targets." + target + ".commands").equalsIgnoreCase("none")) {
//sender.sendMessage("As a string, no commands");
// No action required
}
else if (plugin.yc.configuration.getStringList("targets." + target + ".commands").get(0).equalsIgnoreCase("none")) {
//sender.sendMessage("As a list, no commands");
// No action required
}
else {
Expand All @@ -748,4 +745,24 @@ else if (plugin.yc.configuration.getStringList("targets." + target + ".commands"
sender.sendMessage(ChatColor.RED + "The specified target is not a valid target to progress to ");
}
}

public void promoteCommand(CommandSender sender, String playerName) {
@SuppressWarnings("deprecation")
Player player = Bukkit.getPlayer(playerName);
if (player == null) {
logger.messageSender(sender, "offline", ", it could be offline ");
}
else {
UUID rpId = player.getUniqueId();
String spId = rpId.toString();
if (plugin.yc.configuration.contains("players." + spId)) {
String nextTarget = plugin.yc.configuration.getString("targets." + plugin.yd.configuration.getString("players." + spId + ".target") + ".defaultNextTarget");
String[] args = { "update", nextTarget, playerName };
updatePlayer(sender, args);
}
else {
logger.messageSender(sender, "noplayer", playerName);
}
}
}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ This plugin contains the following commands:
- /promoteoneself
- /prom &lt;arguments&gt;
- /posset &lt;arguments&gt;
- /promote [&lt;player&gt;]

The */promoteoneself* command shows the help page. \
The */prom help [&lt;page&gt;]* command shows the top level help pages. \
Expand Down Expand Up @@ -89,7 +90,8 @@ The */posset set setting updateUsernames true|false* command sets whether the pl
The */posset set setting defaultPoints &lt;integer&gt;* command sets the default number of points players should have. \
The */posset set setting alwaysSaveFiles true|false* command sets whether configuration files the plugin couldn't load properly should be saved regardless (this may wipe the files). \
The */posset set setting remindOnJoin true|false* command sets whether the plugin should send a reminder to players each time they join. \
The */posset set sign &lt;sign-id&gt; usage &lt;integer&gt;* command sets the maximum usage allowed by a sign.
The */posset set sign &lt;sign-id&gt; usage &lt;integer&gt;* command sets the maximum usage allowed by a sign. \
The */promote [&lt;player&gt;]* command is an alias of the */prom update &lt;player_default_next_target&gt; [&lt;player&gt;]* command.

Where applicable, commands of the form */prom update &lt;arguments&gt;*, */posset player &lt;arguments&gt;*, */posset exempt &ltarguments&gt;* and */posset set player &lt;arguments&gt;* only work for players which are currently online.

Expand Down

0 comments on commit bf0563c

Please sign in to comment.