+feat: !reinv party command
This commit is contained in:
parent
2eb2d72501
commit
c8ee41d99d
2 changed files with 30 additions and 11 deletions
|
@ -3,5 +3,5 @@ org.gradle.jvmargs=-Xmx2g
|
||||||
baseGroup = xyz.stachel.bonzotimer
|
baseGroup = xyz.stachel.bonzotimer
|
||||||
mcVersion = 1.8.9
|
mcVersion = 1.8.9
|
||||||
modid = bonzo-timer
|
modid = bonzo-timer
|
||||||
version = 1.2.5
|
version = 1.3.0
|
||||||
org.gradle.java.installations.fromEnv=JDK8,JRE17
|
org.gradle.java.installations.fromEnv=JDK8,JRE17
|
||||||
|
|
|
@ -10,19 +10,23 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class ChatHandler {
|
public class ChatHandler {
|
||||||
private static final Pattern PARTY_PATTERN = Pattern.compile("Party > (?:(?:\\[VIP\\+?]|\\[MVP\\+?\\+?]) )?([a-zA-Z0-9_]{2,16}): (.*)");
|
private static final String PLAYER_PATTERN = "(?:\\[(?:VIP\\+?|MVP\\+{0,2}|YOUTUBE|MOD|ADMIN)\\] )?([a-zA-Z0-9_]{2,16})";
|
||||||
private static final Pattern TRANSFER_PATTERN = Pattern.compile("The party was transferred to (?:\\[(?:VIP\\+?|MVP\\+{0,2}|YOUTUBE|MOD|ADMIN)\\] )?([a-zA-Z0-9_]{2,16}) by (?:\\[(?:VIP\\+?|MVP\\+{0,2}|YOUTUBE|MOD|ADMIN)\\] )?([a-zA-Z0-9_]{2,16})");
|
private static final Pattern PARTY_PATTERN = Pattern.compile("Party > " + PLAYER_PATTERN + ": (.*)");
|
||||||
private static final Pattern PROMOTE_PATTERN = Pattern.compile("(?:\\[(?:VIP\\+?|MVP\\+{0,2}|YOUTUBE|MOD|ADMIN)\\])?([a-zA-Z0-9_]{2,16}) has promoted (?:\\[(?:VIP\\+?|MVP\\+{0,2}|YOUTUBE|MOD|ADMIN)\\] )?([a-zA-Z0-9_]{2,16}) to Party Leader");
|
private static final Pattern TRANSFER_PATTERN = Pattern.compile("The party was transferred to " + PLAYER_PATTERN +" by " + PLAYER_PATTERN);
|
||||||
private static final String[] COLOR_MAPPING = { "§6ORANGE", "§aGREEN", "§4RED" ,"§9BLUE", "§5PRPLX" };
|
private static final Pattern PROMOTE_PATTERN = Pattern.compile(PLAYER_PATTERN + " has promoted " + PLAYER_PATTERN + " to Party Leader");
|
||||||
|
private static final Pattern LEAVE_PATTERN = Pattern.compile(PLAYER_PATTERN + " has left the party.");
|
||||||
|
//private static final String[] COLOR_MAPPING = { "§6ORANGE", "§aGREEN", "§4RED" ,"§9BLUE", "§5PRPLX" };
|
||||||
private int transferCountdown = 0;
|
private int transferCountdown = 0;
|
||||||
private boolean autotransferEnabled = false;
|
private boolean autotransferEnabled = false;
|
||||||
private int colorChangeCooldown = 0;
|
//private int colorChangeCooldown = 0;
|
||||||
private int color = 0;
|
//private int color = 0;
|
||||||
private String oldLeader = null;
|
private String oldLeader = null;
|
||||||
|
private HashMap<String, Byte> rejoiners = new HashMap<>();
|
||||||
|
|
||||||
public void setTransferEnabled(boolean b) {
|
public void setTransferEnabled(boolean b) {
|
||||||
this.autotransferEnabled = b;
|
this.autotransferEnabled = b;
|
||||||
|
@ -30,17 +34,20 @@ public class ChatHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTick(TickEvent.@NotNull ClientTickEvent event) {
|
public void onTick(TickEvent.@NotNull ClientTickEvent event) {
|
||||||
if (colorChangeCooldown > 0) {
|
/*if (colorChangeCooldown > 0) {
|
||||||
colorChangeCooldown--;
|
colorChangeCooldown--;
|
||||||
} else {
|
} else {
|
||||||
color = 0;
|
color = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (transferCountdown > 1) {
|
if (transferCountdown > 1) {
|
||||||
transferCountdown--;
|
transferCountdown--;
|
||||||
} else if (transferCountdown == 1 && Minecraft.getMinecraft().thePlayer != null && this.oldLeader != null) {
|
} else if (transferCountdown == 1 && Minecraft.getMinecraft().thePlayer != null && this.oldLeader != null) {
|
||||||
transferCountdown--;
|
transferCountdown--;
|
||||||
Minecraft.getMinecraft().thePlayer.sendChatMessage("/p transfer " + this.oldLeader);
|
Minecraft.getMinecraft().thePlayer.sendChatMessage("/p transfer " + this.oldLeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rejoiners.replaceAll((k, v) -> v > 0 ? (byte)(v - 1) : v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -85,6 +92,10 @@ public class ChatHandler {
|
||||||
case "!allinvite":
|
case "!allinvite":
|
||||||
case "!allinv":
|
case "!allinv":
|
||||||
Minecraft.getMinecraft().thePlayer.sendChatMessage("/p settings allinvite");
|
Minecraft.getMinecraft().thePlayer.sendChatMessage("/p settings allinvite");
|
||||||
|
break;
|
||||||
|
case "!reinv":
|
||||||
|
rejoiners.put(user, (byte) 100);
|
||||||
|
break;
|
||||||
case "!ptme":
|
case "!ptme":
|
||||||
event.message.appendSibling(
|
event.message.appendSibling(
|
||||||
new ChatComponentText(" [ACCEPT]")
|
new ChatComponentText(" [ACCEPT]")
|
||||||
|
@ -113,15 +124,23 @@ public class ChatHandler {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Matcher leave = LEAVE_PATTERN.matcher(strippedMessage);
|
||||||
|
if (leave.matches()) {
|
||||||
|
final String leaver = leave.group(1).trim();
|
||||||
|
if (rejoiners.getOrDefault(leaver, (byte) 0) != 0) {
|
||||||
|
Minecraft.getMinecraft().thePlayer.sendChatMessage("/party invite " + leaver);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeColor(final int color) {
|
/* private void changeColor(final int color) {
|
||||||
if (this.color < color || this.colorChangeCooldown == 0) {
|
if (this.color < color || this.colorChangeCooldown == 0) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.colorChangeCooldown = 10;
|
this.colorChangeCooldown = 10;
|
||||||
final String title = ChatHandler.COLOR_MAPPING[color-1];
|
final String title = ChatHandler.COLOR_MAPPING[color-1];
|
||||||
Minecraft.getMinecraft().ingameGUI.displayTitle(title, "", 0, 5, 1);
|
Minecraft.getMinecraft().ingameGUI.displayTitle(title, "", 0, 5, 1);
|
||||||
};
|
};
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue