Compare commits
	
		
			2 Commits
		
	
	
		
			1.0
			...
			refactor_c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 59611ac1d1 | |||
| 7e759aace3 | 
@ -3,7 +3,7 @@ name: Build and Release Minecraft Plugin
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
    branches:
 | 
			
		||||
      - release
 | 
			
		||||
      - main
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
							
								
								
									
										65
									
								
								.gitea/workflows/release.yml.off
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								.gitea/workflows/release.yml.off
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,65 @@
 | 
			
		||||
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,56 +0,0 @@
 | 
			
		||||
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 und vorbereiten
 | 
			
		||||
      - 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
 | 
			
		||||
        shell: bash
 | 
			
		||||
 | 
			
		||||
      # Projekt mit Maven bauen
 | 
			
		||||
      - name: Build with Maven
 | 
			
		||||
        run: mvn clean package
 | 
			
		||||
 | 
			
		||||
      # 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-stable.jar
 | 
			
		||||
          tag_name: ${{ env.PLUGIN_VERSION }}
 | 
			
		||||
          release_name: Release ${{ env.PLUGIN_VERSION }}
 | 
			
		||||
          draft: false
 | 
			
		||||
          prerelease: true
 | 
			
		||||
@ -1 +0,0 @@
 | 
			
		||||
testtest
 | 
			
		||||
@ -1,2 +0,0 @@
 | 
			
		||||
+ added system type changelog
 | 
			
		||||
+ added custom type changelog
 | 
			
		||||
							
								
								
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							@ -37,7 +37,6 @@
 | 
			
		||||
        <directory>${project.basedir}/src/main/resources</directory>
 | 
			
		||||
        <includes>
 | 
			
		||||
          <include>plugin.yml</include>
 | 
			
		||||
          <include>config.yml</include>
 | 
			
		||||
        </includes>
 | 
			
		||||
      </resource>
 | 
			
		||||
    </resources>
 | 
			
		||||
 | 
			
		||||
