Clean repo for open source release
Remove build artifacts, dev tool configs, unused dependencies, and third-party source dumps. Add proper README, update .gitignore, clean up Makefile.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.tiedup.remake.network.bounty;
|
||||
|
||||
import com.tiedup.remake.bounty.BountyManager;
|
||||
import com.tiedup.remake.core.SystemMessageManager;
|
||||
import com.tiedup.remake.core.TiedUpMod;
|
||||
import com.tiedup.remake.network.PacketRateLimiter;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
/**
|
||||
* Packet: Client requests to delete/cancel a bounty.
|
||||
*
|
||||
* Phase 17: Bounty System
|
||||
*
|
||||
* Only the bounty client or an admin can delete.
|
||||
* If client deletes, reward is returned.
|
||||
*/
|
||||
public class PacketDeleteBounty {
|
||||
|
||||
private final String bountyId;
|
||||
|
||||
public PacketDeleteBounty(String bountyId) {
|
||||
this.bountyId = bountyId;
|
||||
}
|
||||
|
||||
public void encode(FriendlyByteBuf buf) {
|
||||
buf.writeUtf(bountyId);
|
||||
}
|
||||
|
||||
public static PacketDeleteBounty decode(FriendlyByteBuf buf) {
|
||||
return new PacketDeleteBounty(buf.readUtf(256));
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx
|
||||
.get()
|
||||
.enqueueWork(() -> {
|
||||
ServerPlayer player = ctx.get().getSender();
|
||||
if (player == null) return;
|
||||
if (!PacketRateLimiter.allowPacket(player, "action")) return;
|
||||
|
||||
BountyManager manager = BountyManager.get(player.serverLevel());
|
||||
boolean success = manager.cancelBounty(player, bountyId);
|
||||
|
||||
if (!success) {
|
||||
SystemMessageManager.sendToPlayer(
|
||||
player,
|
||||
SystemMessageManager.MessageCategory.ERROR,
|
||||
"Cannot delete this bounty."
|
||||
);
|
||||
}
|
||||
|
||||
TiedUpMod.LOGGER.debug(
|
||||
"[BOUNTY] Delete request from {}: bounty={}, success={}",
|
||||
player.getName().getString(),
|
||||
bountyId,
|
||||
success
|
||||
);
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.tiedup.remake.network.bounty;
|
||||
|
||||
import com.tiedup.remake.bounty.Bounty;
|
||||
import com.tiedup.remake.bounty.BountyManager;
|
||||
import com.tiedup.remake.network.ModNetwork;
|
||||
import com.tiedup.remake.network.PacketRateLimiter;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
/**
|
||||
* Packet: Client requests bounty list from server.
|
||||
*
|
||||
* Phase 17: Bounty System
|
||||
*
|
||||
* Flow: Client → Server → PacketSendBounties → Client
|
||||
*/
|
||||
public class PacketRequestBounties {
|
||||
|
||||
public PacketRequestBounties() {}
|
||||
|
||||
public void encode(FriendlyByteBuf buf) {
|
||||
// No data needed
|
||||
}
|
||||
|
||||
public static PacketRequestBounties decode(FriendlyByteBuf buf) {
|
||||
return new PacketRequestBounties();
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx
|
||||
.get()
|
||||
.enqueueWork(() -> {
|
||||
ServerPlayer player = ctx.get().getSender();
|
||||
if (player == null) return;
|
||||
if (!PacketRateLimiter.allowPacket(player, "ui")) return;
|
||||
|
||||
BountyManager manager = BountyManager.get(player.serverLevel());
|
||||
List<Bounty> bounties = manager.getBounties(
|
||||
player.serverLevel()
|
||||
);
|
||||
boolean isAdmin = player.hasPermissions(2);
|
||||
|
||||
// Send bounty list back to client
|
||||
ModNetwork.sendToPlayer(
|
||||
new PacketSendBounties(bounties, isAdmin),
|
||||
player
|
||||
);
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.tiedup.remake.network.bounty;
|
||||
|
||||
import com.tiedup.remake.bounty.Bounty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
/**
|
||||
* Packet: Server sends bounty list to client.
|
||||
*
|
||||
* Phase 17: Bounty System
|
||||
*
|
||||
* Flow: Server → Client (opens BountyListScreen)
|
||||
*/
|
||||
public class PacketSendBounties {
|
||||
|
||||
private final List<Bounty> bounties;
|
||||
private final boolean isAdmin;
|
||||
|
||||
public PacketSendBounties(List<Bounty> bounties, boolean isAdmin) {
|
||||
this.bounties = bounties;
|
||||
this.isAdmin = isAdmin;
|
||||
}
|
||||
|
||||
public void encode(FriendlyByteBuf buf) {
|
||||
buf.writeBoolean(isAdmin);
|
||||
|
||||
// Serialize bounties as NBT list
|
||||
ListTag listTag = new ListTag();
|
||||
for (Bounty bounty : bounties) {
|
||||
listTag.add(bounty.save());
|
||||
}
|
||||
CompoundTag wrapper = new CompoundTag();
|
||||
wrapper.put("bounties", listTag);
|
||||
buf.writeNbt(wrapper);
|
||||
}
|
||||
|
||||
public static PacketSendBounties decode(FriendlyByteBuf buf) {
|
||||
boolean isAdmin = buf.readBoolean();
|
||||
|
||||
CompoundTag wrapper = buf.readNbt();
|
||||
List<Bounty> bounties = new ArrayList<>();
|
||||
|
||||
if (wrapper != null && wrapper.contains("bounties")) {
|
||||
ListTag listTag = wrapper.getList("bounties", Tag.TAG_COMPOUND);
|
||||
for (int i = 0; i < listTag.size(); i++) {
|
||||
bounties.add(Bounty.load(listTag.getCompound(i)));
|
||||
}
|
||||
}
|
||||
|
||||
return new PacketSendBounties(bounties, isAdmin);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx
|
||||
.get()
|
||||
.enqueueWork(() -> {
|
||||
if (FMLEnvironment.dist == Dist.CLIENT) {
|
||||
handleClient();
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void handleClient() {
|
||||
net.minecraft.client.Minecraft.getInstance().setScreen(
|
||||
new com.tiedup.remake.client.gui.screens.BountyListScreen(
|
||||
bounties,
|
||||
isAdmin
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user