Move more messages into the central location
This commit is contained in:
parent
984cb45b02
commit
6eaab7c7ee
6 changed files with 54 additions and 8 deletions
|
@ -20,9 +20,21 @@ public class Messages {
|
|||
public static final String PUBLIC;
|
||||
public static final String PRIVATE;
|
||||
|
||||
public static final String WARP_NAME_REQUIRED;
|
||||
public static final String WARP_NOT_EXIST;
|
||||
public static final String WARP_ATTEMPTING;
|
||||
public static final String WARPING;
|
||||
public static final String WARP_CREATED;
|
||||
public static final String WARP_CREATE_ERROR;
|
||||
public static final String WARP_RTP_CREATED;
|
||||
|
||||
static{
|
||||
ESSENTIALS_PREFIX = "!Gray![!Dark_Green!AE!Gray!] ";
|
||||
|
||||
WARP_ATTEMPTING = ESSENTIALS_PREFIX + "!Dark_Green!Attempting to find a safe landing location. This may take a minute";
|
||||
WARPING = ESSENTIALS_PREFIX+"!Dark_green!Warping";
|
||||
|
||||
|
||||
RTP_SEARCHING = ESSENTIALS_PREFIX + "!Dark_Purple!Searching... Attempt !Gold![0]!White!/!Dark_Red![1]";
|
||||
RTP_CANCELLED = ESSENTIALS_PREFIX + "!Dark_Red!Last position was good, but another mod asked us not to send you there. This could happen with a claims mod.";
|
||||
RTP_ABORTED = ESSENTIALS_PREFIX + "!Dark_Red!Could not find a suitable location in [0] attempts. Giving up. [1]";
|
||||
|
@ -38,5 +50,13 @@ public class Messages {
|
|||
WARP_ACCESS_FORMAT = "!Dark_Purple!This warp is [0]";
|
||||
PUBLIC = "!Dark_Green!Public";
|
||||
PRIVATE = "!Dark_Red!Private";
|
||||
|
||||
WARP_NAME_REQUIRED = ESSENTIALS_PREFIX + "!Dark_Red!The warp name is required in order to warp. You can click this message to get a full list of the warps you have access to.";
|
||||
WARP_NOT_EXIST = ESSENTIALS_PREFIX + "!Dark_Red!No Such Warp";
|
||||
|
||||
WARP_CREATED = ESSENTIALS_PREFIX + "!Dark_Green!Warp created successfully";
|
||||
WARP_CREATE_ERROR = ESSENTIALS_PREFIX + "!Dark_Red!Warp could not be created due to [0]";
|
||||
|
||||
WARP_RTP_CREATED = WARP_CREATED+" with RTP properties";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
|||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.essentials.events.WarpCreatedEvent;
|
||||
import dev.zontreck.essentials.warps.Warp;
|
||||
import dev.zontreck.essentials.warps.WarpsProvider;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
|
@ -23,6 +24,7 @@ import net.minecraft.network.chat.TranslatableComponent;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class RTPWarpCommand {
|
||||
|
||||
|
@ -45,10 +47,16 @@ public class RTPWarpCommand {
|
|||
|
||||
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
|
||||
Warp warp = new Warp(p.getUUID(), string, true, true, dest);
|
||||
WarpCreatedEvent event = new WarpCreatedEvent(warp);
|
||||
if(MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARP_CREATE_ERROR)), p.server);
|
||||
return 0;
|
||||
}
|
||||
WarpsProvider.WARPS_INSTANCE.add(warp);
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX+ChatColor.doColors(" !Dark_Green!Random Position Teleport (RTP) Warp created successfully")), p.server);
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARP_RTP_CREATED)), p.server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
|||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.essentials.events.WarpCreatedEvent;
|
||||
import dev.zontreck.essentials.warps.Warp;
|
||||
import dev.zontreck.essentials.warps.WarpsProvider;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
|
@ -23,6 +24,7 @@ import net.minecraft.network.chat.TranslatableComponent;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class SetWarpCommand {
|
||||
|
||||
|
@ -46,9 +48,14 @@ public class SetWarpCommand {
|
|||
|
||||
TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel());
|
||||
Warp w = new Warp(p.getUUID(), string, false, true, dest);
|
||||
WarpCreatedEvent event = new WarpCreatedEvent(w);
|
||||
if(MinecraftForge.EVENT_BUS.post(event)){
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARP_CREATE_ERROR, event.denyReason)), p.server);
|
||||
return 0;
|
||||
}
|
||||
WarpsProvider.WARPS_INSTANCE.add(w);
|
||||
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX+ChatColor.doColors(" !Dark_Green!Warp created successfully")), p.server);
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARP_CREATED)), p.server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ public class WarpCommand {
|
|||
|
||||
if(type == 1)
|
||||
{
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX+ ChatColor.doColors(" !Dark_Green!Attempting to locate a safe location. This may take a minute or two")), p.server);
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARP_ATTEMPTING)), p.server);
|
||||
}else{
|
||||
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(Messages.ESSENTIALS_PREFIX+ ChatColor.doColors(" !Dark_Purple!Warping!")), p.server);
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARPING)), p.server);
|
||||
}
|
||||
|
||||
Thread tx = new Thread(new Runnable(){
|
||||
|
@ -92,7 +92,7 @@ public class WarpCommand {
|
|||
tx.start();
|
||||
}catch(NoSuchWarpException e)
|
||||
{
|
||||
ChatHelpers.broadcastTo(source.getEntity().getUUID(), new TextComponent(ChatColor.DARK_RED+"No such warp"), source.getServer());
|
||||
ChatHelpers.broadcastTo(source.getEntity().getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARP_NOT_EXIST)), source.getServer());
|
||||
} catch (CommandSyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class WarpCommand {
|
|||
|
||||
private static int nowarp(CommandSourceStack source) {
|
||||
ServerPlayer p = (ServerPlayer)source.getEntity();
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatColor.DARK_RED + "You must supply the warp name. If you need to know what warps are available, please use the warps command, or click this message.").withStyle(Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(Clickable.command("/warps"))), source.getServer());
|
||||
ChatHelpers.broadcastTo(p.getUUID(), new TextComponent(ChatHelpers.macroize(Messages.WARP_NAME_REQUIRED)).withStyle(Style.EMPTY.withFont(Style.DEFAULT_FONT).withClickEvent(Clickable.command("/warps"))), source.getServer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package dev.zontreck.essentials.configs;
|
||||
|
||||
public class EssentialsConfig {
|
||||
|
||||
// TODO:
|
||||
/*
|
||||
* 1. Waystone support, Issue #1
|
||||
* 2. Economy support for server owners to charge a fee to use warps and / or homes
|
||||
*
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ import net.minecraftforge.eventbus.api.Event;
|
|||
public class WarpCreatedEvent extends Event
|
||||
{
|
||||
public Warp warp;
|
||||
|
||||
/**
|
||||
* Edit this value to specify a reason for cancelling the event to the end user
|
||||
*/
|
||||
public String denyReason = "an unknown error";
|
||||
public WarpCreatedEvent(Warp w)
|
||||
{
|
||||
warp=w;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue