mirror of
https://github.com/tomasff/BeesPlus.git
synced 2024-09-28 21:37:28 +02:00
Compare commits
7 Commits
bd982cdbe2
...
c9c5d78a38
Author | SHA1 | Date | |
---|---|---|---|
|
c9c5d78a38 | ||
|
9a94cea232 | ||
|
e7ae6ae440 | ||
|
1e0c51f607 | ||
|
f224810f45 | ||
|
8d0f7f3498 | ||
|
85e8bb3271 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -12,10 +12,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 1.8
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: '17'
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn -B package --file pom.xml
|
run: mvn -B package --file pom.xml
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
|
12
pom.xml
12
pom.xml
@ -6,13 +6,13 @@
|
|||||||
|
|
||||||
<groupId>com.tomff.beesplus</groupId>
|
<groupId>com.tomff.beesplus</groupId>
|
||||||
<artifactId>BeesPlus</artifactId>
|
<artifactId>BeesPlus</artifactId>
|
||||||
<version>1.6.0</version>
|
<version>1.6.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<junit.jupiter.version>5.6.2</junit.jupiter.version>
|
<junit.jupiter.version>5.6.2</junit.jupiter.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -31,13 +31,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.16.3-R0.1-SNAPSHOT</version>
|
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
<version>1.7</version>
|
<version>3.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -65,7 +65,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.2.2</version>
|
<version>3.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
|
@ -12,10 +12,12 @@ import com.tomff.beesplus.handlers.DamageHandler;
|
|||||||
import com.tomff.beesplus.handlers.RightClickHandler;
|
import com.tomff.beesplus.handlers.RightClickHandler;
|
||||||
import com.tomff.beesplus.items.*;
|
import com.tomff.beesplus.items.*;
|
||||||
import com.tomff.beesplus.localization.Localization;
|
import com.tomff.beesplus.localization.Localization;
|
||||||
import com.tomff.beesplus.localization.LocalizationWrapper;
|
import com.tomff.beesplus.localization.LocalizationLoader;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -23,6 +25,11 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class BeesPlus extends JavaPlugin {
|
public class BeesPlus extends JavaPlugin {
|
||||||
|
|
||||||
|
private static final int RESOURCE_ID = 77224;
|
||||||
|
private static final int PLUGIN_ID = 7065;
|
||||||
|
|
||||||
|
private static final String LANGUAGE_CHART_ID = "language_used";
|
||||||
|
|
||||||
private GuiViewTracker guiViewTracker;
|
private GuiViewTracker guiViewTracker;
|
||||||
private CustomItemManager customItemManager;
|
private CustomItemManager customItemManager;
|
||||||
|
|
||||||
@ -34,9 +41,11 @@ public class BeesPlus extends JavaPlugin {
|
|||||||
guiViewTracker = new GuiViewTracker();
|
guiViewTracker = new GuiViewTracker();
|
||||||
customItemManager = new CustomItemManager(this);
|
customItemManager = new CustomItemManager(this);
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new GuiHandler(this), this);
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
getServer().getPluginManager().registerEvents(new BeehiveHandler(), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new RightClickHandler(this), this);
|
pluginManager.registerEvents(new GuiHandler(this), this);
|
||||||
|
pluginManager.registerEvents(new BeehiveHandler(), this);
|
||||||
|
pluginManager.registerEvents(new RightClickHandler(this), this);
|
||||||
|
|
||||||
if (!loadLocale()) {
|
if (!loadLocale()) {
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
@ -45,8 +54,11 @@ public class BeesPlus extends JavaPlugin {
|
|||||||
|
|
||||||
registerItems();
|
registerItems();
|
||||||
setupMetrics();
|
setupMetrics();
|
||||||
|
setupUpdateChecker();
|
||||||
|
}
|
||||||
|
|
||||||
new UpdateChecker(this, 77224).getVersion(version -> {
|
private void setupUpdateChecker() {
|
||||||
|
new UpdateChecker(this, RESOURCE_ID).getVersion(version -> {
|
||||||
if (!this.getDescription().getVersion().equalsIgnoreCase(version)) {
|
if (!this.getDescription().getVersion().equalsIgnoreCase(version)) {
|
||||||
getLogger().info("A new update is available: BeesPlus " + version);
|
getLogger().info("A new update is available: BeesPlus " + version);
|
||||||
}
|
}
|
||||||
@ -54,9 +66,9 @@ public class BeesPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupMetrics() {
|
private void setupMetrics() {
|
||||||
Metrics metrics = new Metrics(this, 7065);
|
Metrics metrics = new Metrics(this, PLUGIN_ID);
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("language_used",
|
metrics.addCustomChart(new SimplePie(LANGUAGE_CHART_ID,
|
||||||
() -> getConfig().getString("locale", Locale.ENGLISH.toLanguageTag())));
|
() -> getConfig().getString("locale", Locale.ENGLISH.toLanguageTag())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,10 +79,10 @@ public class BeesPlus extends JavaPlugin {
|
|||||||
|
|
||||||
private boolean loadLocale() {
|
private boolean loadLocale() {
|
||||||
String locale = getConfig().getString("locale", Locale.ENGLISH.toLanguageTag());
|
String locale = getConfig().getString("locale", Locale.ENGLISH.toLanguageTag());
|
||||||
LocalizationWrapper localizationWrapper = new LocalizationWrapper(this, "locale");
|
LocalizationLoader localizationLoader = new LocalizationLoader(this, "locale");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
YamlConfiguration localeYamlFile = localizationWrapper.getLocale(locale);
|
YamlConfiguration localeYamlFile = localizationLoader.load(locale);
|
||||||
Localization.load(localeYamlFile);
|
Localization.load(localeYamlFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
getLogger().severe("Invalid locale! Please choose a valid locale.");
|
getLogger().severe("Invalid locale! Please choose a valid locale.");
|
||||||
@ -133,7 +145,7 @@ public class BeesPlus extends JavaPlugin {
|
|||||||
|
|
||||||
boolean isProtectionSuitEnabled = getConfig().getBoolean("beeprotectionsuit.enabled", true);
|
boolean isProtectionSuitEnabled = getConfig().getBoolean("beeprotectionsuit.enabled", true);
|
||||||
|
|
||||||
if(isProtectionSuitEnabled) {
|
if (isProtectionSuitEnabled) {
|
||||||
customItemManager.registerCustomItem("protection_boots", new BeeProtectionBoots());
|
customItemManager.registerCustomItem("protection_boots", new BeeProtectionBoots());
|
||||||
customItemManager.registerCustomItem("protection_leggings", new BeeProtectionLeggings());
|
customItemManager.registerCustomItem("protection_leggings", new BeeProtectionLeggings());
|
||||||
customItemManager.registerCustomItem("protection_chestplate", new BeeProtectionChestplate());
|
customItemManager.registerCustomItem("protection_chestplate", new BeeProtectionChestplate());
|
||||||
|
@ -21,7 +21,8 @@ public class UpdateChecker {
|
|||||||
|
|
||||||
public void getVersion(final Consumer<String> consumer) {
|
public void getVersion(final Consumer<String> consumer) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(beesPlus, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(beesPlus, () -> {
|
||||||
try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scanner = new Scanner(inputStream)) {
|
try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream();
|
||||||
|
Scanner scanner = new Scanner(inputStream)) {
|
||||||
if (scanner.hasNext()) {
|
if (scanner.hasNext()) {
|
||||||
consumer.accept(scanner.next());
|
consumer.accept(scanner.next());
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ public class CustomItemManager {
|
|||||||
|
|
||||||
NamespacedKey namespacedKey = new NamespacedKey(beesPlus, id);
|
NamespacedKey namespacedKey = new NamespacedKey(beesPlus, id);
|
||||||
ShapedRecipe recipe = new ShapedRecipe(namespacedKey, customItem.getResult());
|
ShapedRecipe recipe = new ShapedRecipe(namespacedKey, customItem.getResult());
|
||||||
|
|
||||||
recipe.shape(customItem.getRecipe());
|
recipe.shape(customItem.getRecipe());
|
||||||
customItem.getIngredients().forEach(recipe::setIngredient);
|
customItem.getIngredients().forEach(recipe::setIngredient);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.tomff.beesplus.core.items.ItemBuilder;
|
|||||||
import com.tomff.beesplus.localization.Localization;
|
import com.tomff.beesplus.localization.Localization;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Bee;
|
import org.bukkit.entity.Bee;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class BeeInfo extends Gui {
|
public class BeeInfo extends Gui {
|
||||||
@ -26,6 +27,44 @@ public class BeeInfo extends Gui {
|
|||||||
return Localization.get(Localization.BEE_INFO_GUI_TITLE);
|
return Localization.get(Localization.BEE_INFO_GUI_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rideBee(Player player) {
|
||||||
|
double distance = player.getLocation().distance(bee.getLocation());
|
||||||
|
|
||||||
|
if (!player.hasPermission("beesplus.bee.ride")) {
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 2, 2);
|
||||||
|
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_NO_PERMISSION);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bee.getAnger() > 0) {
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 2, 2);
|
||||||
|
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_ANGRY);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distance <= 6) {
|
||||||
|
if (bee.getPassengers().size() >= 1) {
|
||||||
|
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_ALREADY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.closeInventory();
|
||||||
|
|
||||||
|
bee.addPassenger(player);
|
||||||
|
|
||||||
|
String title = Localization.get(Localization.RIDE_BEE_TITLE, player.getName());
|
||||||
|
String subtitle = Localization.get(Localization.RIDE_BEE_SUBTITLE, player.getName());
|
||||||
|
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_FLAP, 10, 1);
|
||||||
|
player.sendTitle(title, subtitle, 10, 25, 10);
|
||||||
|
} else {
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 2, 2);
|
||||||
|
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_TOO_FAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildIcons() {
|
public void buildIcons() {
|
||||||
ItemStack age = new ItemBuilder(Material.OAK_SIGN)
|
ItemStack age = new ItemBuilder(Material.OAK_SIGN)
|
||||||
@ -64,44 +103,7 @@ public class BeeInfo extends Gui {
|
|||||||
.setName(Localization.get(Localization.BEE_INFO_GUI_RIDE))
|
.setName(Localization.get(Localization.BEE_INFO_GUI_RIDE))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Icon mountIcon = new Icon(mount, (player) -> {
|
Icon mountIcon = new Icon(mount, this::rideBee);
|
||||||
double distance = player.getLocation().distance(bee.getLocation());
|
|
||||||
|
|
||||||
if (!player.hasPermission("beesplus.bee.ride")) {
|
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 2, 2);
|
|
||||||
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_NO_PERMISSION);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bee.getAnger() > 0) {
|
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 2, 2);
|
|
||||||
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_ANGRY);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (distance <= 6) {
|
|
||||||
|
|
||||||
if (bee.getPassengers().size() >= 1) {
|
|
||||||
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_ALREADY);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.closeInventory();
|
|
||||||
|
|
||||||
bee.addPassenger(player);
|
|
||||||
|
|
||||||
String title = Localization.get(Localization.RIDE_BEE_TITLE, player.getName());
|
|
||||||
String subtitle = Localization.get(Localization.RIDE_BEE_SUBTITLE, player.getName());
|
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_FLAP, 10, 1);
|
|
||||||
player.sendTitle(title, subtitle, 10, 25, 10);
|
|
||||||
} else {
|
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 2, 2);
|
|
||||||
Localization.sendMessage(player, Localization.BEE_INFO_GUI_RIDE_TOO_FAR);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setIcon(mountIcon, 15);
|
setIcon(mountIcon, 15);
|
||||||
|
|
||||||
ItemStack stung = new ItemBuilder(Material.IRON_SWORD)
|
ItemStack stung = new ItemBuilder(Material.IRON_SWORD)
|
||||||
|
@ -8,17 +8,17 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
public class LocalizationWrapper {
|
public class LocalizationLoader {
|
||||||
|
|
||||||
private final BeesPlus beesPlus;
|
private final BeesPlus beesPlus;
|
||||||
private final String basePath;
|
private final String basePath;
|
||||||
|
|
||||||
public LocalizationWrapper(BeesPlus beesPlus, String path) {
|
public LocalizationLoader(BeesPlus beesPlus, String path) {
|
||||||
this.beesPlus = beesPlus;
|
this.beesPlus = beesPlus;
|
||||||
this.basePath = path;
|
this.basePath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public YamlConfiguration getLocale(String locale) throws IOException, InvalidConfigurationException {
|
public YamlConfiguration load(String locale) throws IOException, InvalidConfigurationException {
|
||||||
String path = Paths.get(basePath, locale + ".yml").toString();
|
String path = Paths.get(basePath, locale + ".yml").toString();
|
||||||
File localeFile = new File(beesPlus.getDataFolder(), path);
|
File localeFile = new File(beesPlus.getDataFolder(), path);
|
||||||
|
|
@ -87,10 +87,10 @@ bee_protection_boots: "&6Bottes de protection des abeilles"
|
|||||||
###################
|
###################
|
||||||
# Beehive upgrade item
|
# Beehive upgrade item
|
||||||
###################
|
###################
|
||||||
beehive_upgrade_item_name: "&6Beehive Upgrade"
|
beehive_upgrade_item_name: "&6Amélioration de la ruche"
|
||||||
|
|
||||||
# Use || to a create a new line
|
# Use || to a create a new line
|
||||||
beehive_upgrade_item_lore: "&7Bee capacity: &a+3||&8(Right click to use)"
|
beehive_upgrade_item_lore: "&7Capacité d'abeilles: &a+3||&8(Cliquez à droite pour l'utiliser)"
|
||||||
|
|
||||||
beehive_upgrade_success: "&aBeehive upgraded! New population: &7%beesno%&a bees"
|
beehive_upgrade_success: "&aLa ruche a été améliorée ! Nouvelle population de: &7%beesno%&a abeilles"
|
||||||
beehive_upgrade_max: "&cError: This beehive has reached the maximum population allowed!"
|
beehive_upgrade_max: "&cErreur : Cette ruche a atteint sa capacité maximale !"
|
||||||
|
@ -2,7 +2,7 @@ name: BeesPlus
|
|||||||
author: Attlantiz
|
author: Attlantiz
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: com.tomff.beesplus.BeesPlus
|
main: com.tomff.beesplus.BeesPlus
|
||||||
api-version: 1.15
|
api-version: 1.18
|
||||||
permissions:
|
permissions:
|
||||||
beesplus.bee.view:
|
beesplus.bee.view:
|
||||||
default: op
|
default: op
|
||||||
@ -14,4 +14,3 @@ permissions:
|
|||||||
default: op
|
default: op
|
||||||
beesplus.beehive.upgrade:
|
beesplus.beehive.upgrade:
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user