Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14fd38ccaf | |||
| 116dcc1a0e | |||
| 1ff91018a6 | |||
| 16800135f0 | |||
| 5eb08e1859 | |||
| ad3b275214 | |||
| 6c2a56a179 | |||
| 1a00dacdc2 | |||
| 725a964c79 | |||
| bb5d6c0b7f | |||
| 868286d462 | |||
| 117d53024b | |||
| adff0d6c72 | |||
| e29591bb7b | |||
| 18de7529a6 | |||
| 95dd560779 | |||
| 2879109f59 | |||
| 50477bbace | |||
| 27b00aa28c | |||
| 12813cdc13 | |||
| 149c81dce0 | |||
| 78852274ad | |||
| ca3a3de361 | |||
| 96a826561f | |||
| 881a303196 | |||
| f839ab9690 | |||
| 68191b79c5 | |||
| f855c43364 | |||
| 9e6d61f20d | |||
| 98bfffd7aa | |||
| 7807364a98 | |||
| 85fca1fd6f | |||
| ee4567c5d0 | |||
| 4ab622e7b7 | |||
| 51ad4f64a5 | |||
| 2713333df2 | |||
| ffcdcabf8a | |||
| a16500904c | |||
| 8b7c49e766 | |||
| dfccc5567a | |||
| d408feaf1a | |||
| 5b622cc85c | |||
| b4a41b0277 | |||
| 839b9f6acb | |||
| e54b14c833 | |||
| 42dd11b7b1 | |||
| 360b4562a5 | |||
| 750cb6209d | |||
| b576aa55b7 | |||
| d66fcb5185 | |||
| fd8b3ab94d | |||
| 88efe99327 | |||
| 113f0ce247 | |||
| 195e12e7e4 | |||
| fb489ecd1d | |||
| 00c3c3d653 | |||
| 516e1da1e8 | |||
| 79a41180bc | |||
| 4ec58fcec3 | |||
| aa023d46bb | |||
| 3096c1090e | |||
| 2521e32411 | |||
| 057b5672e1 | |||
| d786e9de94 | |||
| b5566c4d4e | |||
| 807150d83e | |||
| 451ca47fb3 | |||
| 3315017b82 | |||
| c1b3db80b2 | |||
| b0accb96cc | |||
| 0ea61bfcd7 | |||
| 1e4bbe5d55 | |||
| b05e054bd7 | |||
| 2ef476372f | |||
| 385886c7f5 | |||
| ef5c81d7cc | |||
| 5628dfb459 | |||
| dbbb60280b | |||
| 750042d7a9 | |||
| 1bac43b3fe | |||
| 59611ac1d1 | |||
| 7e759aace3 |
60
.gitea/workflows/release.yml
Normal file
60
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
name: Build and Release Minecraft Plugin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- Resting
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-release:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Repository auschecken
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Java 17 installieren
|
||||||
|
- name: Set up Java 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
# Maven installieren
|
||||||
|
- name: Install Maven
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y maven
|
||||||
|
|
||||||
|
# Plugin-Version aus plugin.yml auslesen
|
||||||
|
- name: Extract Plugin Version
|
||||||
|
id: extract_version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version:' src/main/resources/plugin.yml | awk '{print $2}')
|
||||||
|
echo "PLUGIN_VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Projekt mit Maven bauen
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn clean package
|
||||||
|
|
||||||
|
# JAR-Datei umbenennen
|
||||||
|
- name: Rename JAR File
|
||||||
|
run: |
|
||||||
|
mv target/*.jar target/BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
|
||||||
|
# Artefakt hochladen
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
path: target/BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
|
||||||
|
# Release erstellen
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: target/BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
tag_name: ${{ env.PLUGIN_VERSION }}
|
||||||
|
release_name: Release ${{ env.PLUGIN_VERSION }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
name: Build and Release Minecraft Plugin
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Java 17
|
|
||||||
uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
java-version: '17'
|
|
||||||
distribution: 'adopt' # Verwenden Sie 'adopt' für Java 17
|
|
||||||
|
|
||||||
- name: Update Apt
|
|
||||||
run: apt update -y
|
|
||||||
|
|
||||||
- name: Update CA certificates
|
|
||||||
run: apt-get install --reinstall ca-certificates -y
|
|
||||||
|
|
||||||
- name: Install Maven
|
|
||||||
run: apt install maven -y
|
|
||||||
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn clean install
|
|
||||||
|
|
||||||
- name: Upload Artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: BetterMinecraft-stable.jar
|
|
||||||
path: target/BetterMinecraft-stable.jar
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Get letzte Release-Version
|
|
||||||
id: get_version
|
|
||||||
run: echo "::set-output name=version::$(git describe --tags --abbrev=0 || echo '0.0.0')"
|
|
||||||
|
|
||||||
- name: Incrementiere Version
|
|
||||||
id: increment_version
|
|
||||||
run: |
|
|
||||||
IFS='.' read -ra VERSION <<< "${{ steps.get_version.outputs.version }}"
|
|
||||||
MAJOR="${VERSION[0]}"
|
|
||||||
MINOR="${VERSION[1]}"
|
|
||||||
PATCH="${VERSION[2]}"
|
|
||||||
echo "::set-output name=major::$(($MAJOR + 1))"
|
|
||||||
echo "::set-output name=minor::$(($MINOR + 1))"
|
|
||||||
echo "::set-output name=patch::$(($PATCH + 1))"
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
id: create_release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
target/BetterMinecraft-stable.jar
|
|
||||||
tag_name: ${{ steps.increment_version.outputs.major }}.${{ steps.increment_version.outputs.minor }}.${{ steps.increment_version.outputs.patch }}
|
|
||||||
release_name: Release ${{ steps.increment_version.outputs.major }}.${{ steps.increment_version.outputs.minor }}.${{ steps.increment_version.outputs.patch }}
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
name: Build and Release Minecraft Plugin
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- Release
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Java 17
|
|
||||||
uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
java-version: '17'
|
|
||||||
distribution: 'adopt' # Verwenden Sie 'adopt' für Java 17
|
|
||||||
|
|
||||||
- name: Update Apt
|
|
||||||
run: apt update -y
|
|
||||||
|
|
||||||
- name: Update CA certificates
|
|
||||||
run: apt-get install --reinstall ca-certificates -y
|
|
||||||
|
|
||||||
- name: Install Maven
|
|
||||||
run: apt install maven -y
|
|
||||||
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn clean install
|
|
||||||
|
|
||||||
- name: Upload Artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: BetterMinecraft-stable.jar
|
|
||||||
path: target/BetterMinecraft-stable.jar
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Get letzte Release-Version
|
|
||||||
id: get_version
|
|
||||||
run: echo "::set-output name=version::$(git describe --tags --abbrev=0 || echo '0.0.0')"
|
|
||||||
|
|
||||||
- name: Incrementiere Version
|
|
||||||
id: increment_version
|
|
||||||
run: |
|
|
||||||
IFS='.' read -ra VERSION <<< "${{ steps.get_version.outputs.version }}"
|
|
||||||
MAJOR="${VERSION[0]}"
|
|
||||||
MINOR="${VERSION[1]}"
|
|
||||||
PATCH="${VERSION[2]}"
|
|
||||||
echo "::set-output name=major::$(($MAJOR + 1))"
|
|
||||||
echo "::set-output name=minor::$(($MINOR + 1))"
|
|
||||||
echo "::set-output name=patch::$(($PATCH + 1))"
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
id: create_release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
target/BetterMinecraft-stable.jar
|
|
||||||
tag_name: ${{ steps.increment_version.outputs.major }}.${{ steps.increment_version.outputs.minor }}.${{ steps.increment_version.outputs.patch }}
|
|
||||||
release_name: Release ${{ steps.increment_version.outputs.major }}.${{ steps.increment_version.outputs.minor }}.${{ steps.increment_version.outputs.patch }}
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
1
.gitea/workflows/test.md
Normal file
1
.gitea/workflows/test.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
testtesttesttrest
|
||||||
60
.gitea/workflows/test.yml
Normal file
60
.gitea/workflows/test.yml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
name: Build and Release Minecraft Plugin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- Testing
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-release:
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Repository auschecken
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Java 17 installieren
|
||||||
|
- name: Set up Java 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
# Maven installieren
|
||||||
|
- name: Install Maven
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y maven
|
||||||
|
|
||||||
|
# Plugin-Version aus plugin.yml auslesen
|
||||||
|
- name: Extract Plugin Version
|
||||||
|
id: extract_version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version:' src/main/resources/plugin.yml | awk '{print $2}')
|
||||||
|
echo "PLUGIN_VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Projekt mit Maven bauen
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn clean package
|
||||||
|
|
||||||
|
# JAR-Datei umbenennen
|
||||||
|
- name: Rename JAR File
|
||||||
|
run: |
|
||||||
|
mv target/*.jar target/BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
|
||||||
|
# Artefakt hochladen
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
path: target/BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
|
||||||
|
# Release erstellen
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: target/BetterMinecraft-${{ env.PLUGIN_VERSION }}-b.jar
|
||||||
|
tag_name: ${{ env.PLUGIN_VERSION }}
|
||||||
|
release_name: Release ${{ env.PLUGIN_VERSION }}
|
||||||
|
draft: false
|
||||||
|
prerelease: true
|
||||||
2
changelog.txt
Normal file
2
changelog.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
+ added system type changelog
|
||||||
|
+ added custom type changelog
|
||||||
4
pom.xml
4
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>de.steev.bm</groupId>
|
<groupId>de.steev.bm</groupId>
|
||||||
<artifactId>BetterMinecraft</artifactId>
|
<artifactId>BetterMinecraft</artifactId>
|
||||||
<version>stable</version>
|
<version>1.2.2</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
<version>1.21.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -4,91 +4,85 @@ import de.steev.bm.Commands.back;
|
|||||||
import de.steev.bm.Listener.BedListener;
|
import de.steev.bm.Listener.BedListener;
|
||||||
import de.steev.bm.Listener.InteractListener;
|
import de.steev.bm.Listener.InteractListener;
|
||||||
import de.steev.bm.Listener.KillListener;
|
import de.steev.bm.Listener.KillListener;
|
||||||
|
import de.steev.bm.Listener.PrepareAnvilListener;
|
||||||
import de.steev.bm.Manager.GameManager;
|
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.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import static de.steev.bm.utils.Constants.*;
|
||||||
|
|
||||||
public class BetterMinecraft extends JavaPlugin implements Listener {
|
public class BetterMinecraft extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
// Global Variables that might come helpfull later
|
// Global Variables that might come helpfull later
|
||||||
public int playerInBed = 0;
|
public int playerInBed = 0;
|
||||||
public World world;
|
public World world;
|
||||||
String version = "1.2";
|
|
||||||
|
|
||||||
// Custom Playerdata File
|
// Custom Playerdata File
|
||||||
private File playerdata;
|
private Config playerData = new Config(playerDataFilename, this);
|
||||||
private FileConfiguration playerDataConfig;
|
|
||||||
private final String playerdatafilename = "playerdata.yml";
|
|
||||||
private static String prefix = ChatColor.GRAY + "[" + ChatColor.AQUA + "BetterMinecraft" + ChatColor.GRAY + "]";
|
|
||||||
|
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
|
|
||||||
// Handles initialisation
|
// Handles initialisation
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Messaging
|
// 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");
|
this.getLogger().info(prefix + ChatColor.WHITE + "Initializing Gamemanager");
|
||||||
gameManager = new GameManager(this);
|
gameManager = new GameManager(this);
|
||||||
this.saveDefaultConfig();
|
this.saveDefaultConfig();
|
||||||
|
|
||||||
// Registers Events
|
// 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 BedListener(this.gameManager), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new KillListener(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(new InteractListener(this.gameManager), this);
|
||||||
|
this.getServer().getPluginManager().registerEvents(new PrepareAnvilListener(this.gameManager), this);
|
||||||
this.getServer().getPluginManager().registerEvents(this, this);
|
this.getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
Objects.requireNonNull(this.getCommand("back")).setExecutor(new back(this.gameManager));
|
||||||
this.getCommand("back").setExecutor(new back(this.gameManager));
|
|
||||||
|
|
||||||
// PlayerData
|
// PlayerData
|
||||||
playerdata = new File(this.getDataFolder(), playerdatafilename);
|
try {
|
||||||
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
|
this.playerData.saveConfig(playerDataFilename);
|
||||||
saveplayerdata();
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
// More Messaging
|
// More Messaging
|
||||||
this.getLogger().info(ChatColor.AQUA + "Ich bin Fertig :D");
|
this.getLogger().info(ChatColor.AQUA + "Startup complete :D");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerJoin(PlayerJoinEvent e) {
|
void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
Player p = (Player) e.getPlayer();
|
Player p = (Player) e.getPlayer();
|
||||||
UUID uuid = p.getUniqueId();
|
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");
|
|
||||||
p.sendMessage("=====================================================");
|
|
||||||
|
|
||||||
this.playerDataConfig.set(uuid + ".name", p.getName());
|
|
||||||
this.playerDataConfig.set(uuid + "." + version + ".read", "true");
|
|
||||||
saveplayerdata();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveplayerdata() {
|
|
||||||
try {
|
try {
|
||||||
playerDataConfig.save(playerdata);
|
if (this.playerData.readBooleanFromConfig(uuid + "." + Version + ".read")) {
|
||||||
} catch (IOException e) {
|
p.sendMessage("================= Better Minecraft " + Version + " =================");
|
||||||
this.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save
|
p.sendMessage("Amboss Kostengrenze entfernt");
|
||||||
// throws the exception
|
p.sendMessage("=====================================================");
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileConfiguration getPlayerDataConfig(){
|
|
||||||
return this.playerDataConfig;
|
|
||||||
}
|
|
||||||
public static String LoggerPrefix(){
|
public static String LoggerPrefix(){
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
@@ -97,4 +91,8 @@ public class BetterMinecraft extends JavaPlugin implements Listener {
|
|||||||
// Even more Messaging
|
// Even more Messaging
|
||||||
this.getLogger().info(ChatColor.AQUA + "Ich geh dann mal :c");
|
this.getLogger().info(ChatColor.AQUA + "Ich geh dann mal :c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileConfiguration getPlayerDataConfig() {
|
||||||
|
return this.playerData.getConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
29
src/main/java/de/steev/bm/Interaction/AnvilCalculator.java
Normal file
29
src/main/java/de/steev/bm/Interaction/AnvilCalculator.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,12 +8,14 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||||
|
|
||||||
|
import static de.steev.bm.utils.Constants.prefix;
|
||||||
|
|
||||||
public class BedListener implements Listener {
|
public class BedListener implements Listener {
|
||||||
|
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
|
|
||||||
public BedListener(GameManager gameManager) {
|
public BedListener(GameManager gameManager) {
|
||||||
gameManager.getPlugin().getLogger().info("Bed Listener Registered");
|
gameManager.getPlugin().getLogger().info(prefix + "Bed Listener Registered");
|
||||||
this.gameManager = gameManager;
|
this.gameManager = gameManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
import static de.steev.bm.utils.Constants.prefix;
|
||||||
|
|
||||||
public class InteractListener implements Listener {
|
public class InteractListener implements Listener {
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
|
|
||||||
public InteractListener(GameManager gameManager){
|
public InteractListener(GameManager gameManager){
|
||||||
gameManager.getPlugin().getLogger().info("Initializing Interaction Listener");
|
gameManager.getPlugin().getLogger().info(prefix + "Initializing Interaction Listener");
|
||||||
this.gameManager = gameManager;
|
this.gameManager = gameManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static de.steev.bm.utils.Constants.prefix;
|
||||||
|
|
||||||
public class KillListener implements Listener {
|
public class KillListener implements Listener {
|
||||||
|
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
|
|
||||||
public KillListener(GameManager gameManager) {
|
public KillListener(GameManager gameManager) {
|
||||||
gameManager.getPlugin().getLogger().info("Mob Death events Registered");
|
gameManager.getPlugin().getLogger().info(prefix + "Mob Death events Registered");
|
||||||
this.gameManager = gameManager;
|
this.gameManager = gameManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +34,7 @@ public class KillListener implements Listener {
|
|||||||
if(event.getEntity() instanceof Player && this.gameManager.getConfigManager().GetBool("back_command")){
|
if(event.getEntity() instanceof Player && this.gameManager.getConfigManager().GetBool("back_command")){
|
||||||
Location death = ((Player) event.getEntity()).getPlayer().getLocation();
|
Location death = ((Player) event.getEntity()).getPlayer().getLocation();
|
||||||
UUID uuid = ((Player) event.getEntity()).getPlayer().getUniqueId();
|
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) {
|
} else if(event.getEntity() instanceof Animals) {
|
||||||
if(event.getEntity().toString() == "CraftPig" && this.gameManager.getConfigManager().GetBool("custom_drops")){
|
if(event.getEntity().toString() == "CraftPig" && this.gameManager.getConfigManager().GetBool("custom_drops")){
|
||||||
amounts = new int[]{ 2,2 };
|
amounts = new int[]{ 2,2 };
|
||||||
|
|||||||
32
src/main/java/de/steev/bm/Listener/PrepareAnvilListener.java
Normal file
32
src/main/java/de/steev/bm/Listener/PrepareAnvilListener.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package de.steev.bm.Listener;
|
||||||
|
|
||||||
|
import de.steev.bm.BetterMinecraft;
|
||||||
|
import de.steev.bm.Manager.GameManager;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.PrepareAnvilEvent;
|
||||||
|
import org.bukkit.inventory.AnvilInventory;
|
||||||
|
import org.bukkit.inventory.view.AnvilView;
|
||||||
|
|
||||||
|
import static de.steev.bm.utils.Constants.prefix;
|
||||||
|
|
||||||
|
public class PrepareAnvilListener implements Listener {
|
||||||
|
|
||||||
|
private GameManager gameManager;
|
||||||
|
|
||||||
|
public PrepareAnvilListener(GameManager gameManager) {
|
||||||
|
gameManager.getPlugin().getLogger().info(prefix + "initializing Anvil CostCap fix");
|
||||||
|
this.gameManager = gameManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPrepare(PrepareAnvilEvent event) {
|
||||||
|
if (this.gameManager.getConfigManager().GetBool("anvil_fix")) {
|
||||||
|
AnvilView inv = event.getView();
|
||||||
|
this.gameManager.getPlugin().getLogger().info(prefix + "repaircost:" + inv.getRepairCost());
|
||||||
|
inv.setMaximumRepairCost(Integer.MAX_VALUE);
|
||||||
|
inv.getPlayer().sendMessage("repair cost: " + inv.getRepairCost());
|
||||||
|
inv.setRepairCost(inv.getRepairCost());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/main/java/de/steev/bm/utils/Changelog.java
Normal file
60
src/main/java/de/steev/bm/utils/Changelog.java
Normal 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 "";
|
||||||
|
}
|
||||||
|
}
|
||||||
72
src/main/java/de/steev/bm/utils/Config.java
Normal file
72
src/main/java/de/steev/bm/utils/Config.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/main/java/de/steev/bm/utils/Constants.java
Normal file
9
src/main/java/de/steev/bm/utils/Constants.java
Normal 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";
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package de.steev.bm.utils.exceptions;
|
||||||
|
|
||||||
|
public class ConfigEntryExceptions extends Exception {
|
||||||
|
public ConfigEntryExceptions() {}
|
||||||
|
|
||||||
|
public ConfigEntryExceptions(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,17 @@
|
|||||||
|
# sets minimum players in bed to 50% of the server instead of requiring all players to be in bed
|
||||||
improved_bed: true
|
improved_bed: true
|
||||||
|
|
||||||
|
# fixes anvil cost beeing to expensive after 40 level
|
||||||
|
anvil_fix: true
|
||||||
|
|
||||||
|
# adds additional drops to some mobds
|
||||||
custom_drops: true
|
custom_drops: true
|
||||||
|
|
||||||
|
# adds custom crafting recipes
|
||||||
custom_recipes: true
|
custom_recipes: true
|
||||||
|
|
||||||
|
# enables forge like replanting
|
||||||
replanting: true
|
replanting: true
|
||||||
|
|
||||||
|
# enables /back command
|
||||||
back_command: true
|
back_command: true
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
name: BetterMinecraft
|
name: BetterMinecraft
|
||||||
main: de.steev.bm.BetterMinecraft
|
main: de.steev.bm.BetterMinecraft
|
||||||
version: 1.0
|
version: 1.2.2-b2
|
||||||
api-version: 1.17
|
api-version: 1.21
|
||||||
commands:
|
commands:
|
||||||
back:
|
back:
|
||||||
description: "teleports players back to their deathpoint"
|
description: "teleports players back to their deathpoint"
|
||||||
Reference in New Issue
Block a user