Chat-GPT makes an Minigame with papermc

MannuG

New member
Dec 8, 2022
3
1
1
Chatgpt by openai generated and idea for an minecraft minigame called 'Escape the dungeon'
with many detailed rules


here's the example it generated after many tries to bypass its filters:

Java:
public class Player {
    private Location location;
    private Inventory inventory;
    private int health;
    
    public Player(Location location, Inventory inventory, int health) {
        this.location = location;
        this.inventory = inventory;
        this.health = health;
    }
    
    public void moveForward() {
        location.add(1, 0, 0);
    }
    
    public void pickUpItem(ItemStack item) {
        inventory.addItem(item);
    }
    
    public void attack(Player target) {
        target.setHealth(target.getHealth() - 1);
    }
    
    public Location getLocation() {
        return location;
    }
    
    public void setLocation(Location location) {
        this.location = location;
    }
    
    public Inventory getInventory() {
        return inventory;
    }
    
    public void setInventory(Inventory inventory) {
        this.inventory = inventory;
    }
    
    public int getHealth() {
        return health;
    }
    
    public void setHealth(int health) {
        this.health = health;
    }
}

public class Dungeon {
    private String layoutFile;
    private List<Room> rooms;
    
    public Dungeon(String layoutFile, List<Room> rooms) {
        this.layoutFile = layoutFile;
        this.rooms = rooms;
    }
    
    public void generateWorld(World world) {
        // Read layout file and generate dungeon in world
        BufferedReader reader = new BufferedReader(new FileReader(layoutFile));
        String line;
        while ((line = reader.readLine()) != null) {
            // Parse layout data and generate dungeon in world
            String[] data = line.split(",");
            int x = Integer.parseInt(data[0]);
            int y = Integer.parseInt(data[1]);
            int z = Integer.parseInt(data[2]);
            Material blockType = Material.valueOf(data[3]);
            world.getBlockAt(x, y, z).setType(blockType);
        }
        reader.close();
    }
    
    public int getSize() {
        return rooms.size();
    }
    
    public List<Room> getRooms() {
        return rooms;
    }
    
    public void setRooms(List<Room> rooms) {
        this.rooms = rooms;
    }
}

public class Room {
    private List<Challenge> challenges;
    
    public Room(List<Challenge> challenges) {
        this.challenges = challenges;
    }
    
public class Objective {
    private String description;
    private boolean completed;
    
    public Objective(String description, boolean completed) {
        this.description = description;
        this.completed = completed;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public boolean isCompleted() {
        return completed;
    }
    
    public void setCompleted(boolean completed) {
        this.completed = completed;
    }
}

public class Puzzle {
    private String description;
    private List<String> clues;
    
    public Puzzle(String description, List<String> clues) {
        this.description = description;
        this.clues = clues;
    }
    
