This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove useless code; support 1.13.0 through 1.18.2
- Loading branch information
Showing
4 changed files
with
19 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 11 additions & 69 deletions
80
src/main/java/com/budderman18/tooexpensivefix/TooExpensiveFix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,27 @@ | ||
package com.budderman18.tooexpensivefix; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.ConsoleCommandSender; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.PrepareAnvilEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
/** | ||
* This class enables and disables the plugin | ||
* It also imports commands and handles events | ||
*/ | ||
public class TooExpensiveFix extends JavaPlugin implements Listener { | ||
private final ConsoleCommandSender sender = getServer().getConsoleSender(); | ||
private final String prefixMessage = ChatColor.translateAlternateColorCodes('&', "&a[&cTooExpensiveFix&a] "); | ||
/* | ||
* | ||
* Enables the plugin. | ||
* Checks if MC version isn't the latest. | ||
* If its not, warn the player about lacking support | ||
* Checks if server is running offline mode | ||
* If it is, disable the plugin | ||
* Also loads death event | ||
* | ||
*/ | ||
public class TooExpensiveFix extends JavaPlugin implements Listener { | ||
|
||
@Override | ||
public void onEnable() { | ||
//language variables | ||
final String unsupportedVersionAMessage = ChatColor.translateAlternateColorCodes('&', "&4TooExpensiveFix does not support your version!"); | ||
final String unsupportedVersionBMessage = ChatColor.translateAlternateColorCodes('&', "&aOnly 1.18.2 is supported"); | ||
final String unsupportedVersionCMessage = ChatColor.translateAlternateColorCodes('&', "&aThis plugin will likely not work and you will get no support for issues"); | ||
final String unsecureServerAMessage = ChatColor.translateAlternateColorCodes('&', "&4NEVER EVER EVER EVER EVER EVER USE OFFLINE MODE!!!!!!!!!!!!!!!"); | ||
final String unsecureServerBMessage = ChatColor.translateAlternateColorCodes('&', "&cOffline mode is a serious threat to your server and will never be supported by my plugins!"); | ||
final String unsecureServerCMessage = ChatColor.translateAlternateColorCodes('&', "&cTo protect your safety and this plugin''s saftey, this plugin will now be disabled"); | ||
final String pluginEnabledMessage = ChatColor.translateAlternateColorCodes('&', "&eTooExpensiveFix by Budderman18 has been enabled!"); | ||
//check for correct version | ||
if (!(Bukkit.getVersion().contains("1.18.2"))) { | ||
sender.sendMessage(prefixMessage + unsupportedVersionAMessage); | ||
sender.sendMessage(prefixMessage + unsupportedVersionBMessage); | ||
sender.sendMessage(prefixMessage + unsupportedVersionCMessage); | ||
} | ||
//check for online mode | ||
if (!(getServer().getOnlineMode())) { | ||
sender.sendMessage(prefixMessage + unsecureServerAMessage); | ||
sender.sendMessage(prefixMessage + unsecureServerBMessage); | ||
sender.sendMessage(prefixMessage + unsecureServerCMessage); | ||
getServer().getPluginManager().disablePlugin(this); | ||
} | ||
//events | ||
getServer().getPluginManager().registerEvents(this,this); | ||
//enable plugin | ||
getServer().getPluginManager().enablePlugin(this); | ||
sender.sendMessage(prefixMessage + pluginEnabledMessage); | ||
getServer().getPluginManager().registerEvents(this, this); | ||
} | ||
/* | ||
* | ||
* This method disables the plugin | ||
* | ||
*/ | ||
@Override | ||
public void onDisable() { | ||
final String pluginDisabledMessage = ChatColor.translateAlternateColorCodes('&', "&eXPDeathDropFix by Budderman18 has been disabled!"); | ||
//disables plugin | ||
getServer().getPluginManager().disablePlugin(this); | ||
sender.sendMessage(prefixMessage + pluginDisabledMessage); | ||
} | ||
/* | ||
* | ||
* This method hadles everything involving fixing the limit | ||
* It simply always sets the maximum to the level limit | ||
* It also sets renamed items to 1 level | ||
* | ||
*/ | ||
|
||
@EventHandler | ||
public void onAnvilUse(PrepareAnvilEvent event) { | ||
event.getInventory().setMaximumRepairCost(21862); | ||
if (event.getInventory().getItem(2) != null) { | ||
if (event.getInventory().getItem(0).getItemMeta().getDisplayName() != event.getInventory().getItem(2).getItemMeta().getDisplayName() && event.getInventory().getItem(1) == null) { | ||
event.getInventory().setRepairCost(1); | ||
} | ||
ItemStack original = event.getInventory().getItem(0); | ||
ItemStack result = event.getInventory().getItem(2); | ||
if (original == null || result == null) return; | ||
if (!original.hasItemMeta() || !result.hasItemMeta()) return; | ||
if (!original.getItemMeta().getDisplayName().equals(result.getItemMeta().getDisplayName()) && event.getInventory().getItem(1) == null) { | ||
event.getInventory().setRepairCost(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: TooExpensiveFix | ||
main: com.budderman18.TooExpensiveFix.Main | ||
main: com.budderman18.tooexpensivefix.TooExpensiveFix | ||
author: Budderman18 | ||
description: Removes the "Too Expensive!" tag in anvils and makes all re-name costs only 1 level. | ||
version: 1.0 | ||
version: 2.0 | ||
api-version: 1.13 |
baaba43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you would like, I can link your fork on my spigot page as a version that supports more than just 1.18.2. You would need to attach a jar file to the 2.0 release so people can download it.
baaba43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I can do that, just didn't know if you were OK with redistribution of modifications.
baaba43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with redistribution as long as its open-source and free.