Skip to content

Commit

Permalink
Change Messaging Order
Browse files Browse the repository at this point in the history
  • Loading branch information
KAMKEEL committed Oct 27, 2021
1 parent edd277e commit 8aac47e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
62 changes: 52 additions & 10 deletions src/kamkeel/RPGMessenger/Commands/CommandTemp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,43 @@ public class CommandTemp implements CommandDefault {

// -------------------------------------------------| Temp Commands
public void TempMSG(CommandSender sender, String label, String[] args){
// /tmpmsg Player(0) CustomName(1) MSG(2)
if(args.length > 2){
Player target = findPlayer(args[0]);
if(target != null){
NPC tempNPC = new NPC(args[1]);

int tempIndex = tempControl.npcExactIndex( tempNPC );

if(tempIndex != -1){
tempNPC = tempControl.getNPC(tempIndex);
}
else{
tempControl.npcAdd(tempNPC);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
tempControl.npcRemove(args[1]);
}
}, 1200 * plugin.getConfig().getInt("Time"));
}

String allArgs = layoutString(2, args);

Bukkit.getConsoleSender().sendMessage(getSpyFormat(1, tempNPC.getDisplayName(), target.getDisplayName(), allArgs));
formMessage(target, tempNPC.getDisplayName(), true, allArgs);
sendSpyMessage(sender, 1, true, tempNPC.getDisplayName(), target.getDisplayName(), allArgs);

setReply(target.getName(), tempNPC.getDisplayName(), 0);
}
else{
sender.sendMessage(RPGStringHelper.COLOR_TAG + "§4Could not find player!");
}
}
else{
sender.sendMessage(RPGStringHelper.COLOR_TAG + "§c/" + label + " §6NewName §ePlayer §7Message");
}
}
public void TempMSGLegacy(CommandSender sender, String label, String[] args){
// /tmpmsg CustomName(0) Player(1) MSG(2)
if(args.length > 2){
Player target = findPlayer(args[1]);
Expand Down Expand Up @@ -52,11 +89,11 @@ public void run() {
}
}
public void TempLocal(CommandSender sender, String label, String[] args){
// /tmplocal CustomName(0) Player(1) MSG(2)
// /tmplocal Player(0) CustomName(1) MSG(2)
if(args.length > 2){
Player target = findPlayer(args[1]);
Player target = findPlayer(args[0]);
if(target != null){
NPC tempNPC = new NPC(args[0]);
NPC tempNPC = new NPC(args[1]);

int tempIndex = tempControl.npcExactIndex( tempNPC );

Expand All @@ -67,7 +104,7 @@ public void TempLocal(CommandSender sender, String label, String[] args){
tempControl.npcAdd(tempNPC);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
tempControl.npcRemove(args[0]);
tempControl.npcRemove(args[1]);
}
}, 1200 * plugin.getConfig().getInt("Time"));
}
Expand All @@ -90,19 +127,19 @@ public void run() {
}
}
public void TempGroup(CommandSender sender, String label, String[] args){
// /tmpgroup CustomName(0) Group(1) MSG(2)
// /tmpgroup Group(0) CustomName(1) MSG(2)
if(args.length > 2) {
int groupIndex;
try {
groupIndex = Integer.parseInt(args[1]) - 1;
groupIndex = Integer.parseInt(args[0]) - 1;
} catch (NumberFormatException iobe) {
groupIndex = groupControl.groupIndex(args[1]);
groupIndex = groupControl.groupIndex(args[0]);
}

if (groupIndex > -1 && groupControl.validIndex(groupIndex)) {

String allArgs = layoutString(2, args);
NPC tempNPC = new NPC(args[0]);
NPC tempNPC = new NPC(args[1]);

int tempIndex = tempControl.npcExactIndex( tempNPC );

Expand All @@ -113,7 +150,7 @@ public void TempGroup(CommandSender sender, String label, String[] args){
tempControl.npcAdd(tempNPC);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
tempControl.npcRemove(args[0]);
tempControl.npcRemove(args[1]);
}
}, 1200 * plugin.getConfig().getInt("Time"));
}
Expand Down Expand Up @@ -218,7 +255,12 @@ public void runCMD(CommandSender sender, String label, String[] args) {
if(label.equalsIgnoreCase("tmpmsg") || label.equalsIgnoreCase("tm")
|| label.equalsIgnoreCase("fma") || label.equalsIgnoreCase("tma")
|| label.equalsIgnoreCase("tidm")) {
TempMSG(sender, label, args);
if(label.equalsIgnoreCase("fma")){
TempMSGLegacy(sender, label, args);
}
else {
TempMSG(sender, label, args);
}
}
else if(label.equalsIgnoreCase("tmpgroup") || label.equalsIgnoreCase("tidg")
|| label.equalsIgnoreCase("tga")) {
Expand Down
2 changes: 1 addition & 1 deletion src/kamkeel/RPGMessenger/RPGCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ else if(label.equalsIgnoreCase("ns") || label.equalsIgnoreCase("npcsay") ||
sender.sendMessage("Usage: /" + label + " <NPCName/ID>" + " <message>");
}
}
else{
else {
// npcmsg Player (0) NPC/ID (1) chat (2)
if (args.length > 2) {

Expand Down

0 comments on commit 8aac47e

Please sign in to comment.