Skip to content

Commit

Permalink
Vault fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leothawne committed Feb 13, 2024
1 parent a16a2fc commit 7c0670b
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ plugin.yml
pom.xml
portuguese.yml
vietnamese.yml
src/main/nms/remapped_server_1.20.4.jar
47 changes: 46 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.leothawne</groupId>
<artifactId>LTItemMail</artifactId>
<version>0.3.2</version>
<version>0.3.3</version>
<name>LT Item Mail</name>
<description>Have you ever imagined mailing items to your friends in Minecraft?</description>
<build>
Expand All @@ -17,6 +17,51 @@
</configuration>
<version>3.12.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<version>2.1.2</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>javadoc-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<failOnError>false</failOnError>
</configuration>
</execution>
</executions>
<configuration>
<charset>UTF-8</charset>
<show>public</show>
</configuration>
<version>2.10.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<version>2.5</version>
</plugin>
</plugins>
<resources>
<resource>
Expand Down
15 changes: 1 addition & 14 deletions src/main/java/io/github/leothawne/LTItemMail/LTItemMail.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.leothawne.LTItemMail;

import java.sql.Connection;
Expand Down Expand Up @@ -74,6 +60,7 @@ public final void onEnable() {
}
} else ConsoleModule.info("Database is up to date! (" + dbVer + ")");
RecipeModule.register();
RecipeModule.scheduleFailsafe();
MailboxItemTask.run();
registerEvents(new VirtualMailboxListener(),
new PlayerListener(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final boolean onCommand(final CommandSender sender, final Command cmd, fi
final Player player = (Player) sender;
if(args.length == 0) {
player.sendMessage(ChatColor.DARK_GREEN + "[" + (String) ConfigurationModule.get(ConfigurationModule.Type.PLUGIN_TAG) + "] " + ChatColor.YELLOW + "" + LanguageModule.get(LanguageModule.Type.PLAYER_MISSINGERROR));
} else if(args.length == 1) {
} else if(args.length >= 1) {
final OfflinePlayer playerTo = Bukkit.getOfflinePlayer(args[0]);
if(playerTo.hasPlayedBefore()) {
if(playerTo.getUniqueId().equals(player.getUniqueId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final List<String> getDescription(String data) {
}
@Override
public final ItemType getType() {
return ItemType.MAILBOX_ITEM;
return ItemType.MAILBOX;
}
@Override
public final Material getMaterial() {
Expand All @@ -51,7 +51,7 @@ public final LinkedList<BukkitTask> getTasks() {
}
@Override
public final ItemStack getItem(final String data) {
ItemStack item = new ItemStack(getMaterial());
final ItemStack item = new ItemStack(getMaterial(), 1);
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName(getName());
meta.setLore(getDescription(data));
Expand All @@ -60,11 +60,12 @@ public final ItemStack getItem(final String data) {
}
@Override
public final Recipe getRecipe() {
final ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(LTItemMail.getInstance(), getType().toString().toLowerCase()), getItem(null));
recipe.shape("PPP", "PBP", "PFP");
recipe.setIngredient('P', Material.STONE);
recipe.setIngredient('B', Material.CHEST);
recipe.setIngredient('F', Material.IRON_INGOT);
final NamespacedKey key = new NamespacedKey(LTItemMail.getInstance(), getType().toString().toLowerCase());
final ShapedRecipe recipe = new ShapedRecipe(key, getItem(null));
recipe.shape("ppp", "pbp", "pgp");
recipe.setIngredient('p', Material.STONE);
recipe.setIngredient('b', Material.CHEST);
recipe.setIngredient('g', Material.IRON_INGOT);
return recipe;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.github.leothawne.LTItemMail.item.model;

public enum ItemType {
MAILBOX_ITEM
MAILBOX
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ public static final Object get(final Type type) {
result = true;
path = "hook.worldguard";
break;
case PLUGIN_DEBUG:
result = false;
path = "plugin.debug";
break;
}
if(path != null && result != null) if(LTItemMail.getInstance().getConfiguration().isSet(path)) {
if(path != null) if(LTItemMail.getInstance().getConfiguration().isSet(path)) {
result = LTItemMail.getInstance().getConfiguration().get(path);
} else {
} else if(result != null) {
ConsoleModule.warning("Configuration fallback: [" + path + ":" + result + "]");
LTItemMail.getInstance().getConfiguration().set(path, result);
try {
Expand All @@ -121,6 +125,7 @@ public enum Type {
PLUGIN_HOOK_REDPROTECT,
PLUGIN_HOOK_TOWNYADVANCED,
PLUGIN_HOOK_WORLDGUARD,
PLUGIN_DEBUG,
MAILBOX_TITLE,
MAILBOX_TYPE_COST,
MAILBOX_COST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private static final ConsoleCommandSender getConsoleSender() {
public static final void Hello() {
getConsoleSender().sendMessage(ChatColor.AQUA + " _ _______ _____ __ __ ");
getConsoleSender().sendMessage(ChatColor.AQUA + "| | |__ __|_ _| \\/ |");
getConsoleSender().sendMessage(ChatColor.AQUA + "| | | | | | | \\ / |" + ChatColor.WHITE + " V: " + LTItemMail.getInstance().getDescription().getVersion() + " (Minecraft: " + DataModule.getVersion(DataModule.VersionType.MINECRAFT) + ")");
getConsoleSender().sendMessage(ChatColor.AQUA + "| | | | | | | \\ / |" + ChatColor.WHITE + " V: " + LTItemMail.getInstance().getDescription().getVersion());
getConsoleSender().sendMessage(ChatColor.AQUA + "| | | | | | | |\\/| |" + ChatColor.WHITE + " Requires Java: " + DataModule.getVersion(DataModule.VersionType.JAVA) + " (or higher)");
getConsoleSender().sendMessage(ChatColor.AQUA + "| |____| | _| |_| | | |" + ChatColor.WHITE + " Released on: " + DataModule.getVersionDate());
getConsoleSender().sendMessage(ChatColor.AQUA + "|______|_| |_____|_| |_|" + ChatColor.WHITE + " Creator's X (Twitter): @nc2ps");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
public final class DataModule {
private DataModule() {}
private static final String PROJECT_PAGES = "BUKKIT_DEV:dev.bukkit.org/projects/lt-item-mail,SPIGOT_MC:www.spigotmc.org/resources/62294";
private static final String VERSIONS = "DATABASE:2,CONFIG_YML:8,ENGLISH_YML:7,PORTUGUESE_YML:7,VIETNAMESE_YML:3,MINECRAFT:1.19,JAVA:8+";
private static final String Plugin_Date = "30/12/2023 21:44 (BRT)";
private static final String VERSIONS = "DATABASE:2,CONFIG_YML:9,ENGLISH_YML:7,PORTUGUESE_YML:7,VIETNAMESE_YML:3,MINECRAFT:1.19,JAVA:8+";
private static final String Plugin_Date = "12/02/2024 22:32 (BRT)";
private static final String Minecraft_Build = "1.13-R0.1-SNAPSHOT";
private static final String Update_URL = "https://leothawne.github.io/LTItemMail/api/" + getVersion(VersionType.MINECRAFT) + ".html";
private static final String Plugin_URL = "https://leothawne.github.io/LTItemMail/api/$version/plugin.html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ public static final String get(final Type type) {
path = "command.player.costs";
break;
}
if(path != null && result != null) if(LTItemMail.getInstance().getLanguage().isSet(path)) {
if(path != null) if(LTItemMail.getInstance().getLanguage().isSet(path)) {
result = LTItemMail.getInstance().getLanguage().getString(path);
} else {
} else if(result != null) {
ConsoleModule.warning("Language fallback: [" + path + ":" + result + "]");
LTItemMail.getInstance().getLanguage().set(path, result);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@

import io.github.leothawne.LTItemMail.LTItemMail;
import io.github.leothawne.LTItemMail.item.MailboxItem;
import io.github.leothawne.LTItemMail.item.model.Item;

public final class RecipeModule {
private RecipeModule() {}
private static final Item mailbox = new MailboxItem();
public static final void register() {
try {
Bukkit.addRecipe(mailbox.getRecipe());
if((Boolean) ConfigurationModule.get(ConfigurationModule.Type.PLUGIN_DEBUG)) ConsoleModule.debug(mailbox.getType().toString().toLowerCase() + " registered.");
} catch(final IllegalStateException exception) {
if((Boolean) ConfigurationModule.get(ConfigurationModule.Type.PLUGIN_DEBUG)) ConsoleModule.debug(mailbox.getType().toString().toLowerCase() + " is registered already.");
}
}
public static final void scheduleFailsafe() {
new BukkitRunnable() {
@Override
public final void run() {
try {
Bukkit.getServer().addRecipe(new MailboxItem().getRecipe());
} catch(final IllegalStateException exception) {}
RecipeModule.register();
}
}.runTaskTimer(LTItemMail.getInstance(), 0, 20 * 5);
}.runTaskTimer(LTItemMail.getInstance(), 20 * 15, 20 * 15);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final boolean register(final FPlugin FPlugin) {
case VAULT_ECONOMY:
if(isInstalled(TPlugin.VAULT)) {
final RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
if(rsp != null) register.putIfAbsent(FPlugin, rsp);
if(rsp != null) register.putIfAbsent(FPlugin, rsp.getProvider());
}
break;
case GRIEF_PREVENTION_API:
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ plugin:
#Enable or disable this plugin. Default: true
enable: true
#INTERNAL languages support: portuguese, english, vietnamese. Default: english
language: english
language: "english"
#Here you can customize the name tag that appears in chat. Default: LTIM
tag: LTIM
tag: "LTIM"
#Show error messages if something go wrong
debug: false

hook:
#Set 'true' if you wish to use area protection plugins. Defaults: true
Expand All @@ -23,11 +25,11 @@ mail:
#Cost value to send items. Default: 1.5 (per item) and 30.0 (per mailbox)
value: 30.0
#Name of the mail inventory. Default: Mailbox.
name: Mailbox
name: "Mailbox"

#Should administrators be warned about new updates? Default: true
update:
check: true

#Do not change this under any circumstances!
config-version: 8
config-version: 9
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: LTItemMail
description: Have you ever imagined mailing items to your friends in Minecraft?
version: ${project.version}
api-version: 1.13
load: POSTWORLD
load: STARTUP
author: [leothawne]
website: https://leothawne.github.io/LTItemMail/
url: https://leothawne.github.io/LTItemMail/
main: io.github.leothawne.LTItemMail.LTItemMail
database: true
soft-depend: [Vault, GriefPrevention, RedProtect, Towny, WorldGuard]
soft-depend: [Vault, Essentials, GriefPrevention, RedProtect, Towny, WorldGuard]
commands:
itemmail:
description: Commands for players.
Expand Down

0 comments on commit 7c0670b

Please sign in to comment.