moved code to new structure
This commit is contained in:
57
src/main/java/de/steev/bm/Manager/GameManager.java
Normal file
57
src/main/java/de/steev/bm/Manager/GameManager.java
Normal file
@ -0,0 +1,57 @@
|
||||
package de.steev.bm.Manager;
|
||||
|
||||
import de.steev.bm.BetterMinecraft;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Gamemanager controlls the plugins game logic
|
||||
*/
|
||||
public class GameManager {
|
||||
|
||||
private BetterMinecraft plugin;
|
||||
private RecipyManager recipyManager;
|
||||
private PlayerManager playerManager;
|
||||
|
||||
/**
|
||||
* initilizes the Gamemanager and all systems beneath it
|
||||
* @param plugin the plugin reference
|
||||
*/
|
||||
public GameManager(BetterMinecraft plugin) {
|
||||
plugin.getLogger().info("Initializing Gamemanager");
|
||||
this.plugin = plugin;
|
||||
|
||||
this.plugin.getLogger().info("Moving logger to internal plugin reference");
|
||||
this.plugin.getLogger().info("Initilizing other managers");
|
||||
|
||||
this.recipyManager = new RecipyManager(this);
|
||||
this.playerManager = new PlayerManager(this);
|
||||
|
||||
this.plugin.getLogger().info("registring Recipies");
|
||||
this.plugin.getLogger().info("saddle");
|
||||
char[] s_ing = { 'L', 'S', 'I' };
|
||||
String[] s_rec = { "LLL", "LSL", " I " };
|
||||
Material[] s_mat = { Material.LEATHER, Material.STRING, Material.IRON_NUGGET };
|
||||
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, 1, Material.STRING, "String");
|
||||
|
||||
}
|
||||
|
||||
public BetterMinecraft getPlugin(){
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public RecipyManager getRecipyManager() {
|
||||
return recipyManager;
|
||||
}
|
||||
|
||||
public PlayerManager getPlayerManager() {
|
||||
return playerManager;
|
||||
}
|
||||
}
|
||||
|
41
src/main/java/de/steev/bm/Manager/PlayerManager.java
Normal file
41
src/main/java/de/steev/bm/Manager/PlayerManager.java
Normal file
@ -0,0 +1,41 @@
|
||||
package de.steev.bm.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* houses all functions controlling players
|
||||
*/
|
||||
public class PlayerManager {
|
||||
|
||||
private GameManager gameManager;
|
||||
|
||||
/**
|
||||
* initilizes a player manager
|
||||
* @param gameManager the Gamemanager reference
|
||||
*/
|
||||
public PlayerManager(GameManager gameManager) {
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* teleports a player to a location
|
||||
* @param player the wanted player
|
||||
* @param loc the wanted location
|
||||
*/
|
||||
public void teleportPlayer(Player player, Location loc) {
|
||||
player.teleport(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* gives a player a given itemstack
|
||||
* @param player the players reference
|
||||
* @param itemStack the items the player should receive
|
||||
*/
|
||||
public void givePlayerItems(Player player, ItemStack itemStack){
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
}
|
41
src/main/java/de/steev/bm/Manager/RecipyManager.java
Normal file
41
src/main/java/de/steev/bm/Manager/RecipyManager.java
Normal file
@ -0,0 +1,41 @@
|
||||
package de.steev.bm.Manager;
|
||||
|
||||
import de.steev.bm.BetterMinecraft;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
public class RecipyManager{
|
||||
|
||||
private GameManager gameManager;
|
||||
|
||||
public RecipyManager(GameManager gameManager) {
|
||||
this.gameManager = gameManager;
|
||||
}
|
||||
|
||||
public void RegisterNew(char[] ing, Material[] mat, String[] rec, int amount, Material result, String Item){
|
||||
|
||||
BetterMinecraft plugin;
|
||||
NamespacedKey item;
|
||||
ShapedRecipe rec_item;
|
||||
|
||||
item = new NamespacedKey(this.gameManager.getPlugin(), Item);
|
||||
ItemStack itemStack = new ItemStack(result);
|
||||
itemStack.setAmount(amount);
|
||||
|
||||
rec_item = new ShapedRecipe(item, itemStack);
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user