Add prefix, nickname, chat colors
This commit is contained in:
parent
c5e8f1cc54
commit
707b99f58d
12 changed files with 544 additions and 16 deletions
|
@ -127,7 +127,7 @@ public class HomeCommand {
|
|||
|
||||
MobEffectInstance inst = new MobEffectInstance(MobEffects.DARKNESS, 200, 1, true, true);
|
||||
MobEffectInstance regen = new MobEffectInstance(MobEffects.REGENERATION, 200, 1, true, true);
|
||||
MobEffectInstance invul = new MobEffectInstance(MobEffects.LEVITATION, 200, 1, true, true);
|
||||
MobEffectInstance invul = new MobEffectInstance(MobEffects.LEVITATION, 75, 1, true, true);
|
||||
|
||||
|
||||
p.addEffect(inst);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package dev.zontreck.otemod.commands;
|
||||
|
||||
public class TPACommand {
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatColor;
|
||||
import dev.zontreck.otemod.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.otemod.configs.Profile;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class ChatColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("ccolor")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||
)
|
||||
);
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
||||
|
||||
// Chat Color has a registry of colors that we can use to map back to our desired color
|
||||
String actual_color = string.toString();
|
||||
// To code
|
||||
String colorcoded = ChatColor.from(actual_color);
|
||||
|
||||
// Get profile
|
||||
if(source.getPlayer()==null){
|
||||
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
|
||||
return 1;
|
||||
}
|
||||
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
|
||||
p.chat_color = colorcoded;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(Component.literal(ChatColor.DARK_GRAY+ "["+ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE + "Your chat color has been updated"), false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatColor;
|
||||
import dev.zontreck.otemod.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.otemod.configs.Profile;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class NameColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("ncolor")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||
)
|
||||
);
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
||||
|
||||
// Chat Color has a registry of colors that we can use to map back to our desired color
|
||||
String actual_color = string.toString();
|
||||
// To code
|
||||
String colorcoded = ChatColor.from(actual_color);
|
||||
|
||||
// Get profile
|
||||
if(source.getPlayer()==null){
|
||||
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
|
||||
return 1;
|
||||
}
|
||||
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
|
||||
p.name_color = colorcoded;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(Component.literal(ChatColor.DARK_GRAY+ "["+ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE + "Your name color has been updated"), false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatColor;
|
||||
import dev.zontreck.otemod.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.otemod.configs.Profile;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class NickCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("nick")
|
||||
.executes(c->setchatcolor(c.getSource(), c.getSource().getPlayer().getName().getString()))
|
||||
.then(Commands.argument("new_name", StringArgumentType.string())//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), StringArgumentType.getString(c, "new_name")))// EnumArgument.getS(c, "color")))
|
||||
)
|
||||
);
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||
|
||||
// Get profile
|
||||
if(source.getPlayer()==null){
|
||||
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
|
||||
return 1;
|
||||
}
|
||||
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
|
||||
p.nickname = string;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(Component.literal(ChatColor.DARK_GRAY+ "["+ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE + "Your nickname has been updated"), false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatColor;
|
||||
import dev.zontreck.otemod.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.otemod.configs.Profile;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class PrefixColorCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("pcolor")
|
||||
.executes(c->setchatcolor(c.getSource(), ColorOptions.White))
|
||||
.then(Commands.argument("color", EnumArgument.enumArgument(ChatColor.ColorOptions.class))//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), c.getArgument("color", ChatColor.ColorOptions.class)))// EnumArgument.getS(c, "color")))
|
||||
)
|
||||
);
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, ColorOptions string) {
|
||||
|
||||
// Chat Color has a registry of colors that we can use to map back to our desired color
|
||||
String actual_color = string.toString();
|
||||
// To code
|
||||
String colorcoded = ChatColor.from(actual_color);
|
||||
|
||||
// Get profile
|
||||
if(source.getPlayer()==null){
|
||||
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
|
||||
return 1;
|
||||
}
|
||||
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
|
||||
p.name_color = colorcoded;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(Component.literal(ChatColor.DARK_GRAY+ "["+ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE + "Your prefix color has been updated"), false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package dev.zontreck.otemod.commands.profilecmds;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatColor;
|
||||
import dev.zontreck.otemod.chat.ChatColor.ColorOptions;
|
||||
import dev.zontreck.otemod.configs.Profile;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.server.command.EnumArgument;
|
||||
|
||||
public class PrefixCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("prefix")
|
||||
.executes(c->setchatcolor(c.getSource(), "Member"))
|
||||
.then(Commands.argument("new_prefix", StringArgumentType.string())//StringArgumentType.string())
|
||||
.executes(c -> setchatcolor(c.getSource(), StringArgumentType.getString(c, "new_prefix")))// EnumArgument.getS(c, "color")))
|
||||
)
|
||||
);
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
public static int setchatcolor(CommandSourceStack source, String string) {
|
||||
|
||||
// Get profile
|
||||
if(source.getPlayer()==null){
|
||||
source.sendFailure(Component.literal(ChatColor.DARK_RED+"Only a player can use this command"));
|
||||
return 1;
|
||||
}
|
||||
Profile p = Profile.get_profile_of(source.getPlayer().getStringUUID());
|
||||
p.prefix = string;
|
||||
p.commit();
|
||||
OTEMod.PROFILES.put(source.getPlayer().getStringUUID(), p);
|
||||
|
||||
source.sendSuccess(Component.literal(ChatColor.DARK_GRAY+ "["+ChatColor.DARK_GREEN+ "OTEMOD" + ChatColor.DARK_GRAY + "] "+ChatColor.DARK_PURPLE + "Your prefix has been updated"), false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in a new issue