@ -5,90 +5,81 @@ 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");
 | 
			
		||||
        // More Messaging
 | 
			
		||||
		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");
 | 
			
		||||
			p.sendMessage("=====================================================");
 | 
			
		||||
 | 
			
		||||
			this.playerDataConfig.set(uuid + ".name", p.getName());
 | 
			
		||||
			this.playerDataConfig.set(uuid + "." + version + ".read", "true");
 | 
			
		||||
			saveplayerdata();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
			// prevent this allways resetting the job count
 | 
			
		||||
			if (this.playerData.readBooleanFromConfig(uuid + "." + Version + ".read")) {
 | 
			
		||||
				p.sendMessage("================= Better Minecraft " + Version + " =================");
 | 
			
		||||
				p.sendMessage("Command: /back eingefügt");
 | 
			
		||||
				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(){
 | 
			
		||||
		return prefix;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -17,14 +17,8 @@ public class back implements CommandExecutor {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
 | 
			
		||||
        if (!this.gameManager.getConfigManager().GetBool("back_command")) {
 | 
			
		||||
            commandSender.sendMessage("back command ist nicht aktiv");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Player player = (Player) commandSender.getServer().getPlayer(commandSender.getName());
 | 
			
		||||
        Location lastDeath;
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            lastDeath = this.gameManager.getPlugin().getPlayerDataConfig().getLocation(player.getUniqueId() + ".death");
 | 
			
		||||
            player.teleport(lastDeath);
 | 
			
		||||
@ -33,7 +27,6 @@ public class back implements CommandExecutor {
 | 
			
		||||
        } catch (Exception ex) {
 | 
			
		||||
            commandSender.sendMessage("Tot nicht gefunden!");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -36,12 +36,9 @@ public class replanting {
 | 
			
		||||
                target.getLocation().getWorld().dropItem(loc, new ItemStack(item[0]));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (amount.length > 1) {
 | 
			
		||||
                for (int i = 0; i < amount[1]; i++) {
 | 
			
		||||
                    target.getLocation().getWorld().dropItem(loc, new ItemStack(item[1]));
 | 
			
		||||
                }
 | 
			
		||||
            for(int i = 0; i < amount[1]; i++) {
 | 
			
		||||
                target.getLocation().getWorld().dropItem(loc, new ItemStack(item[1]));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            crop.setAge(0);
 | 
			
		||||
            target.setBlockData(crop);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
package de.steev.bm.Listener;
 | 
			
		||||
 | 
			
		||||
import de.steev.bm.BetterMinecraft;
 | 
			
		||||
import de.steev.bm.Manager.GameManager;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
@ -20,7 +21,7 @@ public class BedListener implements Listener {
 | 
			
		||||
    @EventHandler // Adding to the Player Variable
 | 
			
		||||
    public void onPlayerBedEnter(PlayerBedEnterEvent event) {
 | 
			
		||||
        final World world = event.getPlayer().getWorld();
 | 
			
		||||
        if(world.getTime() >= 13000 || world.getThunderDuration() > 0 && this.gameManager.getConfigManager().GetBool("improved_bed")) {
 | 
			
		||||
        if(world.getTime() >= 13000 || world.getThunderDuration() > 0) {
 | 
			
		||||
            this.gameManager.getPlugin().playerInBed++;
 | 
			
		||||
            // Checks if enough Players (currentSleeping >= OnlinePlayerAmount/2) are Sleeping
 | 
			
		||||
            if(this.gameManager.getPlugin().playerInBed >= (int)this.gameManager.getPlugin().getServer().getOnlinePlayers().size()/2) {
 | 
			
		||||
@ -48,4 +49,5 @@ public class BedListener implements Listener {
 | 
			
		||||
            this.gameManager.getPlugin().playerInBed = 0;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ public class InteractListener implements Listener {
 | 
			
		||||
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onPlayerInteract(PlayerInteractEvent event){
 | 
			
		||||
        if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && this.gameManager.getConfigManager().GetBool("replanting")){
 | 
			
		||||
        if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
 | 
			
		||||
 | 
			
		||||
            /** the clicked block */
 | 
			
		||||
            Block target = event.getClickedBlock();
 | 
			
		||||
 | 
			
		||||
@ -29,12 +29,12 @@ public class KillListener implements Listener {
 | 
			
		||||
        int[] amounts;
 | 
			
		||||
        Material[] drops;
 | 
			
		||||
 | 
			
		||||
        if(event.getEntity() instanceof Player && this.gameManager.getConfigManager().GetBool("back_command")){
 | 
			
		||||
        if(event.getEntity() instanceof Player){
 | 
			
		||||
            Location death = ((Player) event.getEntity()).getPlayer().getLocation();
 | 
			
		||||
            UUID uuid = ((Player) event.getEntity()).getPlayer().getUniqueId();
 | 
			
		||||
            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")){
 | 
			
		||||
            if(event.getEntity().toString() == "CraftPig"){
 | 
			
		||||
                amounts = new int[]{ 2,2 };
 | 
			
		||||
                drops = new Material[]{Material.LEATHER, Material.PORKCHOP};
 | 
			
		||||
                Death.onAnimalDeath(amounts, drops, this.gameManager.getPlugin(), event);
 | 
			
		||||
 | 
			
		||||
@ -1,14 +0,0 @@
 | 
			
		||||
package de.steev.bm.Manager;
 | 
			
		||||
 | 
			
		||||
public class ConfigManager {
 | 
			
		||||
 | 
			
		||||
    private GameManager gameManager;
 | 
			
		||||
 | 
			
		||||
    public ConfigManager(GameManager gameManager) {
 | 
			
		||||
        this.gameManager = gameManager;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean GetBool(String Key){
 | 
			
		||||
        return gameManager.getPlugin().getConfig().getBoolean(Key);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -12,7 +12,6 @@ public class GameManager {
 | 
			
		||||
    private BetterMinecraft plugin;
 | 
			
		||||
    private RecipyManager recipyManager;
 | 
			
		||||
    private PlayerManager playerManager;
 | 
			
		||||
    private ConfigManager configManager;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * initilizes the Gamemanager and all systems beneath it
 | 
			
		||||
@ -27,22 +26,20 @@ public class GameManager {
 | 
			
		||||
 | 
			
		||||
        this.recipyManager = new RecipyManager(this);
 | 
			
		||||
        this.playerManager = new PlayerManager(this);
 | 
			
		||||
        this.configManager = new ConfigManager(this);
 | 
			
		||||
 | 
			
		||||
        if (this.configManager.GetBool("custom_recipes")) {
 | 
			
		||||
            this.plugin.getLogger().info("registring Recipies");
 | 
			
		||||
            this.plugin.getLogger().info("saddle");
 | 
			
		||||
            char[] s_ing = {'L', 'S', 'I', 'W'};
 | 
			
		||||
            String[] s_rec = {"LLL", "SWS", "I I"};
 | 
			
		||||
            Material[] s_mat = {Material.LEATHER, Material.STRING, Material.IRON_INGOT, Material.WHITE_WOOL};
 | 
			
		||||
            this.recipyManager.RegisterNew(s_ing, s_mat, s_rec, 1, Material.SADDLE, "Saddle");
 | 
			
		||||
        this.plugin.getLogger().info("registring Recipies");
 | 
			
		||||
        this.plugin.getLogger().info("saddle");
 | 
			
		||||
        char[] s_ing = { 'L', 'S', 'I', 'W' };
 | 
			
		||||
        String[] s_rec = { "LLL", "SWS", "I I" };
 | 
			
		||||
        Material[] s_mat = { Material.LEATHER, Material.STRING, Material.IRON_INGOT, Material.WHITE_WOOL};
 | 
			
		||||
        this.recipyManager.RegisterNew(s_ing, s_mat, s_rec, 1, Material.SADDLE, "Saddle");
 | 
			
		||||
 | 
			
		||||
        this.plugin.getLogger().info("String");
 | 
			
		||||
        char[] w_ing = { 'W', 'F', };
 | 
			
		||||
        String[] w_rec = { " W ", "WFW", " W " };
 | 
			
		||||
        Material[] w_mat = { Material.WHITE_WOOL, Material.FLINT };
 | 
			
		||||
        this.recipyManager.RegisterNew(w_ing, w_mat, w_rec, 4, Material.STRING, "String");
 | 
			
		||||
 | 
			
		||||
            this.plugin.getLogger().info("String");
 | 
			
		||||
            char[] w_ing = {'W', 'F',};
 | 
			
		||||
            String[] w_rec = {" W ", "WFW", " W "};
 | 
			
		||||
            Material[] w_mat = {Material.WHITE_WOOL, Material.FLINT};
 | 
			
		||||
            this.recipyManager.RegisterNew(w_ing, w_mat, w_rec, 4, Material.STRING, "String");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BetterMinecraft getPlugin(){
 | 
			
		||||
@ -56,9 +53,5 @@ public class GameManager {
 | 
			
		||||
    public PlayerManager getPlayerManager() {
 | 
			
		||||
        return playerManager;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ConfigManager getConfigManager() {
 | 
			
		||||
        return configManager;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										37
									
								
								src/main/java/de/steev/bm/utils/Changelog.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/main/java/de/steev/bm/utils/Changelog.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
package de.steev.bm.utils;
 | 
			
		||||
 | 
			
		||||
import de.steev.bm.Manager.GameManager;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
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 or not a player has seen the changelog
 | 
			
		||||
     */
 | 
			
		||||
    private boolean hasPlayerSeenChangelog(Player player) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /***
 | 
			
		||||
     * reads the set changlog file
 | 
			
		||||
     * @return the resulting changelog as string
 | 
			
		||||
     */
 | 
			
		||||
    private String createChangelog() {
 | 
			
		||||
        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 +0,0 @@
 | 
			
		||||
improved_bed: true
 | 
			
		||||
custom_drops: true
 | 
			
		||||
custom_recipes: true
 | 
			
		||||
replanting: true
 | 
			
		||||
back_command: true
 | 
			
		||||
		Reference in New Issue
	
	Block a user