Update to use newer libzontreck, and add some prototype GUIs
This commit is contained in:
parent
bedaa55ee5
commit
d9da756a5d
4 changed files with 103 additions and 28 deletions
|
@ -3,7 +3,7 @@
|
|||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
libzontreck=1.9.122123.1608
|
||||
libzontreck=1.10.010224.1940
|
||||
|
||||
## Environment Properties
|
||||
|
||||
|
@ -49,7 +49,7 @@ mod_name=Aria's Essentials
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.1.122523.2332
|
||||
mod_version=1.2.010224.2002
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
@ -6,17 +6,31 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||
|
||||
import dev.zontreck.essentials.AriasEssentials;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.essentials.homes.Home;
|
||||
import dev.zontreck.essentials.homes.Homes;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUI;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUIButton;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2i;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
public class HomesCommand {
|
||||
private static final ResourceLocation HOMES_GUI_ID = new ResourceLocation("ariasmods", "homes-gui");
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("homes").executes(HomesCommand::getHomes));
|
||||
|
@ -32,19 +46,47 @@ public class HomesCommand {
|
|||
|
||||
ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HOME_COUNT, String.valueOf(homes.count())), player.server);
|
||||
|
||||
ChestGUI gui = ChestGUI.builder().withGUIId(HOMES_GUI_ID).withTitle("Homes").withPlayer(player.getUUID());
|
||||
|
||||
int iconX = 0;
|
||||
int iconY = 0;
|
||||
|
||||
for (Home string : homes.getList()) {
|
||||
Style st = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.get(ChatHelpers.macroize(Messages.HOME_HOVER_TEXT))).withClickEvent(Clickable.command("/home "+string.homeName));
|
||||
|
||||
ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HOME_FORMAT, string.homeName).setStyle(st), ctx.getSource().getServer());
|
||||
ItemStack stack = new ItemStack(Items.BLUE_BED);
|
||||
stack.setHoverName(Component.literal(string.homeName));
|
||||
|
||||
ChestGUIButton button = new ChestGUIButton(stack, ()-> {
|
||||
|
||||
TeleportDestination dest = string.destination;
|
||||
TeleportActioner.ApplyTeleportEffect(player);
|
||||
TeleportContainer cont = new TeleportContainer(player, dest.Position.asMinecraftVector(), dest.Rotation.asMinecraftVector(), dest.getActualDimension());
|
||||
TeleportActioner.PerformTeleport(cont);
|
||||
gui.close();
|
||||
}, new Vector2i(iconX, iconY))
|
||||
.withInfo(new LoreEntry.Builder().text(ChatColor.doColors("!Dark_Green!Click here to go to this home")).build())
|
||||
.withInfo(new LoreEntry.Builder().text(ChatHelpers.macro("!Dark_Purple!This home is in the dimension [0]", string.destination.Dimension).getString()).bold(true).build());
|
||||
|
||||
iconY++;
|
||||
gui.withButton(button);
|
||||
if(iconY>=9)
|
||||
{
|
||||
iconY=0;
|
||||
iconX++;
|
||||
}
|
||||
//ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HOME_FORMAT, string.homeName).setStyle(st), ctx.getSource().getServer());
|
||||
|
||||
}
|
||||
gui.open();
|
||||
}catch(CommandSyntaxException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,22 +11,35 @@ import java.util.Map.Entry;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.essentials.rtp.RandomPositionFactory;
|
||||
import dev.zontreck.essentials.warps.Warp;
|
||||
import dev.zontreck.essentials.warps.WarpsProvider;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUI;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUIButton;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadCache;
|
||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2i;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.commands.ExecuteCommand;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
|
||||
public class WarpsCommand {
|
||||
|
||||
private static final ResourceLocation WARPS_GUI_ID = new ResourceLocation("ariasmods", "ess_warps");
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("warps").executes(c-> warps(c.getSource())));
|
||||
|
@ -46,6 +59,13 @@ public class WarpsCommand {
|
|||
|
||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(Messages.COUNT, String.valueOf(warps.size()), "warp"), source.getServer());
|
||||
|
||||
ChestGUI gui = ChestGUI.builder().withTitle("Warps").withPlayer(p.getUUID()).withGUIId(WARPS_GUI_ID);
|
||||
|
||||
final ChestGUI chestGui = gui;
|
||||
|
||||
int iconX=0;
|
||||
int iconY=0;
|
||||
|
||||
Iterator<Entry<String, Warp>> it = warps.entrySet().iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
|
@ -60,38 +80,51 @@ public class WarpsCommand {
|
|||
return 1;
|
||||
}
|
||||
String warpName = warp.WarpName;
|
||||
int warpType = 0;
|
||||
int warpType;
|
||||
if(warp.RTP) warpType=1;
|
||||
|
||||
else {
|
||||
warpType = 0;
|
||||
}
|
||||
|
||||
String appendType = (warpType == 0) ? Messages.WARP_STANDARD : Messages.WARP_RTP;
|
||||
|
||||
|
||||
HoverEvent hover = HoverTip.get(ChatHelpers.macroize(appendType, warp.destination.Dimension));
|
||||
ClickEvent click = Clickable.command("/warp "+warpName);
|
||||
|
||||
MutableComponent warpMsg = ChatHelpers.macro(ChatColor.GREEN + warpName + ChatColor.resetChat());
|
||||
ChestGUIButton button = new ChestGUIButton(HeadUtilities.get(prof.username, warpName), ()->{
|
||||
TeleportDestination dest = warp.destination;
|
||||
if(warpType == 1)
|
||||
{
|
||||
dest.Position = Vector3.ZERO;
|
||||
RandomPositionFactory.beginRTP(p, warp.destination.getActualDimension());
|
||||
chestGui.close();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
TeleportActioner.ApplyTeleportEffect(p);
|
||||
TeleportContainer tc = new TeleportContainer(p, dest.Position.asMinecraftVector(), dest.Rotation.asMinecraftVector(), dest.getActualDimension());
|
||||
TeleportActioner.PerformTeleport(tc);
|
||||
|
||||
warpMsg = ChatHelpers.applyHoverEvent(warpMsg, hover);
|
||||
|
||||
// Now, display the warp name, along with the warp's owner information
|
||||
HoverEvent h2 = HoverTip.get(
|
||||
ChatHelpers.macroize(Messages.WARP_HOVER_FORMAT,
|
||||
ChatHelpers.macroize(Messages.WARP_OWNER, prof.name_color, prof.nickname),
|
||||
ChatHelpers.macroize(Messages.WARP_ACCESS_FORMAT,
|
||||
(warp.isPublic ? ChatHelpers.macroize(Messages.PUBLIC) : ChatHelpers.macroize(Messages.PRIVATE))
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
|
||||
chestGui.close();
|
||||
}, new Vector2i(iconX, iconY))
|
||||
.withInfo(new LoreEntry.Builder().text(ChatColor.doColors("!Dark_Purple!Owner: " + prof.name_color + prof.nickname))
|
||||
|
||||
.build()
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
.withInfo(new LoreEntry.Builder().text(ChatHelpers.macro(appendType, warp.destination.Dimension).getString()).build());
|
||||
chestGui.withButton(button);
|
||||
|
||||
Component ownerInfo = ChatHelpers.applyHoverEvent(ChatHelpers.macro(Messages.HOVER_WARP_INFO), h2);
|
||||
iconY++;
|
||||
if(iconY>=9){
|
||||
iconY=0;
|
||||
iconX++;
|
||||
}
|
||||
|
||||
|
||||
// Combine the two
|
||||
warpMsg = warpMsg.copy().append(ownerInfo);
|
||||
warpMsg = ChatHelpers.applyClickEvent(warpMsg, click);
|
||||
ChatHelpers.broadcastTo(p.getUUID(), warpMsg, source.getServer());
|
||||
}
|
||||
|
||||
chestGui.open();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ description='''${mod_description}'''
|
|||
[[dependencies.${mod_id}]]
|
||||
modId="libzontreck"
|
||||
mandatory=true
|
||||
versionRange="[1.9.121823,1.10)"
|
||||
versionRange="[1.10,1.11)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue