Compare commits
7 Commits
1.2.1b1
...
refactor_c
Author | SHA1 | Date | |
---|---|---|---|
59611ac1d1 | |||
7e759aace3 | |||
0fe5ce24a8 | |||
137a39e430 | |||
8c83b7ddb6 | |||
63ffe0fe2b | |||
6743f297b2 |
24
README.md
24
README.md
@ -1,3 +1,27 @@
|
|||||||
# betterminecraft
|
# betterminecraft
|
||||||
sandboxplugin to fix mojang fuckups
|
sandboxplugin to fix mojang fuckups
|
||||||
you can use my code when you link this repo and name the author
|
you can use my code when you link this repo and name the author
|
||||||
|
|
||||||
|
|
||||||
|
# Contribution
|
||||||
|
## contribute by code
|
||||||
|
In order to contribute you need to do the following things
|
||||||
|
1. Create an issue with the changes you want to add
|
||||||
|
2. Wait for your feature to be approved
|
||||||
|
3. Fork the Project and make a branch with the features name
|
||||||
|
4. make a pull request from your project to the testing branch (pr's to any other branch will be removed)
|
||||||
|
|
||||||
|
Now your contribution is in testing where people can start using it as beta on their own servers and report back issues
|
||||||
|
Once the testing phase is over and now reports come in the feature will be pulled to release from which it then gets its own downloadable release created
|
||||||
|
|
||||||
|
## contribute with requests
|
||||||
|
if you want a certain feature in my plugin write an issue with the enhancement label
|
||||||
|
you issue should follow this structure
|
||||||
|
|
||||||
|
### Feature request
|
||||||
|
**Name:** how should the feature be named
|
||||||
|
**Version:** when would you like the feature to be implemented (this might differ from actual implementation)
|
||||||
|
**Description:** get creative and technical what do you want this feature to do. Your description even might contain pseudo code if you want to provide such
|
||||||
|
|
||||||
|
Your feature now can be reviewed by the community and be disscussed uppon and maybe changed to fit the plugin
|
||||||
|
once it is approved it will be given a releaes milestone and its own feature branch from where it then will continue on the development proccess
|
@ -5,89 +5,81 @@ 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.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.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);
|
||||||
|
|
||||||
// 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(this, 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
|
||||||
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);
|
// prevent this allways resetting the job count
|
||||||
} catch (IOException e) {
|
if (this.playerData.readBooleanFromConfig(uuid + "." + Version + ".read")) {
|
||||||
this.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save
|
p.sendMessage("================= Better Minecraft " + Version + " =================");
|
||||||
// throws the exception
|
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(){
|
public static String LoggerPrefix(){
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class GameManager {
|
|||||||
this.plugin.getLogger().info("saddle");
|
this.plugin.getLogger().info("saddle");
|
||||||
char[] s_ing = { 'L', 'S', 'I', 'W' };
|
char[] s_ing = { 'L', 'S', 'I', 'W' };
|
||||||
String[] s_rec = { "LLL", "SWS", "I I" };
|
String[] s_rec = { "LLL", "SWS", "I I" };
|
||||||
Material[] s_mat = { Material.LEATHER, Material.STRING, Material.IRON_INGOT, Material.WOOL};
|
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.recipyManager.RegisterNew(s_ing, s_mat, s_rec, 1, Material.SADDLE, "Saddle");
|
||||||
|
|
||||||
this.plugin.getLogger().info("String");
|
this.plugin.getLogger().info("String");
|
||||||
|
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 +1,5 @@
|
|||||||
name: BetterMinecraft
|
name: BetterMinecraft
|
||||||
main: de.steev.bm.main
|
main: de.steev.bm.BetterMinecraft
|
||||||
version: 1.0
|
version: 1.0
|
||||||
api-version: 1.17
|
api-version: 1.17
|
||||||
commands:
|
commands:
|
||||||
|
Reference in New Issue
Block a user