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"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.steev</groupId>
|
||||
<artifactId>betterminecraft</artifactId>
|
||||
<version>1.2</version>
|
||||
|
||||
<name>betterminecraft</name>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
<groupId>de.vortexhq.lobby</groupId>
|
||||
<artifactId>vortexlobby</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<!-- This adds the Spigot Maven repository to the build -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.42.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||
<plugins>
|
||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||
<plugin>
|
||||
<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>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
@ -1,16 +1,16 @@
|
||||
package de.steev.bm.Commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class back implements CommandExecutor {
|
||||
// TODO save death coordinates in playerdata
|
||||
// TODO grab them
|
||||
// TODO ensure the position is safe
|
||||
// TODO teleport player back
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package de.steev.bm.Commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class back implements CommandExecutor {
|
||||
// TODO save death coordinates in playerdata
|
||||
// TODO grab them
|
||||
// TODO ensure the position is safe
|
||||
// TODO teleport player back
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
package de.steev.bm.changes.env;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
public class weather {
|
||||
|
||||
static long lastThunder = 0;
|
||||
long delay = 24000;
|
||||
private static boolean isThunder(World world) {
|
||||
return world.getThunderDuration() > 0;
|
||||
}
|
||||
|
||||
public static void changeWeather(World world) {
|
||||
if(isThunder(world)) {
|
||||
if(lastThunder + 24000 > world.getFullTime()) {
|
||||
world.setClearWeatherDuration(1000);
|
||||
}else {
|
||||
lastThunder = world.getFullTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package de.steev.bm.changes.env;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
public class weather {
|
||||
|
||||
static long lastThunder = 0;
|
||||
long delay = 24000;
|
||||
private static boolean isThunder(World world) {
|
||||
return world.getThunderDuration() > 0;
|
||||
}
|
||||
|
||||
public static void changeWeather(World world) {
|
||||
if(isThunder(world)) {
|
||||
if(lastThunder + 24000 > world.getFullTime()) {
|
||||
world.setClearWeatherDuration(1000);
|
||||
}else {
|
||||
lastThunder = world.getFullTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +1,50 @@
|
||||
package de.steev.bm.changes.interaction;
|
||||
|
||||
import de.steev.bm.main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
public class Item_Recipy_Override {
|
||||
|
||||
main plugin;
|
||||
NamespacedKey item;
|
||||
static ShapedRecipe rec_item;
|
||||
|
||||
/**
|
||||
* Overrides vanilla recipes
|
||||
* @param plugin Plugin Reference
|
||||
* @param Item Item name
|
||||
* @param result the dropping item
|
||||
* @param amount the droprate
|
||||
*/
|
||||
public Item_Recipy_Override(main plugin, String Item, Material result, int amount){
|
||||
this.plugin = plugin;
|
||||
item = new NamespacedKey(plugin, Item);
|
||||
ItemStack itemStack = new ItemStack(result);
|
||||
itemStack.setAmount(amount);
|
||||
|
||||
rec_item = new ShapedRecipe(item, itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* registers recipe to bukkit recipe handler
|
||||
* @param ing Ingredience reference
|
||||
* @param mat material ing will reference
|
||||
* @param rec the recipe shape
|
||||
*/
|
||||
public static void register_recipy(char[] ing, Material[] mat, String[] rec){
|
||||
//Recipe shapes
|
||||
rec_item.shape(rec[0], rec[1], rec[2]);
|
||||
|
||||
for(int i = 0; i < ing.length; i++) {
|
||||
// Material Definitions
|
||||
rec_item.setIngredient(ing[i], mat[i]);
|
||||
}
|
||||
|
||||
// Add recipes to Server
|
||||
Bukkit.addRecipe(rec_item);
|
||||
}
|
||||
}
|
||||
package de.steev.bm.changes.interaction;
|
||||
|
||||
import de.steev.bm.main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
public class Item_Recipy_Override {
|
||||
|
||||
main plugin;
|
||||
NamespacedKey item;
|
||||
static ShapedRecipe rec_item;
|
||||
|
||||
/**
|
||||
* Overrides vanilla recipes
|
||||
* @param plugin Plugin Reference
|
||||
* @param Item Item name
|
||||
* @param result the dropping item
|
||||
* @param amount the droprate
|
||||
*/
|
||||
public Item_Recipy_Override(main plugin, String Item, Material result, int amount){
|
||||
this.plugin = plugin;
|
||||
item = new NamespacedKey(plugin, Item);
|
||||
ItemStack itemStack = new ItemStack(result);
|
||||
itemStack.setAmount(amount);
|
||||
|
||||
rec_item = new ShapedRecipe(item, itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* registers recipe to bukkit recipe handler
|
||||
* @param ing Ingredience reference
|
||||
* @param mat material ing will reference
|
||||
* @param rec the recipe shape
|
||||
*/
|
||||
public static void register_recipy(char[] ing, Material[] mat, String[] rec){
|
||||
//Recipe shapes
|
||||
rec_item.shape(rec[0], rec[1], rec[2]);
|
||||
|
||||
for(int i = 0; i < ing.length; i++) {
|
||||
// Material Definitions
|
||||
rec_item.setIngredient(ing[i], mat[i]);
|
||||
}
|
||||
|
||||
// Add recipes to Server
|
||||
Bukkit.addRecipe(rec_item);
|
||||
}
|
||||
}
|
@ -1,47 +1,47 @@
|
||||
package de.steev.bm.changes.interaction;
|
||||
|
||||
import de.steev.bm.main;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class replanting {
|
||||
|
||||
private main plugin;
|
||||
|
||||
/**
|
||||
* event constructor
|
||||
* @param plugin plugin instance
|
||||
*/
|
||||
public replanting(main plugin) {
|
||||
plugin.getLogger().info("replanting handler Registered");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* simplified function for handling replanting works only with arrays
|
||||
* @param item the material of each drop
|
||||
* @param amount the drop amount of each item
|
||||
*/
|
||||
public static void planting(Material[] item, int[] amount, Block target){
|
||||
Ageable crop = (Ageable) target.getBlockData();
|
||||
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||
|
||||
// TODO: validate if code may throw errors
|
||||
|
||||
if(crop.getAge() == crop.getMaximumAge()){
|
||||
for(int i = 0; i < amount[0]; i++) {
|
||||
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[0]));
|
||||
}
|
||||
|
||||
for(int i = 0; i < amount[1]; i++) {
|
||||
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[1]));
|
||||
}
|
||||
crop.setAge(0);
|
||||
target.setBlockData(crop);
|
||||
}
|
||||
}
|
||||
}
|
||||
package de.steev.bm.changes.interaction;
|
||||
|
||||
import de.steev.bm.main;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class replanting {
|
||||
|
||||
private main plugin;
|
||||
|
||||
/**
|
||||
* event constructor
|
||||
* @param plugin plugin instance
|
||||
*/
|
||||
public replanting(main plugin) {
|
||||
plugin.getLogger().info("replanting handler Registered");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* simplified function for handling replanting works only with arrays
|
||||
* @param item the material of each drop
|
||||
* @param amount the drop amount of each item
|
||||
*/
|
||||
public static void planting(Material[] item, int[] amount, Block target){
|
||||
Ageable crop = (Ageable) target.getBlockData();
|
||||
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||
|
||||
// TODO: validate if code may throw errors
|
||||
|
||||
if(crop.getAge() == crop.getMaximumAge()){
|
||||
for(int i = 0; i < amount[0]; i++) {
|
||||
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[0]));
|
||||
}
|
||||
|
||||
for(int i = 0; i < amount[1]; i++) {
|
||||
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[1]));
|
||||
}
|
||||
crop.setAge(0);
|
||||
target.setBlockData(crop);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +1,52 @@
|
||||
package de.steev.bm.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
|
||||
import de.steev.bm.main;
|
||||
|
||||
public class BedEvent implements Listener {
|
||||
|
||||
private main plugin;
|
||||
|
||||
public BedEvent(main plugin) {
|
||||
plugin.getLogger().info("Bed events Registered");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler // Adding to the Player Variable
|
||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||
final World world = event.getPlayer().getWorld();
|
||||
if(world.getTime() >= 13000 || world.getThunderDuration() > 0) {
|
||||
plugin.playerInBed++;
|
||||
// Checks if enough Players (currentSleeping >= OnlinePlayerAmount/2) are Sleeping
|
||||
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
||||
// Delayed Task for detecting useless entries
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
||||
world.setTime(0);
|
||||
world.setWeatherDuration(7 * 24000);
|
||||
}
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler // Subtracting to the Player Variable
|
||||
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
||||
// Subtraction from the PlayerInBed variable
|
||||
if(plugin.playerInBed > 0) {
|
||||
plugin.playerInBed--;
|
||||
// Failsafe to prevent integer underflow
|
||||
}else if(plugin.playerInBed > 0) {
|
||||
plugin.playerInBed = 0;
|
||||
}
|
||||
}
|
||||
package de.steev.bm.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
|
||||
import de.steev.bm.main;
|
||||
|
||||
public class BedEvent implements Listener {
|
||||
|
||||
private main plugin;
|
||||
|
||||
public BedEvent(main plugin) {
|
||||
plugin.getLogger().info("Bed events Registered");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler // Adding to the Player Variable
|
||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||
final World world = event.getPlayer().getWorld();
|
||||
if(world.getTime() >= 13000 || world.getThunderDuration() > 0) {
|
||||
plugin.playerInBed++;
|
||||
// Checks if enough Players (currentSleeping >= OnlinePlayerAmount/2) are Sleeping
|
||||
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
||||
// Delayed Task for detecting useless entries
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(plugin.playerInBed >= (int)plugin.getServer().getOnlinePlayers().size()/2) {
|
||||
world.setTime(0);
|
||||
world.setWeatherDuration(7 * 24000);
|
||||
}
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler // Subtracting to the Player Variable
|
||||
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
||||
// Subtraction from the PlayerInBed variable
|
||||
if(plugin.playerInBed > 0) {
|
||||
plugin.playerInBed--;
|
||||
// Failsafe to prevent integer underflow
|
||||
}else if(plugin.playerInBed > 0) {
|
||||
plugin.playerInBed = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +1,47 @@
|
||||
package de.steev.bm.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
import de.steev.bm.main;
|
||||
import de.steev.bm.changes.interaction.Death;
|
||||
|
||||
public class KillEvent implements Listener{
|
||||
private main plugin;
|
||||
|
||||
public KillEvent(main plugin) {
|
||||
plugin.getLogger().info("Mob Death events Registered");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements drops on death and can handle other deaths
|
||||
* @param event the parsed event on any death
|
||||
*/
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
int[] amounts;
|
||||
Material[] drops;
|
||||
|
||||
if(event.getEntity() instanceof Player){
|
||||
Location death = ((Player) event.getEntity()).getPlayer().getLocation();
|
||||
UUID uuid = ((Player) event.getEntity()).getPlayer().getUniqueId();
|
||||
plugin.playerDataConfig.set("" + uuid + ".death", death);
|
||||
} else if(event.getEntity() instanceof Animals) {
|
||||
|
||||
|
||||
if(event.getEntity().toString() == "CraftPig"){
|
||||
amounts = new int[]{ 2,2 };
|
||||
drops = new Material[]{Material.LEATHER, Material.PORKCHOP};
|
||||
Death.onAnimalDeath(amounts, drops, plugin, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package de.steev.bm.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
import de.steev.bm.main;
|
||||
import de.steev.bm.changes.interaction.Death;
|
||||
|
||||
public class KillEvent implements Listener{
|
||||
private main plugin;
|
||||
|
||||
public KillEvent(main plugin) {
|
||||
plugin.getLogger().info("Mob Death events Registered");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements drops on death and can handle other deaths
|
||||
* @param event the parsed event on any death
|
||||
*/
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
int[] amounts;
|
||||
Material[] drops;
|
||||
|
||||
if(event.getEntity() instanceof Player){
|
||||
Location death = ((Player) event.getEntity()).getPlayer().getLocation();
|
||||
UUID uuid = ((Player) event.getEntity()).getPlayer().getUniqueId();
|
||||
plugin.playerDataConfig.set("" + uuid + ".death", death);
|
||||
} else if(event.getEntity() instanceof Animals) {
|
||||
|
||||
|
||||
if(event.getEntity().toString() == "CraftPig"){
|
||||
amounts = new int[]{ 2,2 };
|
||||
drops = new Material[]{Material.LEATHER, Material.PORKCHOP};
|
||||
Death.onAnimalDeath(amounts, drops, plugin, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,100 +1,100 @@
|
||||
package de.steev.bm;
|
||||
|
||||
import de.steev.bm.changes.interaction.Item_Recipy_Override;
|
||||
import de.steev.bm.events.BedEvent;
|
||||
import de.steev.bm.events.InteractEvent;
|
||||
import de.steev.bm.events.KillEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
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.UUID;
|
||||
|
||||
public class main 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
|
||||
public File playerdata;
|
||||
public FileConfiguration playerDataConfig;
|
||||
public final String playerdatafilename = "playerdata.yml";
|
||||
|
||||
// Handles initialisation
|
||||
public void onEnable() {
|
||||
// Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Plugin Startet");
|
||||
|
||||
// Registers Events
|
||||
this.getLogger().info(ChatColor.AQUA + "Lade Events");
|
||||
this.getServer().getPluginManager().registerEvents(new BedEvent(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new KillEvent(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new InteractEvent(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
|
||||
// PlayerData
|
||||
playerdata = new File(this.getDataFolder(), playerdatafilename);
|
||||
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
|
||||
saveplayerdata();
|
||||
|
||||
// More Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Erstelle Rezepte");
|
||||
|
||||
Item_Recipy_Override Saddle = new Item_Recipy_Override(this, "Saddle", Material.SADDLE, 1);
|
||||
char[] s_ing = { 'L', 'S', 'I' };
|
||||
String[] s_rec = { "LLL", "LSL", " I " };
|
||||
Material[] s_mat = { Material.LEATHER, Material.STRING, Material.IRON_NUGGET };
|
||||
Saddle.register_recipy(s_ing, s_mat, s_rec);
|
||||
|
||||
Item_Recipy_Override Wool = new Item_Recipy_Override(this, "String", Material.STRING, 8);
|
||||
char[] w_ing = { 'W', 'F', };
|
||||
String[] w_rec = { " W ", "WFW", " W " };
|
||||
Material[] w_mat = { Material.WHITE_WOOL, Material.FLINT };
|
||||
Wool.register_recipy(w_ing, w_mat, w_rec);
|
||||
|
||||
// More Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Ich bin Fertig :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
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
// Even more Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Ich geh dann mal :c");
|
||||
}
|
||||
package de.steev.bm;
|
||||
|
||||
import de.steev.bm.changes.interaction.Item_Recipy_Override;
|
||||
import de.steev.bm.events.BedEvent;
|
||||
import de.steev.bm.events.InteractEvent;
|
||||
import de.steev.bm.events.KillEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
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.UUID;
|
||||
|
||||
public class main 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
|
||||
public File playerdata;
|
||||
public FileConfiguration playerDataConfig;
|
||||
public final String playerdatafilename = "playerdata.yml";
|
||||
|
||||
// Handles initialisation
|
||||
public void onEnable() {
|
||||
// Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Plugin Startet");
|
||||
|
||||
// Registers Events
|
||||
this.getLogger().info(ChatColor.AQUA + "Lade Events");
|
||||
this.getServer().getPluginManager().registerEvents(new BedEvent(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new KillEvent(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new InteractEvent(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
|
||||
// PlayerData
|
||||
playerdata = new File(this.getDataFolder(), playerdatafilename);
|
||||
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
|
||||
saveplayerdata();
|
||||
|
||||
// More Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Erstelle Rezepte");
|
||||
|
||||
Item_Recipy_Override Saddle = new Item_Recipy_Override(this, "Saddle", Material.SADDLE, 1);
|
||||
char[] s_ing = { 'L', 'S', 'I' };
|
||||
String[] s_rec = { "LLL", "LSL", " I " };
|
||||
Material[] s_mat = { Material.LEATHER, Material.STRING, Material.IRON_NUGGET };
|
||||
Saddle.register_recipy(s_ing, s_mat, s_rec);
|
||||
|
||||
Item_Recipy_Override Wool = new Item_Recipy_Override(this, "String", Material.STRING, 8);
|
||||
char[] w_ing = { 'W', 'F', };
|
||||
String[] w_rec = { " W ", "WFW", " W " };
|
||||
Material[] w_mat = { Material.WHITE_WOOL, Material.FLINT };
|
||||
Wool.register_recipy(w_ing, w_mat, w_rec);
|
||||
|
||||
// More Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Ich bin Fertig :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
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
// Even more Messaging
|
||||
this.getLogger().info(ChatColor.AQUA + "Ich geh dann mal :c");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user