added build automization
This commit is contained in:
44
.gitea/workflows/release.yml
Normal file
44
.gitea/workflows/release.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: Build and Release Minecraft Plugin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Java
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn clean install
|
||||||
|
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: plugin-jar
|
||||||
|
path: target/BetterMinecraft.jar
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
target/BetterMinecraft.jar
|
||||||
|
tag_name: ${{ gitea.ref }}
|
||||||
|
title: Release ${{ gitea.ref }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
97
pom.xml
97
pom.xml
@ -1,89 +1,50 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>de.steev</groupId>
|
<groupId>de.vortexhq.lobby</groupId>
|
||||||
<artifactId>betterminecraft</artifactId>
|
<artifactId>vortexlobby</artifactId>
|
||||||
<version>1.2</version>
|
<version>1.0</version>
|
||||||
|
|
||||||
<name>betterminecraft</name>
|
|
||||||
<!-- FIXME change it to the project's website -->
|
|
||||||
<url>http://www.example.com</url>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.source>1.7</maven.compiler.source>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<maven.compiler.target>1.7</maven.compiler.target>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<!-- This adds the Spigot Maven repository to the build -->
|
<!-- This adds the Spigot Maven repository to the build -->
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.11</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.17-R0.1-SNAPSHOT</version>
|
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xerial</groupId>
|
||||||
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
|
<version>3.42.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||||
<plugins>
|
<resources>
|
||||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
<resource>
|
||||||
<plugin>
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<includes>
|
||||||
<version>3.1.0</version>
|
<include>plugin.yml</include>
|
||||||
</plugin>
|
</includes>
|
||||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
</resource>
|
||||||
<plugin>
|
</resources>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.0</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.22.1</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
|
||||||
<version>2.5.2</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<version>2.8.2</version>
|
|
||||||
</plugin>
|
|
||||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
|
||||||
<version>3.7.1</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
@ -1,16 +1,16 @@
|
|||||||
package de.steev.bm.Commands;
|
package de.steev.bm.Commands;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class back implements CommandExecutor {
|
public class back implements CommandExecutor {
|
||||||
// TODO save death coordinates in playerdata
|
// TODO save death coordinates in playerdata
|
||||||
// TODO grab them
|
// TODO grab them
|
||||||
// TODO ensure the position is safe
|
// TODO ensure the position is safe
|
||||||
// TODO teleport player back
|
// TODO teleport player back
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,22 +1,22 @@
|
|||||||
package de.steev.bm.changes.env;
|
package de.steev.bm.changes.env;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public class weather {
|
public class weather {
|
||||||
|
|
||||||
static long lastThunder = 0;
|
static long lastThunder = 0;
|
||||||
long delay = 24000;
|
long delay = 24000;
|
||||||
private static boolean isThunder(World world) {
|
private static boolean isThunder(World world) {
|
||||||
return world.getThunderDuration() > 0;
|
return world.getThunderDuration() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void changeWeather(World world) {
|
public static void changeWeather(World world) {
|
||||||
if(isThunder(world)) {
|
if(isThunder(world)) {
|
||||||
if(lastThunder + 24000 > world.getFullTime()) {
|
if(lastThunder + 24000 > world.getFullTime()) {
|
||||||
world.setClearWeatherDuration(1000);
|
world.setClearWeatherDuration(1000);
|
||||||
}else {
|
}else {
|
||||||
lastThunder = world.getFullTime();
|
lastThunder = world.getFullTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,50 +1,50 @@
|
|||||||
package de.steev.bm.changes.interaction;
|
package de.steev.bm.changes.interaction;
|
||||||
|
|
||||||
import de.steev.bm.main;
|
import de.steev.bm.main;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
|
|
||||||
public class Item_Recipy_Override {
|
public class Item_Recipy_Override {
|
||||||
|
|
||||||
main plugin;
|
main plugin;
|
||||||
NamespacedKey item;
|
NamespacedKey item;
|
||||||
static ShapedRecipe rec_item;
|
static ShapedRecipe rec_item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides vanilla recipes
|
* Overrides vanilla recipes
|
||||||
* @param plugin Plugin Reference
|
* @param plugin Plugin Reference
|
||||||
* @param Item Item name
|
* @param Item Item name
|
||||||
* @param result the dropping item
|
* @param result the dropping item
|
||||||
* @param amount the droprate
|
* @param amount the droprate
|
||||||
*/
|
*/
|
||||||
public Item_Recipy_Override(main plugin, String Item, Material result, int amount){
|
public Item_Recipy_Override(main plugin, String Item, Material result, int amount){
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
item = new NamespacedKey(plugin, Item);
|
item = new NamespacedKey(plugin, Item);
|
||||||
ItemStack itemStack = new ItemStack(result);
|
ItemStack itemStack = new ItemStack(result);
|
||||||
itemStack.setAmount(amount);
|
itemStack.setAmount(amount);
|
||||||
|
|
||||||
rec_item = new ShapedRecipe(item, itemStack);
|
rec_item = new ShapedRecipe(item, itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* registers recipe to bukkit recipe handler
|
* registers recipe to bukkit recipe handler
|
||||||
* @param ing Ingredience reference
|
* @param ing Ingredience reference
|
||||||
* @param mat material ing will reference
|
* @param mat material ing will reference
|
||||||
* @param rec the recipe shape
|
* @param rec the recipe shape
|
||||||
*/
|
*/
|
||||||
public static void register_recipy(char[] ing, Material[] mat, String[] rec){
|
public static void register_recipy(char[] ing, Material[] mat, String[] rec){
|
||||||
//Recipe shapes
|
//Recipe shapes
|
||||||
rec_item.shape(rec[0], rec[1], rec[2]);
|
rec_item.shape(rec[0], rec[1], rec[2]);
|
||||||
|
|
||||||
for(int i = 0; i < ing.length; i++) {
|
for(int i = 0; i < ing.length; i++) {
|
||||||
// Material Definitions
|
// Material Definitions
|
||||||
rec_item.setIngredient(ing[i], mat[i]);
|
rec_item.setIngredient(ing[i], mat[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add recipes to Server
|
// Add recipes to Server
|
||||||
Bukkit.addRecipe(rec_item);
|
Bukkit.addRecipe(rec_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
package de.steev.bm.changes.interaction;
|
package de.steev.bm.changes.interaction;
|
||||||
|
|
||||||
import de.steev.bm.main;
|
import de.steev.bm.main;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.Ageable;
|
import org.bukkit.block.data.Ageable;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class replanting {
|
public class replanting {
|
||||||
|
|
||||||
private main plugin;
|
private main plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* event constructor
|
* event constructor
|
||||||
* @param plugin plugin instance
|
* @param plugin plugin instance
|
||||||
*/
|
*/
|
||||||
public replanting(main plugin) {
|
public replanting(main plugin) {
|
||||||
plugin.getLogger().info("replanting handler Registered");
|
plugin.getLogger().info("replanting handler Registered");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* simplified function for handling replanting works only with arrays
|
* simplified function for handling replanting works only with arrays
|
||||||
* @param item the material of each drop
|
* @param item the material of each drop
|
||||||
* @param amount the drop amount of each item
|
* @param amount the drop amount of each item
|
||||||
*/
|
*/
|
||||||
public static void planting(Material[] item, int[] amount, Block target){
|
public static void planting(Material[] item, int[] amount, Block target){
|
||||||
Ageable crop = (Ageable) target.getBlockData();
|
Ageable crop = (Ageable) target.getBlockData();
|
||||||
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
|
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
// TODO: validate if code may throw errors
|
// TODO: validate if code may throw errors
|
||||||
|
|
||||||
if(crop.getAge() == crop.getMaximumAge()){
|
if(crop.getAge() == crop.getMaximumAge()){
|
||||||
for(int i = 0; i < amount[0]; i++) {
|
for(int i = 0; i < amount[0]; i++) {
|
||||||
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[0]));
|
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < amount[1]; i++) {
|
for(int i = 0; i < amount[1]; i++) {
|
||||||
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[1]));
|
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[1]));
|
||||||
}
|
}
|
||||||
crop.setAge(0);
|
crop.setAge(0);
|
||||||
target.setBlockData(crop);
|
target.setBlockData(crop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,52 +1,52 @@
|
|||||||
package de.steev.bm.events;
|
package de.steev.bm.events;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
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.PlayerBedEnterEvent;
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||||
|
|
||||||
import de.steev.bm.main;
|
import de.steev.bm.main;
|
||||||
|
|
||||||
public class BedEvent implements Listener {
|
public class BedEvent implements Listener {
|
||||||
|
|
||||||
private main plugin;
|
private main plugin;
|
||||||
|
|
||||||
public BedEvent(main plugin) {
|
public BedEvent(main plugin) {
|
||||||
plugin.getLogger().info("Bed events Registered");
|
plugin.getLogger().info("Bed events Registered");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler // Adding to the Player Variable
|
@EventHandler // Adding to the Player Variable
|
||||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||||
final World world = event.getPlayer().getWorld();
|
final World world = event.getPlayer().getWorld();
|
||||||
if(world.getTime() >= 13000 || world.getThunderDuration() > 0) {
|
if(world.getTime() >= 13000 || world.getThunderDuration() > 0) {
|
||||||
plugin.playerInBed++;
|
plugin.playerInBed++;
|
||||||
// Checks if enough Players (currentSleeping >= OnlinePlayerAmount/2) are Sleeping
|
// Checks if enough Players (currentSleeping >= OnlinePlayerAmount/2) are Sleeping
|
||||||
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
||||||
// Delayed Task for detecting useless entries
|
// Delayed Task for detecting useless entries
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
||||||
world.setTime(0);
|
world.setTime(0);
|
||||||
world.setWeatherDuration(7 * 24000);
|
world.setWeatherDuration(7 * 24000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20L);
|
}, 20L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler // Subtracting to the Player Variable
|
@EventHandler // Subtracting to the Player Variable
|
||||||
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
||||||
// Subtraction from the PlayerInBed variable
|
// Subtraction from the PlayerInBed variable
|
||||||
if(plugin.playerInBed > 0) {
|
if(plugin.playerInBed > 0) {
|
||||||
plugin.playerInBed--;
|
plugin.playerInBed--;
|
||||||
// Failsafe to prevent integer underflow
|
// Failsafe to prevent integer underflow
|
||||||
}else if(plugin.playerInBed > 0) {
|
}else if(plugin.playerInBed > 0) {
|
||||||
plugin.playerInBed = 0;
|
plugin.playerInBed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
package de.steev.bm.events;
|
package de.steev.bm.events;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Animals;
|
||||||
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.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
|
||||||
import de.steev.bm.main;
|
import de.steev.bm.main;
|
||||||
import de.steev.bm.changes.interaction.Death;
|
import de.steev.bm.changes.interaction.Death;
|
||||||
|
|
||||||
public class KillEvent implements Listener{
|
public class KillEvent implements Listener{
|
||||||
private main plugin;
|
private main plugin;
|
||||||
|
|
||||||
public KillEvent(main plugin) {
|
public KillEvent(main plugin) {
|
||||||
plugin.getLogger().info("Mob Death events Registered");
|
plugin.getLogger().info("Mob Death events Registered");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements drops on death and can handle other deaths
|
* Implements drops on death and can handle other deaths
|
||||||
* @param event the parsed event on any death
|
* @param event the parsed event on any death
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
int[] amounts;
|
int[] amounts;
|
||||||
Material[] drops;
|
Material[] drops;
|
||||||
|
|
||||||
if(event.getEntity() instanceof Player){
|
if(event.getEntity() instanceof Player){
|
||||||
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();
|
||||||
plugin.playerDataConfig.set("" + uuid + ".death", death);
|
plugin.playerDataConfig.set("" + uuid + ".death", death);
|
||||||
} else if(event.getEntity() instanceof Animals) {
|
} else if(event.getEntity() instanceof Animals) {
|
||||||
|
|
||||||
|
|
||||||
if(event.getEntity().toString() == "CraftPig"){
|
if(event.getEntity().toString() == "CraftPig"){
|
||||||
amounts = new int[]{ 2,2 };
|
amounts = new int[]{ 2,2 };
|
||||||
drops = new Material[]{Material.LEATHER, Material.PORKCHOP};
|
drops = new Material[]{Material.LEATHER, Material.PORKCHOP};
|
||||||
Death.onAnimalDeath(amounts, drops, plugin, event);
|
Death.onAnimalDeath(amounts, drops, plugin, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,100 +1,100 @@
|
|||||||
package de.steev.bm;
|
package de.steev.bm;
|
||||||
|
|
||||||
import de.steev.bm.changes.interaction.Item_Recipy_Override;
|
import de.steev.bm.changes.interaction.Item_Recipy_Override;
|
||||||
import de.steev.bm.events.BedEvent;
|
import de.steev.bm.events.BedEvent;
|
||||||
import de.steev.bm.events.InteractEvent;
|
import de.steev.bm.events.InteractEvent;
|
||||||
import de.steev.bm.events.KillEvent;
|
import de.steev.bm.events.KillEvent;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
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.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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class main extends JavaPlugin implements Listener {
|
public class main 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";
|
String version = "1.2";
|
||||||
|
|
||||||
// Custom Playerdata File
|
// Custom Playerdata File
|
||||||
public File playerdata;
|
public File playerdata;
|
||||||
public FileConfiguration playerDataConfig;
|
public FileConfiguration playerDataConfig;
|
||||||
public final String playerdatafilename = "playerdata.yml";
|
public final String playerdatafilename = "playerdata.yml";
|
||||||
|
|
||||||
// Handles initialisation
|
// Handles initialisation
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Messaging
|
// Messaging
|
||||||
this.getLogger().info(ChatColor.AQUA + "Plugin Startet");
|
this.getLogger().info(ChatColor.AQUA + "Plugin Startet");
|
||||||
|
|
||||||
// Registers Events
|
// Registers Events
|
||||||
this.getLogger().info(ChatColor.AQUA + "Lade Events");
|
this.getLogger().info(ChatColor.AQUA + "Lade Events");
|
||||||
this.getServer().getPluginManager().registerEvents(new BedEvent(this), this);
|
this.getServer().getPluginManager().registerEvents(new BedEvent(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new KillEvent(this), this);
|
this.getServer().getPluginManager().registerEvents(new KillEvent(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(new InteractEvent(this), this);
|
this.getServer().getPluginManager().registerEvents(new InteractEvent(this), this);
|
||||||
this.getServer().getPluginManager().registerEvents(this, this);
|
this.getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
// PlayerData
|
// PlayerData
|
||||||
playerdata = new File(this.getDataFolder(), playerdatafilename);
|
playerdata = new File(this.getDataFolder(), playerdatafilename);
|
||||||
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
|
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
|
||||||
saveplayerdata();
|
saveplayerdata();
|
||||||
|
|
||||||
// More Messaging
|
// More Messaging
|
||||||
this.getLogger().info(ChatColor.AQUA + "Erstelle Rezepte");
|
this.getLogger().info(ChatColor.AQUA + "Erstelle Rezepte");
|
||||||
|
|
||||||
Item_Recipy_Override Saddle = new Item_Recipy_Override(this, "Saddle", Material.SADDLE, 1);
|
Item_Recipy_Override Saddle = new Item_Recipy_Override(this, "Saddle", Material.SADDLE, 1);
|
||||||
char[] s_ing = { 'L', 'S', 'I' };
|
char[] s_ing = { 'L', 'S', 'I' };
|
||||||
String[] s_rec = { "LLL", "LSL", " I " };
|
String[] s_rec = { "LLL", "LSL", " I " };
|
||||||
Material[] s_mat = { Material.LEATHER, Material.STRING, Material.IRON_NUGGET };
|
Material[] s_mat = { Material.LEATHER, Material.STRING, Material.IRON_NUGGET };
|
||||||
Saddle.register_recipy(s_ing, s_mat, s_rec);
|
Saddle.register_recipy(s_ing, s_mat, s_rec);
|
||||||
|
|
||||||
Item_Recipy_Override Wool = new Item_Recipy_Override(this, "String", Material.STRING, 8);
|
Item_Recipy_Override Wool = new Item_Recipy_Override(this, "String", Material.STRING, 8);
|
||||||
char[] w_ing = { 'W', 'F', };
|
char[] w_ing = { 'W', 'F', };
|
||||||
String[] w_rec = { " W ", "WFW", " W " };
|
String[] w_rec = { " W ", "WFW", " W " };
|
||||||
Material[] w_mat = { Material.WHITE_WOOL, Material.FLINT };
|
Material[] w_mat = { Material.WHITE_WOOL, Material.FLINT };
|
||||||
Wool.register_recipy(w_ing, w_mat, w_rec);
|
Wool.register_recipy(w_ing, w_mat, w_rec);
|
||||||
|
|
||||||
// More Messaging
|
// More Messaging
|
||||||
this.getLogger().info(ChatColor.AQUA + "Ich bin Fertig :D");
|
this.getLogger().info(ChatColor.AQUA + "Ich bin Fertig :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
|
// prevent this allways resetting the job count
|
||||||
if (this.playerDataConfig.get(uuid + "." + version + ".read") == null) {
|
if (this.playerDataConfig.get(uuid + "." + version + ".read") == null) {
|
||||||
p.sendMessage("================= Better Minecraft " + version + " =================");
|
p.sendMessage("================= Better Minecraft " + version + " =================");
|
||||||
p.sendMessage("Command: /back eingefügt");
|
p.sendMessage("Command: /back eingefügt");
|
||||||
p.sendMessage("=====================================================");
|
p.sendMessage("=====================================================");
|
||||||
|
|
||||||
this.playerDataConfig.set(uuid + ".name", p.getName());
|
this.playerDataConfig.set(uuid + ".name", p.getName());
|
||||||
this.playerDataConfig.set(uuid + "." + version + ".read", "true");
|
this.playerDataConfig.set(uuid + "." + version + ".read", "true");
|
||||||
saveplayerdata();
|
saveplayerdata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveplayerdata() {
|
void saveplayerdata() {
|
||||||
try {
|
try {
|
||||||
playerDataConfig.save(playerdata);
|
playerDataConfig.save(playerdata);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
this.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save
|
this.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save
|
||||||
// throws the exception
|
// throws the exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user