    public void showClue(Player player) {
        // Show random clue to player
        Random rand = new Random();
        int index = rand.nextInt(clues.size());
        String clue = clues.get(index);
        player.sendMessage(clue);
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public List<String> getClues() {
        return clues;
    }
    
    public void setClues(List<String> clues) {
        this.clues = clues;
    }
}

public class EscapeTheDungeon {
    public void run() {
        // Set initial game state
        boolean gameOver = false;
        
        // Main game loop
        while (!gameOver) {
            // Check for player inputs
            for (Player player : Bukkit.getOnlinePlayers()) {
                if (player.isSneaking()) {
                    player.moveForward();
                }
                if (player.isSprinting()) {
                    player.pickUpItem(player.getTargetBlock(null, 1).getDrops().get(0));
                }
                if (player.isAttacking()) {
                    Player target = player.getPlayerTarget();
                    if (target != null) {
                        player.attack(target);
                    }
                }
            }
            // Update game state
            for (Room room : dungeon.getRooms()) {
                for (Challenge challenge : room.getChallenges()) {
                    if (!challenge.isCompleted()) {
                        List<Objective> objectives = challenge.getObjectives();
                        boolean allCompleted = true;
                        for (Objective objective : objectives) {
                            if (!objective.isCompleted()) {
                                allCompleted = false;
                                break;
                            }
                        }
                        if (allCompleted) {
                            challenge.setCompleted(true);
                            Puzzle puzzle = new Puzzle("Solve the puzzle to escape the dungeon", Arrays.asList("Clue 1", "Clue 2", "Clue 3"));
                            challenge.triggerPuzzle(puzzle);
                        }
                    }
                }
            }
            // Handle game mechanics
            if (dun


public class EscapeTheDungeon {
public void run() {
// Set initial game state
boolean gameOver = false;

// Main game loop
while (!gameOver) {
// Check for player inputs
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.isSneaking()) {
player.moveForward();
}
if (player.isSprinting()) {
player.pickUpItem(player.getTargetBlock(null, 1).getDrops().get(0));
}
if (player.isAttacking()) {
Player target = player.getPlayerTarget();
if (target != null) {
player.attack(target);
}
}
}
// Update game state
for (Room room : dungeon.getRooms()) {
for (Challenge challenge : room.getChallenges()) {
if (!challenge.isCompleted()) {
List<Objective> objectives = challenge.getObjectives();
boolean allCompleted = true;
for (Objective objective : objectives) {
if (!objective.isCompleted()) {
allCompleted = false;
break;
}
}
if (allCompleted) {
challenge.setCompleted(true);
Puzzle puzzle = new Puzzle("Solve the puzzle to escape the dungeon", Arrays.asList("Clue 1", "Clue 2", "Clue 3"));
challenge.triggerPuzzle(puzzle);
}
}
}
}
// Handle game mechanics
if (dungeon.getSize() == 1) {
gameOver = true;
}
// Create and display user interface elements
UserInterface ui = new UserInterface();
ui








continue with example









Here is an example of how to us

public class Main extends JavaPlugin {
    private Dungeon dungeon;
    private EscapeTheDungeon game;
    
    @Override
    public void onEnable() {
        // Initialize dungeon and game
        dungeon = new Dungeon("dungeon_layout.txt", Arrays.asList(new Room(Arrays.asList(new Challenge(Arrays.asList(new Objective("Objective 1", false), new Objective("Objective 2", false), new Objective("Objective 3", false)), false)))));
        game = new EscapeTheDungeon(dungeon);
        
        // Register event listeners
        getServer().getPluginManager().registerEvents(new PlayerMoveListener(), this);
        getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
        getServer().getPluginManager().registerEvents(new EntityDamageByEntityListener(), this);
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("startgame")) {
            game.run();
            return true;
        }
        return false;
    }
}

public class PlayerMoveListener implements Listener {
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        // Check if player is sneaking and move player forward
        if (player.isSneaking()) {
            game.moveForward(player);
        }
    }
}

public class PlayerInteractListener implements Listener {
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        // Check if player is sprinting and pick up item
        if (player.isSprinting()) {
            Block block = event.getClickedBlock();
            if (block != null) {
                game.pickUpItem(player, block.getDrops().get(0));
            }
        }
    }
}

public class EntityDamageByEntityListener implements Listener {
    @EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
            Player player = (Player) event.getDamager();
            Player target = (Player) event.getEntity();
            // Check if player is attacking and damage target
            if (player.isAttacking()) {
                game.attack(player, target);
            }
        }
    }
}


Much Of the Code is inComplete because of spam protection but this shows its potential
 
  • Like
Reactions: Josh

MannuG

New member
Dec 8, 2022
3
1
1
how did you get it to do this? i can't seem to get it working
There are many filters on the ai to prevent it from things like creating full on software , political opinions , dangerous stuff etc etc ,
You can bypass these filters by doing some tricks like making it think you are playing an game or just pretending to do something
but its still possible to make it generate some complex code by asking it for 'how to make' instead of 'make me this sh!t' then ask for examples and implementation for the code and then you tell him to add anything to the example.
Its Blazing Fast it gives documentation too
 

MannuG

New member
Dec 8, 2022
3
1
1
this example isn't that good but you can make fully working things with the bot its just an time taking to ask it to make examples then add stuff to it ,, Very Cool Stuff tho