13 Commits

Author SHA1 Message Date
ce3b09e485 Merge pull request 'bugfix 🪱 fixed missing symbol error' (#75) from bugfix/remove_anvill_costcap into main
Reviewed-on: #75
2025-12-02 21:25:00 +01:00
725a964c79 bugfix 🪱 fixed missing symbol error 2025-12-02 21:23:27 +01:00
24bf91ed67 Merge pull request 'bugfix/remove_anvill_costcap' (#74) from bugfix/remove_anvill_costcap into main
Reviewed-on: #74
2025-12-02 21:16:38 +01:00
bb5d6c0b7f bugfix 🪱 readded lost getter function for playerDataConfig 2025-12-02 21:16:05 +01:00
117d53024b Merge branch 'Testing' into bugfix/remove_anvill_costcap 2025-12-02 21:10:38 +01:00
adff0d6c72 resolved merge conflict
Some checks failed
Build and Release Minecraft Plugin / build-and-release (push) Has been cancelled
2025-12-02 21:09:32 +01:00
e29591bb7b removed cost cap from anvill 2025-12-02 21:08:03 +01:00
18de7529a6 resovled merge conflict
Some checks failed
Build and Release Minecraft Plugin / build-and-release (push) Failing after 3m43s
2025-12-02 20:46:47 +01:00
95dd560779 halted Changelog Screen refactor 2025-12-02 20:39:39 +01:00
2879109f59 .gitea/workflows/test.yml aktualisiert 2024-12-27 04:26:14 +01:00
50477bbace .gitea/workflows/release.yml aktualisiert 2024-12-27 04:25:10 +01:00
59611ac1d1 added changelog handler class 2024-12-05 09:29:55 +01:00
7e759aace3 refactored config to it's own class 2024-11-28 10:27:58 +01:00
12 changed files with 239 additions and 44 deletions

View File

@@ -3,11 +3,10 @@ name: Build and Release Minecraft Plugin
on:
push:
branches:
- testing
- Resting
jobs:
build-and-release:
runs-on: self-hosted
steps:
# Repository auschecken
@@ -58,4 +57,4 @@ jobs:
tag_name: ${{ env.PLUGIN_VERSION }}
release_name: Release ${{ env.PLUGIN_VERSION }}
draft: false
prerelease: true
prerelease: false

View File

@@ -6,7 +6,7 @@
<groupId>de.steev.bm</groupId>
<artifactId>BetterMinecraft</artifactId>
<version>stable</version>
<version>1.2.2</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
@@ -25,7 +25,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@@ -5,90 +5,82 @@ import de.steev.bm.Listener.BedListener;
import de.steev.bm.Listener.InteractListener;
import de.steev.bm.Listener.KillListener;
import de.steev.bm.Manager.GameManager;
import de.steev.bm.utils.Config;
import de.steev.bm.utils.exceptions.ConfigEntryExceptions;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.UUID;
import static de.steev.bm.utils.Constants.*;
public class BetterMinecraft extends JavaPlugin implements Listener {
// Global Variables that might come helpfull later
public int playerInBed = 0;
public World world;
String version = "1.2";
// Custom Playerdata File
private File playerdata;
private FileConfiguration playerDataConfig;
private final String playerdatafilename = "playerdata.yml";
private static String prefix = ChatColor.GRAY + "[" + ChatColor.AQUA + "BetterMinecraft" + ChatColor.GRAY + "]";
private Config playerData = new Config(playerDataFilename, this);
private GameManager gameManager;
// Handles initialisation
public void onEnable() {
// Messaging
this.getLogger().info(prefix + ChatColor.WHITE + "Plugin Startet");
this.getLogger().info(prefix + ChatColor.WHITE + "Plugin Startup");
this.getLogger().info(prefix + ChatColor.WHITE + "Initializing Gamemanager");
gameManager = new GameManager(this);
this.saveDefaultConfig();
// Registers Events
this.getLogger().info(prefix + ChatColor.WHITE + "Lade Events");
this.getLogger().info(prefix + ChatColor.WHITE + "Load Events");
this.getServer().getPluginManager().registerEvents(new BedListener(this.gameManager), this);
this.getServer().getPluginManager().registerEvents(new KillListener(this.gameManager), this);
this.getServer().getPluginManager().registerEvents(new InteractListener(this.gameManager), this);
this.getServer().getPluginManager().registerEvents(this, this);
this.getCommand("back").setExecutor(new back(this.gameManager));
Objects.requireNonNull(this.getCommand("back")).setExecutor(new back(this.gameManager));
// PlayerData
playerdata = new File(this.getDataFolder(), playerdatafilename);
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
saveplayerdata();
try {
this.playerData.saveConfig(playerDataFilename);
} catch (IOException e) {
throw new RuntimeException(e);
}
// More Messaging
this.getLogger().info(ChatColor.AQUA + "Ich bin Fertig :D");
this.getLogger().info(ChatColor.AQUA + "Startup complete :D");
}
@EventHandler
void onPlayerJoin(PlayerJoinEvent e) {
Player p = (Player) e.getPlayer();
UUID uuid = p.getUniqueId();
// prevent this allways resetting the job count
if (this.playerDataConfig.get(uuid + "." + version + ".read") == null) {
p.sendMessage("================= Better Minecraft " + version + " =================");
p.sendMessage("Command: /back eingefügt");
try {
if (this.playerData.readBooleanFromConfig(uuid + "." + Version + ".read")) {
p.sendMessage("================= Better Minecraft " + Version + " =================");
p.sendMessage("Amboss Kostengrenze entfernt");
p.sendMessage("=====================================================");
this.playerDataConfig.set(uuid + ".name", p.getName());
this.playerDataConfig.set(uuid + "." + version + ".read", "true");
saveplayerdata();
this.playerData.writeStringToConfig(uuid + ".name", p.getName());
this.playerData.writeStringToConfig(uuid + "." + Version + ".read", "true");
this.playerData.saveConfig(playerDataFilename);
}
} catch (ConfigEntryExceptions cee) {
this.getLogger().warning("reading config failed with error: " + cee.getMessage());
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
void saveplayerdata() {
try {
playerDataConfig.save(playerdata);
} catch (IOException e) {
this.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save
// throws the exception
}
}
public FileConfiguration getPlayerDataConfig(){
return this.playerDataConfig;
}
public static String LoggerPrefix(){
return prefix;
}
@@ -97,4 +89,8 @@ public class BetterMinecraft extends JavaPlugin implements Listener {
// Even more Messaging
this.getLogger().info(ChatColor.AQUA + "Ich geh dann mal :c");
}
public FileConfiguration getPlayerDataConfig() {
return this.playerData.getConfig();
}
}

View File

@@ -0,0 +1,29 @@
package de.steev.bm.Interaction;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.Repairable;
public class AnvilCalculator {
public static int getRepairCost(ItemStack item) {
if (item == null || item.getType().isAir()) return 0;
ItemMeta meta = item.getItemMeta();
if (meta instanceof Repairable) {
Repairable r = (Repairable) meta;
return r.getRepairCost(); // default 0 wenn nicht gesetzt
}
return 0;
}
public static ItemStack setRepairCost(ItemStack item, int cost) {
if (item == null || item.getType().isAir()) return item;
ItemMeta meta = item.getItemMeta();
if (meta instanceof Repairable) {
Repairable r = (Repairable) meta;
r.setRepairCost(cost);
item.setItemMeta(meta);
}
return item;
}
}

View File

@@ -32,7 +32,7 @@ public class KillListener implements Listener {
if(event.getEntity() instanceof Player && this.gameManager.getConfigManager().GetBool("back_command")){
Location death = ((Player) event.getEntity()).getPlayer().getLocation();
UUID uuid = ((Player) event.getEntity()).getPlayer().getUniqueId();
this.gameManager.getPlugin().getPlayerDataConfig().set("" + uuid + ".death", death);
this.gameManager.getPlugin().getPlayerDataConfig().set(uuid + ".death", death);
} else if(event.getEntity() instanceof Animals) {
if(event.getEntity().toString() == "CraftPig" && this.gameManager.getConfigManager().GetBool("custom_drops")){
amounts = new int[]{ 2,2 };

View File

@@ -0,0 +1,21 @@
package de.steev.bm.Listener;
import de.steev.bm.BetterMinecraft;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.inventory.AnvilInventory;
public class PrepareAnvilListener {
private BetterMinecraft plugin;
public PrepareAnvilListener(BetterMinecraft plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPrepare(PrepareAnvilEvent event) {
AnvilInventory inv = event.getInventory();
inv.setMaximumRepairCost(Integer.MAX_VALUE);
}
}

View File

@@ -0,0 +1,60 @@
package de.steev.bm.utils;
import de.steev.bm.Manager.GameManager;
import org.bukkit.entity.Player;
enum ChangelogType {
SystemChangeLog,
CustomChangelog
}
public class Changelog {
private GameManager plugin;
public Changelog(GameManager plugin) {
this.plugin = plugin;
}
/**
* handles getting changelog and sending it to the player
* @param player the receiving player
*/
public void SendChangelog(Player player) {
//player.sendMessage(createChangelog());
}
/**
* handles checking the playerdata if a player already saw the changelog
* @param player the player to lookup
* @return boolean which tells whether a player has seen the changelog or not
*/
private boolean hasPlayerSeenChangelog(ChangelogType changelogType, Player player) {
// TODO: read from header what version the changelog is for
// TODO: read from playerdata.yml if the player has seen the changelog for that type
// TODO: return found result
return false;
}
/***
* reads the set changlog file
* @return the resulting changelog as string
*/
private String createChangelog(ChangelogType changelogType) {
// TODO: FETCH from
/*switch (changelogType) {
case SystemChangeLog:
// TODO: get changelog url from config
// TODO: fetch version changelog from git
// TODO: proccess changelog
break;
case CustomChangelog:
// TODO: fetch changes from changes.txt found in plugin folder or from configured destination
// TODO: proccess changelog
break;
}*/
return "";
}
}

View File

@@ -0,0 +1,72 @@
package de.steev.bm.utils;
import de.steev.bm.BetterMinecraft;
import de.steev.bm.utils.exceptions.ConfigEntryExceptions;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import static de.steev.bm.utils.Constants.playerDataFilename;
public class Config {
private String name;
private File configFile;
private FileConfiguration fileConfiguration;
private BetterMinecraft plugin;
public Config(String name, BetterMinecraft plugin) {
this.name = name;
this.plugin = plugin;
configFile = new File(this.plugin.getDataFolder(), playerDataFilename);
fileConfiguration = YamlConfiguration.loadConfiguration(configFile);
}
public void saveConfig(String name) throws IOException {
try {
fileConfiguration.save(configFile);
} catch (IOException e) {
this.plugin.getLogger().warning("Unable to save " + playerDataFilename); // shouldn't really happen, but save
// throws the exception
throw e;
}
}
public void writeStringToConfig(String path, String value) {
this.fileConfiguration.set(path, value);
}
public String readStringFromConfig(String path) throws ConfigEntryExceptions {
if (this.fileConfiguration.get(path) == null) {
throw new ConfigEntryExceptions("entry at: " + path + " found null");
}
return this.fileConfiguration.getString(path);
}
public int readIntFromConfig(String path) throws ConfigEntryExceptions {
if (this.fileConfiguration.get(path) == null) {
throw new ConfigEntryExceptions("entry at: " + path + " found null");
}
return this.fileConfiguration.getInt(path);
}
public boolean readBooleanFromConfig(String path) throws ConfigEntryExceptions {
if (this.fileConfiguration.get(path) == null) {
throw new ConfigEntryExceptions("entry at: " + path + " found null");
}
return this.fileConfiguration.getBoolean(path);
}
public FileConfiguration getConfig() {
return this.fileConfiguration;
}
public String getName() {
return this.name;
}
}

View File

@@ -0,0 +1,9 @@
package de.steev.bm.utils;
import org.bukkit.ChatColor;
public class Constants {
public static final String prefix = ChatColor.GRAY + "[" + ChatColor.AQUA + "BetterMinecraft" + ChatColor.GRAY + "]";
public static final String playerDataFilename = "playerdata.yml";
public static final String Version = "1.2.2";
}

View File

@@ -0,0 +1,9 @@
package de.steev.bm.utils.exceptions;
public class ConfigEntryExceptions extends Exception {
public ConfigEntryExceptions() {}
public ConfigEntryExceptions(String message) {
super(message);
}
}

View File

@@ -1,7 +1,7 @@
name: BetterMinecraft
main: de.steev.bm.BetterMinecraft
version: 1.0
api-version: 1.17
version: 1.2.2
api-version: 1.21
commands:
back:
description: "teleports players back to their deathpoint"