UltimateRepairing

This commit is contained in:
Brianna O'Keefe 2018-11-23 14:59:13 -05:00
parent 4469b0acfb
commit 45546fa554
31 changed files with 175 additions and 1008 deletions

2
.gitignore vendored
View File

@ -3,7 +3,7 @@ out/
target
\.idea/
RepairPlus\.iml
UltimateRepairing\.iml
/src/main/java/META-INF/MANIFEST.MF
target/classes/com/massivestats/MassiveStats\.class

View File

@ -6,7 +6,7 @@ build:
image: maven:3.3.9-jdk-8
script: "mvn clean package"
artifacts:
name: "RepairPlus"
name: "UltimateRepairing"
paths:
- "/builds/Songoda/RepairPlus/target/*.jar"
- "/builds/Songoda/RepairPlus/Read_this_before_your_first_use.txt"
- "/builds/Songoda/UltimateRepairing/target/*.jar"
- "/builds/Songoda/UltimateRepairing/Read_this_before_your_first_use.txt"

View File

@ -1,5 +1,5 @@
# RepairPlus
# UltimateRepairing
RepairPlus brings forth a new frontier to the Minecraft anvil. Using RepairPlus, toBeRepaired will now be able to left-click anvils and repair items at the cost of EXP or in-game Economy balance. It also allows you to give anvils Unbreaking so that they will never break, which is extremely useful for an anvil at spawn! Have questions? Check out our support page [here](http://songoda.com/support.php?a=product&id=RepairPlus.9 "http://songoda.com/support.php?a=product&id=RepairPlus.9").
UltimateRepairing brings forth a new frontier to the Minecraft anvil. Using UltimateRepairing, toBeRepaired will now be able to left-click anvils and repair items at the cost of EXP or in-game Economy balance. It also allows you to give anvils Unbreaking so that they will never break, which is extremely useful for an anvil at spawn! Have questions? Check out our support page [here](http://songoda.com/support.php?a=product&id=UltimateRepairing.9 "http://songoda.com/support.php?a=product&id=UltimateRepairing.9").
![N|Solid](https://i.imgur.com/jKtE7ZM.png)

View File

@ -1,8 +1,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<groupId>com.songoda</groupId>
<artifactId>RepairPlus</artifactId>
<artifactId>UltimateRepairing</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.4.1</version>
<version>1</version>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>

View File

@ -1,490 +0,0 @@
/*
* Copyright 2018 (c) Massive Statistics LLC - All Rights Reserved
* This file may only be used in conjunction with the 'MassiveStats' service.
*/
package com.massivestats;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
/**
* MassiveStats collects plugin and server information for plugin authors.
* You can learn more at our website: https://www.massivestats.com/
*
* @version 3.0
* @author Sam Jakob Harker, Brianna Hazel O'Keefe
*/
@SuppressWarnings("all")
public class MassiveStats implements Listener {
/* START: MASSIVESTATS SETTINGS */
public static final int CLIENT_VERSION = 0; // v3.0
public static final String API_URL = "https://report.massivestats.com/v2/";
public static final String MASSIVE_UPDATE_PERMISSION = "massivestats.update";
/* END: MASSIVESTATS SETTINGS */
private MassiveStatsUpdateTask task = null;
private int pingInterval;
private MassiveStatsDataResponse lastResponse;
private boolean listenerDisabled;
private final JavaPlugin plugin;
private Class jsonElement;
private Class jsonParser;
private Class jsonObject;
private Class jsonPrimitive;
/**
* @param plugin The plugin you wish to collect data for.
* @author Sam Jakob Harker
*/
public MassiveStats(JavaPlugin plugin){
this(plugin, 900); // default value: 900 seconds (= 15 minutes)
}
/**
* @param plugin The plugin you wish to collect data for.
* @param pingInterval Duration between requests.
* @author Sam Jakob Harker
*/
public MassiveStats(JavaPlugin plugin, int pingInterval){
try {
jsonElement = Class.forName("com.google.gson.JsonElement");
jsonParser = Class.forName("com.google.gson.JsonParser");
jsonObject = Class.forName("com.google.gson.JsonObject");
jsonPrimitive = Class.forName("com.google.gson.JsonPrimitive");
}catch(ClassNotFoundException ex){
// Gson not included in classpath (so use NMS version)
try {
jsonElement = Class.forName("net.minecraft.util.com.google.gson.JsonElement");
jsonParser = Class.forName("net.minecraft.util.com.google.gson.JsonParser");
jsonObject = Class.forName("net.minecraft.util.com.google.gson.JsonObject");
jsonPrimitive = Class.forName("net.minecraft.util.com.google.gson.JsonPrimitive");
}catch(ClassNotFoundException ignored){
Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use.");
this.plugin = null;
return;
}
}
// Ensure the pingInterval that is set is reasonable.
if(pingInterval < 10 || pingInterval > 86400){
pingInterval = 900;
}
// Ensure that a plugin instance has been provided.
if(plugin == null){
throw new IllegalArgumentException("You must provide a plugin for MassiveStats to collect data for!");
}
// Set the ping interval.
this.pingInterval = pingInterval;
// Set the plugin reference.
this.plugin = plugin;
// and start sending data to the MassiveStats server immediately.
start();
// Register join/leave events for the plugin
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
}
/**
* Gets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled.
* @return Whether or not the MassiveStats listener is enabled.
*/
public boolean isListenerDisabled(){
return listenerDisabled;
}
/**
* Sets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled.
* @param listenerDisabled Whether or not the MassiveStats listener is enabled.
*/
public void setListenerDisabled(boolean listenerDisabled){
this.listenerDisabled = listenerDisabled;
}
/**
* Start the MassiveStats reporting timer.
* If the timer is already running, this method will do nothing.
* @author Sam Jakob Harker
*/
public void start(){
if(this.plugin == null){
Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use and thus cannot start.");
return;
}
if(task == null){
// If the API endpoint URL is invalid, don't start a new task to prevent the user from being spammed.
try {
new URL(MassiveStats.API_URL);
}catch(MalformedURLException ex){
getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for MassiveStats.");
return;
}
task = new MassiveStatsUpdateTask(this);
task.runTaskTimerAsynchronously(plugin, 0L, pingInterval * 20L);
}
}
/**
* Stop the MassiveStats reporting timer.
* Requests will no longer be sent to the server - or until {@link #start()} is invoked.
* @author Sam Jakob Harker
*/
public void stop(){
if(task == null){
return;
}
task.cancel();
task = null;
}
/**
* Sets the duration, in seconds, that MassiveStats should wait before sending another request to the server.
* @param pingInterval Duration between requests.
* @author Sam Jakob Harker
*/
public void setPingInterval(int pingInterval){
this.pingInterval = pingInterval;
stop();
start();
}
/**
* Returns the duration, in seconds, that MassiveStats will wait before sending another request to the server.
* @return Duration between requests.
* @author Sam Jakob Harker
*/
public int getPingInterval(){
return pingInterval;
}
/**
* Returns the plugin that this MassiveStats instance is collecting data for.
* @return MassiveStats instance plugin.
* @author Sam Jakob Harker
*/
public JavaPlugin getPlugin(){
return plugin;
}
void setLastResponse(MassiveStatsDataResponse lastResponse){
this.lastResponse = lastResponse;
}
/**
* Returns the contents of the last response from the MassiveStats server.
* @return MassiveStats server response.
* @author Sam Jakob Harker
*/
public MassiveStatsDataResponse getLastResponse() {
return lastResponse;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
// Ensure the listener should be active
if(lastResponse == null || listenerDisabled){
return;
}
// Of course, only notify the user if the plugin is not up to date.
if(lastResponse.isUpToDate()){
return;
}
// and only notify operators - or players with the correct permission.
if(!event.getPlayer().isOp() && !event.getPlayer().hasPermission(MassiveStats.MASSIVE_UPDATE_PERMISSION)){
return;
}
event.getPlayer().sendMessage(lastResponse.getUpdateMessage());
}
Class getJsonElement(){
return jsonElement;
}
Class getJsonParser(){
return jsonParser;
}
Class getJsonObject(){
return jsonObject;
}
Class getJsonPrimitive(){
return jsonPrimitive;
}
}
class MassiveStatsUpdateTask extends BukkitRunnable {
private final MassiveStats instance;
MassiveStatsUpdateTask(MassiveStats requester){
instance = requester;
}
@Override
@SuppressWarnings("all")
public void run(){
try {
// Generate the request payload and serialize it as JSON.
String payload = new MassiveStatsDataRequest(instance).serialize();
// Then create a new HttpsUrlConnection to the API server and open it.
HttpsURLConnection connection = (HttpsURLConnection) new URL(MassiveStats.API_URL).openConnection();
// Ensure that we don't hang the server with our 'dang shenanigans'.
connection.setConnectTimeout(2500);
connection.setReadTimeout(3500);
// Set the all-important request headers before we begin POSTing...
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
connection.setRequestProperty("User-Agent", "Massive/" + MassiveStats.CLIENT_VERSION);
// Open the output stream, write the payload, and then close the stream.
connection.setDoOutput(true);
DataOutputStream output = new DataOutputStream(connection.getOutputStream());
output.writeBytes(payload);
output.flush();
output.close();
// Ensure that the server was happy with our data.
int responseCode = connection.getResponseCode();
if(responseCode != 200){
throw new IOException();
}
// Now, read the server's response to our payload...
BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
// ...line by line.
String line;
while((line = input.readLine()) != null){
response.append(line);
}
input.close();
// Now, we parse the JSON object.
try {
if(response.toString().contains("ERR_DATA_MISSING")){
Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName());
instance.stop();
return;
}
Object parser = instance.getJsonParser().newInstance();
// JsonElement
Object serverResponseRaw =
parser.getClass().getMethod("parse", String.class).invoke(parser, response.toString());
// JsonObject
Object serverResponse = serverResponseRaw.getClass().getMethod("getAsJsonObject", null)
.invoke(serverResponseRaw, null);
Method serverResponseGet = instance.getJsonObject().getMethod("get", String.class);
Method getAsBoolean =
instance.getJsonPrimitive().getMethod("getAsBoolean", null);
Method getAsString =
instance.getJsonPrimitive().getMethod("getAsString", null);
if(serverResponseGet.invoke(serverResponse, "upToDate") == null){
Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName());
instance.stop();
return;
}
if(serverResponseGet.invoke(serverResponse, "notice") != null) {
Bukkit.getLogger().severe(
(String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "notice"))
);
instance.stop();
return;
}
boolean upToDate = (boolean) getAsBoolean.invoke(serverResponseGet.invoke(serverResponse, "upToDate"), null);
String latestVersion = (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "latestVersion"), null);
String updateMessage = ChatColor.translateAlternateColorCodes(
'&', (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "updateMessage"), null)
);
instance.setLastResponse(new MassiveStatsDataResponse(
upToDate, latestVersion, updateMessage
));
}catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
instance.getPlugin()
.getLogger().warning("MassiveStats returned an invalid response for this plugin.");
}
// Finally, call an event to mark the update.
} catch(MalformedURLException ex){
instance.getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for MassiveStats.");
}catch(IOException ex){
instance.getPlugin()
.getLogger().warning("MassiveStats was unable to communicate with its API endpoint.");
}
}
}
class MassiveStatsDataRequest {
private Object jsonObject;
MassiveStatsDataRequest(MassiveStats requester){
try {
jsonObject = requester.getJsonObject().newInstance();
Method add =
requester.getJsonObject().newInstance().getClass().getMethod("add", String.class, requester.getJsonElement());
Method addPropertyString =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, String.class);
Method addPropertyNumber =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Number.class);
Method addPropertyBoolean =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Boolean.class);
addPropertyNumber.invoke(jsonObject, "now", System.currentTimeMillis());
/* PLUGIN DATA */
Object pluginObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(pluginObject, "name", requester.getPlugin().getDescription().getName());
addPropertyString.invoke(pluginObject, "version", requester.getPlugin().getDescription().getVersion());
add.invoke(jsonObject, "plugin", pluginObject);
/* SERVER DATA */
Object minecraftServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(minecraftServerObject, "players", Bukkit.getServer().getOnlinePlayers().size());
addPropertyBoolean.invoke(minecraftServerObject, "onlineMode", Bukkit.getServer().getOnlineMode());
addPropertyString.invoke(minecraftServerObject, "version", Bukkit.getServer().getVersion());
Object javaServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(javaServerObject, "version", System.getProperty("java.version"));
Object osServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(osServerObject, "name", System.getProperty("os.name"));
addPropertyString.invoke(osServerObject, "arch", System.getProperty("os.arch"));
addPropertyString.invoke(osServerObject, "version", System.getProperty("os.version"));
Object hardwareServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(hardwareServerObject, "cores", Runtime.getRuntime().availableProcessors());
Object serverObject = jsonObject.getClass().newInstance();
add.invoke(serverObject, "minecraft", minecraftServerObject);
add.invoke(serverObject, "java", javaServerObject);
add.invoke(serverObject, "os", osServerObject);
add.invoke(serverObject,"hardware", hardwareServerObject);
add.invoke(jsonObject, "server", serverObject);
/* MASSIVE DATA */
Object massiveObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(massiveObject, "version", MassiveStats.CLIENT_VERSION);
addPropertyNumber.invoke(massiveObject, "pingInterval", requester.getPingInterval());
//object.add("Massive", massiveObject);
add.invoke(jsonObject,"Massive", massiveObject);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
}
@SuppressWarnings("all")
public String serialize(){
//return object.toString();
try {
Method toString = jsonObject.getClass().getMethod("toString", null);
return (String) toString.invoke(jsonObject);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
}
@SuppressWarnings("unused")
final class MassiveStatsDataResponse {
private final boolean isUpToDate;
private final String newVersion;
private final String updateMessage;
MassiveStatsDataResponse(boolean isUpToDate, String newVersion, String updateMessage){
this.isUpToDate = isUpToDate;
if(!isUpToDate) {
this.newVersion = newVersion;
this.updateMessage = updateMessage;
return;
}
this.newVersion = null;
this.updateMessage = null;
}
/**
* Indicates whether or not this version of the plugin is the latest.
* True = This is the latest version of the plugin.
* False = There is an update available.
* @return Whether or not there is an update available.
*/
public boolean isUpToDate() {
return isUpToDate;
}
/**
* Gets the name of the latest version. If this is the latest version, it returns null.
* @return The name of the latest version.
*/
public String getLatestVersion(){
return newVersion;
}
/**
* Gets the message to display, convincing the user to update to the new version of the plugin.
* @return The update message to display.
*/
public String getUpdateMessage(){
return updateMessage;
}
}

View File

@ -1,358 +0,0 @@
package com.songoda.repairplus.handlers;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.Locale;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.anvil.PlayerAnvilData;
import com.songoda.repairplus.anvil.PlayerAnvilData.RepairType;
import com.songoda.repairplus.utils.Debugger;
import com.songoda.repairplus.utils.Methods;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.*;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Created by songoda on 2/25/2017.
*/
public class RepairHandler {
private final RepairPlus instance;
private final Map<UUID, PlayerAnvilData> playerAnvilData = new HashMap<>();
public RepairHandler(RepairPlus instance) {
this.instance = instance;
}
private void repairType(Player p) {
try {
if (getDataFor(p).getInRepair()) {
yesNo(p,getDataFor(p).getType(), getDataFor(p).getToBeRepaired());
return;
}
Inventory i = Bukkit.createInventory(null, 27, instance.getLocale().getMessage("interface.repair.title"));
int nu = 0;
while (nu != 27) {
i.setItem(nu, Methods.getGlass());
nu++;
}
ItemStack item = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.Economy Icon")), 1);
ItemMeta itemmeta = item.getItemMeta();
ArrayList<String> lore = new ArrayList<>();
lore.add(instance.getLocale().getMessage("interface.repair.ecolore"));
itemmeta.setLore(lore);
itemmeta.setDisplayName(instance.getLocale().getMessage("interface.repair.eco"));
item.setItemMeta(itemmeta);
Material mat = Methods.getType(p.getItemInHand());
ItemStack item3 = new ItemStack(mat, 1);
String name = (mat.name().substring(0, 1).toUpperCase() + mat.name().toLowerCase().substring(1)).replace("_", " ");
ItemMeta itemmeta3 = item3.getItemMeta();
ArrayList<String> lore3 = new ArrayList<>();
lore3.add(instance.getLocale().getMessage("interface.repair.itemlore", name));
itemmeta3.setLore(lore3);
itemmeta3.setDisplayName(instance.getLocale().getMessage("interface.repair.item", name));
item3.setItemMeta(itemmeta3);
ItemStack item2 = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.XP Icon")), 1);
ItemMeta itemmeta2 = item2.getItemMeta();
ArrayList<String> lore2 = new ArrayList<>();
lore2.add(instance.getLocale().getMessage("interface.repair.xplore"));
itemmeta2.setLore(lore2);
itemmeta2.setDisplayName(instance.getLocale().getMessage("interface.repair.xp"));
item2.setItemMeta(itemmeta2);
if (p.hasPermission("repairplus.use.ECO"))
i.setItem(11, item);
if (p.hasPermission("repairplus.use.ITEM"))
i.setItem(13, item3);
if (p.hasPermission("repairplus.use.XP"))
i.setItem(15, item2);
i.setItem(0, Methods.getBackgroundGlass(true));
i.setItem(1, Methods.getBackgroundGlass(true));
i.setItem(2, Methods.getBackgroundGlass(false));
i.setItem(6, Methods.getBackgroundGlass(false));
i.setItem(7, Methods.getBackgroundGlass(true));
i.setItem(8, Methods.getBackgroundGlass(true));
i.setItem(9, Methods.getBackgroundGlass(true));
i.setItem(10, Methods.getBackgroundGlass(false));
i.setItem(16, Methods.getBackgroundGlass(false));
i.setItem(17, Methods.getBackgroundGlass(true));
i.setItem(18, Methods.getBackgroundGlass(true));
i.setItem(19, Methods.getBackgroundGlass(true));
i.setItem(20, Methods.getBackgroundGlass(false));
i.setItem(24, Methods.getBackgroundGlass(false));
i.setItem(25, Methods.getBackgroundGlass(true));
i.setItem(26, Methods.getBackgroundGlass(true));
p.openInventory(i);
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void preRepair(Player p, RepairType type, Location loc) {
try {
if (loc.add(0, 1, 0).getBlock().getType() != Material.AIR) {
p.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.needspace"));
return;
}
if (p.getItemInHand().getDurability() <= 0) {
p.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notdamaged"));
return;
}
if (p.getItemInHand().getMaxStackSize() != 1) {
p.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.cantrepair"));
return;
}
Item i = p.getWorld().dropItem(loc.add(0.5, 2, 0.5), p.getItemInHand());
// Support for EpicHoppers suction.
i.setMetadata("grabbed", new FixedMetadataValue(instance, "true"));
i.setMetadata("betterdrops_ignore", new FixedMetadataValue(instance, true));
Vector vec = p.getEyeLocation().getDirection();
vec.setX(0);
vec.setY(0);
vec.setZ(0);
i.setVelocity(vec);
i.setPickupDelay(3600);
i.setMetadata("RepairPlus", new FixedMetadataValue(instance, ""));
// Get from Map, put new instance in Map if it doesn't exist
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(p.getUniqueId(), uuid -> new PlayerAnvilData());
playerData.setItem(i);
playerData.setToBeRepaired(p.getItemInHand());
playerData.setLocations(loc.add(0, -2, 0));
yesNo(p, type, p.getItemInHand());
p.setItemInHand(null);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
if (i.isValid() && !playerData.isBeingRepaired()) {
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.timeout")));
removeItem(playerData, p);
p.closeInventory();
}
}, instance.getConfig().getLong("Main.Time Before Repair Auto Canceled"));
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void initRepair(Player p, Location location) {
int num = 0;
if (p.hasPermission("repairplus.use.ECO"))
num++;
if (p.hasPermission("repairplus.use.XP"))
num++;
if (p.hasPermission("repairplus.use.ITEM"))
num++;
if (num >= 2 || p.hasPermission("repairplus.use.*")) {
repairType(p);
getDataFor(p).setLocation(location);
} else if (p.hasPermission("repairplus.use.eco"))
instance.getRepairHandler().preRepair(p, RepairType.ECONOMY, location);
else if (p.hasPermission("repairplus.use.XP"))
instance.getRepairHandler().preRepair(p, RepairType.XP, location);
else if (p.hasPermission("repairplus.use.ITEM"))
instance.getRepairHandler().preRepair(p, RepairType.ITEM, location);
}
private void yesNo(Player p, RepairType type, ItemStack item) {
try {
PlayerAnvilData playerData = getDataFor(p);
if (playerData.isBeingRepaired()) {
return;
}
playerData.setInRepair(true);
int price = Methods.getCost(type, item);
String cost = "0";
Material mat = new Methods().getType(item);
String name = Arconix.pl().getApi().format().formatText(mat.name(), true);
if (type == RepairType.XP)
cost = price + " XP";
else if (type == RepairType.ECONOMY)
cost = "\\$" + price;
else if (type == RepairType.ITEM)
cost = price + " " + name;
Inventory i = Bukkit.createInventory(null, 27, instance.getLocale().getMessage("interface.yesno.title", cost));
int nu = 0;
while (nu != 27) {
i.setItem(nu, Methods.getGlass());
nu++;
}
ItemStack item2 = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.Buy Icon")), 1);
ItemMeta itemmeta2 = item2.getItemMeta();
itemmeta2.setDisplayName(instance.getLocale().getMessage("interface.yesno.yes"));
item2.setItemMeta(itemmeta2);
ItemStack item3 = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.Exit Icon")), 1);
ItemMeta itemmeta3 = item3.getItemMeta();
itemmeta3.setDisplayName(instance.getLocale().getMessage("interface.yesno.no"));
item3.setItemMeta(itemmeta3);
i.setItem(4, item);
i.setItem(11, item2);
i.setItem(15, item3);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> p.openInventory(i), 1);
playerData.setType(type);
playerData.setPrice(price);
i.setItem(0, Methods.getBackgroundGlass(true));
i.setItem(1, Methods.getBackgroundGlass(true));
i.setItem(2, Methods.getBackgroundGlass(false));
i.setItem(6, Methods.getBackgroundGlass(false));
i.setItem(7, Methods.getBackgroundGlass(true));
i.setItem(8, Methods.getBackgroundGlass(true));
i.setItem(9, Methods.getBackgroundGlass(true));
i.setItem(10, Methods.getBackgroundGlass(false));
i.setItem(16, Methods.getBackgroundGlass(false));
i.setItem(17, Methods.getBackgroundGlass(true));
i.setItem(18, Methods.getBackgroundGlass(true));
i.setItem(19, Methods.getBackgroundGlass(true));
i.setItem(20, Methods.getBackgroundGlass(false));
i.setItem(24, Methods.getBackgroundGlass(false));
i.setItem(25, Methods.getBackgroundGlass(true));
i.setItem(26, Methods.getBackgroundGlass(true));
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void finish(boolean answer, Player p) {
try {
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(p.getUniqueId(), uuid -> new PlayerAnvilData());
if (!answer) {
removeItem(playerData, p);
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.cancelled")));
return;
}
RepairType type = playerData.getType();
ItemStack players = playerData.getToBeRepaired();
boolean economy = false;
boolean sold = false;
if (instance.getServer().getPluginManager().getPlugin("Vault") != null && type == RepairType.ECONOMY) {
RegisteredServiceProvider<Economy> rsp = instance.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
net.milkbowl.vault.economy.Economy econ = rsp.getProvider();
int price = playerData.getPrice();
if (econ.has(p, price)) {
econ.withdrawPlayer(p, price);
sold = true;
}
economy = true;
}
int cost = Methods.getCost(type, players);
ItemStack item2 = new ItemStack(Methods.getType(players), cost);
String name = (item2.getType().name().substring(0, 1).toUpperCase() + item2.getType().name().toLowerCase().substring(1)).replace("_", " ");
if (type == RepairType.ITEM && Arconix.pl().getApi().getGUI().inventoryContains(p.getInventory(), item2)) {
Arconix.pl().getApi().getGUI().removeFromInventory(p.getInventory(), item2);
sold = true;
}
if (type == RepairType.XP && p.getLevel() >= playerData.getPrice() || sold || p.getGameMode() == GameMode.CREATIVE) {
playerData.setBeingRepaired(true);
Location location = playerData.getLocations();
p.getWorld().playEffect(location, Effect.STEP_SOUND, 152);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> p.getWorld().playEffect(location, Effect.STEP_SOUND, 152), 5L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
p.getWorld().playEffect(location, Effect.STEP_SOUND, 152);
p.getWorld().playEffect(location, Effect.STEP_SOUND, 1);
Arconix.pl().getApi().getPlayer(p).playSound(Sound.valueOf("BLOCK_ANVIL_LAND"));
}, 10L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> p.getWorld().playEffect(location, Effect.STEP_SOUND, 152), 15L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> p.getWorld().playEffect(location, Effect.STEP_SOUND, 152), 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
Arconix.pl().getApi().getPlayer(p).playSound(Sound.valueOf("BLOCK_ANVIL_LAND"));
p.getWorld().playEffect(location, Effect.STEP_SOUND, 152);
p.getWorld().playEffect(location, Effect.STEP_SOUND, 145);
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.success")));
ItemStack repairedi = playerData.getToBeRepaired();
repairedi.setDurability((short) 0);
Item repaired = p.getWorld().dropItemNaturally(p.getLocation(), repairedi);
repaired.remove();
p.getInventory().addItem(playerData.getToBeRepaired());
playerData.getItem().remove();
if (p.getGameMode() != GameMode.CREATIVE &&
type == RepairType.XP) {
p.setLevel(p.getLevel() - playerData.getPrice());
}
this.playerAnvilData.remove(p.getUniqueId());
p.closeInventory();
}, 25L);
return;
}
if (type == RepairType.ECONOMY) {
if (!economy)
p.sendMessage("Vault is not installed.");
else
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", instance.getLocale().getMessage("interface.repair.eco"))));
} else if (type == RepairType.XP)
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", instance.getLocale().getMessage("interface.repair.xp"))));
else
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", name)));
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public void removeItem(PlayerAnvilData playerData, Player p) {
try {
p.getInventory().addItem(playerData.getToBeRepaired());
playerData.getItem().remove();
this.playerAnvilData.remove(p.getUniqueId());
} catch (Exception ex) {
Debugger.runReport(ex);
}
}
public boolean hasInstance(Player player) {
return playerAnvilData.containsKey(player);
}
public PlayerAnvilData getDataFor(Player player) {
return playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.repairplus;
package com.songoda.ultimaterepairing;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

View File

@ -1,11 +1,11 @@
package com.songoda.repairplus;
package com.songoda.ultimaterepairing;
public class References {
private String prefix;
public References() {
prefix = RepairPlus.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
prefix = UltimateRepairing.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
}
public String getPrefix() {

View File

@ -1,46 +1,48 @@
package com.songoda.repairplus;
package com.songoda.ultimaterepairing;
import com.songoda.arconix.api.utils.ConfigWrapper;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.command.CommandManager;
import com.songoda.repairplus.events.BlockListeners;
import com.songoda.repairplus.events.InteractListeners;
import com.songoda.repairplus.events.InventoryListeners;
import com.songoda.repairplus.events.PlayerListeners;
import com.songoda.repairplus.handlers.HologramHandler;
import com.songoda.repairplus.handlers.ParticleHandler;
import com.songoda.repairplus.handlers.RepairHandler;
import com.songoda.repairplus.utils.Debugger;
import com.songoda.repairplus.utils.SettingsManager;
import com.songoda.ultimaterepairing.command.CommandManager;
import com.songoda.ultimaterepairing.events.BlockListeners;
import com.songoda.ultimaterepairing.events.InteractListeners;
import com.songoda.ultimaterepairing.events.InventoryListeners;
import com.songoda.ultimaterepairing.events.PlayerListeners;
import com.songoda.ultimaterepairing.handlers.HologramHandler;
import com.songoda.ultimaterepairing.handlers.ParticleHandler;
import com.songoda.ultimaterepairing.handlers.RepairHandler;
import com.songoda.ultimaterepairing.utils.Debugger;
import com.songoda.ultimaterepairing.utils.ServerVersion;
import com.songoda.ultimaterepairing.utils.SettingsManager;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public final class RepairPlus extends JavaPlugin implements Listener {
public final class UltimateRepairing extends JavaPlugin implements Listener {
private static CommandSender console = Bukkit.getConsoleSender();
private static RepairPlus INSTANCE;
private static UltimateRepairing INSTANCE;
public References references = null;
private Locale locale;
private ServerVersion serverVersion = ServerVersion.fromPackageName(Bukkit.getServer().getClass().getPackage().getName());
private RepairHandler repairHandler;
private HologramHandler hologramHandler;
private SettingsManager settingsManager;
private CommandManager commandManager;
private boolean checkVersion() {
int workingVersion = 13;
int currentVersion = Integer.parseInt(Bukkit.getServer().getClass()
.getPackage().getName().split("\\.")[3].split("_")[1]);
if (currentVersion < workingVersion) {
int maxVersion = 12; // also supports 1.8 and higher
int currentVersion = Integer.parseInt(Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].split("_")[1]);
if (currentVersion > maxVersion) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
Bukkit.getConsoleSender().sendMessage("");
Bukkit.getConsoleSender().sendMessage(String.format("%sYou installed the 1.%s only version of %s on a 1.%s server. Since you are on the wrong version we disabled the plugin for you. Please install correct version to continue using %s.", ChatColor.RED, workingVersion, this.getDescription().getName(), currentVersion, this.getDescription().getName()));
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You installed the legacy (1.8 - 1.12) only version of " + this.getDescription().getName() + " on a 1." + currentVersion + " server. Since you are on the wrong version we disabled the plugin for you. Please install correct version to continue using " + this.getDescription().getName() + ".");
Bukkit.getConsoleSender().sendMessage("");
}, 20L);
return false;
@ -58,7 +60,7 @@ public final class RepairPlus extends JavaPlugin implements Listener {
Arconix.pl().hook(this);
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
console.sendMessage(Arconix.pl().getApi().format().formatText("&7RepairPlus " + this.getDescription().getVersion() + " by &5Brianna <3!"));
console.sendMessage(Arconix.pl().getApi().format().formatText("&7UltimateRepairing " + this.getDescription().getVersion() + " by &5Brianna <3!"));
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7..."));
Bukkit.getPluginManager().registerEvents(this, this);
@ -78,8 +80,6 @@ public final class RepairPlus extends JavaPlugin implements Listener {
this.commandManager = new CommandManager(this);
new ParticleHandler(this);
new com.massivestats.MassiveStats(this, 900);
getServer().getPluginManager().registerEvents(new PlayerListeners(this), this);
getServer().getPluginManager().registerEvents(new BlockListeners(this), this);
getServer().getPluginManager().registerEvents(new InteractListeners(this), this);
@ -89,7 +89,7 @@ public final class RepairPlus extends JavaPlugin implements Listener {
public void onDisable() {
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
console.sendMessage(Arconix.pl().getApi().format().formatText("&7RepairPlus " + this.getDescription().getVersion() + " by &5Brianna <3!"));
console.sendMessage(Arconix.pl().getApi().format().formatText("&7UltimateRepairing " + this.getDescription().getVersion() + " by &5Brianna <3!"));
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &cDisabling&7..."));
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
saveConfig();
@ -117,6 +117,21 @@ public final class RepairPlus extends JavaPlugin implements Listener {
}
}
public ServerVersion getServerVersion() {
return serverVersion;
}
public boolean isServerVersion(ServerVersion version) {
return serverVersion == version;
}
public boolean isServerVersion(ServerVersion... versions) {
return ArrayUtils.contains(versions, serverVersion);
}
public boolean isServerVersionAtLeast(ServerVersion version) {
return serverVersion.ordinal() >= version.ordinal();
}
public Locale getLocale() {
return locale;
@ -138,7 +153,7 @@ public final class RepairPlus extends JavaPlugin implements Listener {
return commandManager;
}
public static RepairPlus getInstance() {
public static UltimateRepairing getInstance() {
return INSTANCE;
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.repairplus.anvil;
package com.songoda.ultimaterepairing.anvil;
import org.bukkit.Location;
import org.bukkit.entity.Item;

View File

@ -1,6 +1,6 @@
package com.songoda.repairplus.command;
package com.songoda.ultimaterepairing.command;
import com.songoda.repairplus.RepairPlus;
import com.songoda.ultimaterepairing.UltimateRepairing;
import org.bukkit.command.CommandSender;
public abstract class AbstractCommand {
@ -31,7 +31,7 @@ public abstract class AbstractCommand {
return noConsole;
}
protected abstract ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args);
protected abstract ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args);
public abstract String getPermissionNode();

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.command;
package com.songoda.ultimaterepairing.command;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.commands.*;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.commands.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -14,24 +14,24 @@ import java.util.List;
public class CommandManager implements CommandExecutor {
private RepairPlus instance;
private UltimateRepairing instance;
private List<AbstractCommand> commands = new ArrayList<>();
public CommandManager(RepairPlus instance) {
public CommandManager(UltimateRepairing instance) {
this.instance = instance;
instance.getCommand("RepairPlus").setExecutor(this);
instance.getCommand("UltimateRepairing").setExecutor(this);
instance.getCommand("rpanvil").setExecutor(this);
AbstractCommand commandRepairPlus = addCommand(new CommandRepairPlus());
AbstractCommand commandUltimateRepairing = addCommand(new CommandUltimateRepairing());
addCommand(new CommandRPAnvil());
addCommand(new CommandReload(commandRepairPlus));
addCommand(new CommandSettings(commandRepairPlus));
addCommand(new CommandHolo(commandRepairPlus));
addCommand(new CommandParticles(commandRepairPlus));
addCommand(new CommandInf(commandRepairPlus));
addCommand(new CommandReload(commandUltimateRepairing));
addCommand(new CommandSettings(commandUltimateRepairing));
addCommand(new CommandHolo(commandUltimateRepairing));
addCommand(new CommandParticles(commandUltimateRepairing));
addCommand(new CommandInf(commandUltimateRepairing));
}
private AbstractCommand addCommand(AbstractCommand abstractCommand) {

View File

@ -1,9 +1,9 @@
package com.songoda.repairplus.command.commands;
package com.songoda.ultimaterepairing.command.commands;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.AbstractCommand;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.AbstractCommand;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
@ -16,7 +16,7 @@ public class CommandHolo extends AbstractCommand {
}
@Override
protected ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args) {
protected ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args) {
Player player = (Player) sender;
Block block = player.getTargetBlock(null, 200);
@ -40,7 +40,7 @@ public class CommandHolo extends AbstractCommand {
@Override
public String getPermissionNode() {
return "repairplus.admin";
return "ultimaterepairing.admin";
}
@Override

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.command.commands;
package com.songoda.ultimaterepairing.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.AbstractCommand;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.AbstractCommand;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
@ -15,7 +15,7 @@ public class CommandInf extends AbstractCommand {
}
@Override
protected ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args) {
protected ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args) {
Player player = (Player) sender;
Block b = player.getTargetBlock(null, 200);
@ -37,7 +37,7 @@ public class CommandInf extends AbstractCommand {
@Override
public String getPermissionNode() {
return "repairplus.admin";
return "ultimaterepairing.admin";
}
@Override

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.command.commands;
package com.songoda.ultimaterepairing.command.commands;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.AbstractCommand;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.AbstractCommand;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
@ -15,7 +15,7 @@ public class CommandParticles extends AbstractCommand {
}
@Override
protected ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args) {
protected ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args) {
Player player = (Player) sender;
Block block = player.getTargetBlock(null, 200);
@ -37,7 +37,7 @@ public class CommandParticles extends AbstractCommand {
@Override
public String getPermissionNode() {
return "repairplus.admin";
return "ultimaterepairing.admin";
}
@Override

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.command.commands;
package com.songoda.ultimaterepairing.command.commands;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.AbstractCommand;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.AbstractCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ public class CommandRPAnvil extends AbstractCommand {
}
@Override
protected ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args) {
protected ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args) {
Player player = (Player) sender;
instance.getRepairHandler().initRepair(player, player.getLocation());
return ReturnType.SUCCESS;
@ -21,7 +21,7 @@ public class CommandRPAnvil extends AbstractCommand {
@Override
public String getPermissionNode() {
return "repairplus.rpanvil";
return "ultimaterepairing.rpanvil";
}
@Override

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.command.commands;
package com.songoda.ultimaterepairing.command.commands;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.AbstractCommand;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.AbstractCommand;
import org.bukkit.command.CommandSender;
public class CommandReload extends AbstractCommand {
@ -12,7 +12,7 @@ public class CommandReload extends AbstractCommand {
}
@Override
protected ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args) {
protected ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args) {
instance.reload();
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Configuration and Language files reloaded."));
return ReturnType.SUCCESS;
@ -20,7 +20,7 @@ public class CommandReload extends AbstractCommand {
@Override
public String getPermissionNode() {
return "repairplus.admin";
return "ultimaterepairing.admin";
}
@Override

View File

@ -1,7 +1,7 @@
package com.songoda.repairplus.command.commands;
package com.songoda.ultimaterepairing.command.commands;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.AbstractCommand;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.AbstractCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -12,7 +12,7 @@ public class CommandSettings extends AbstractCommand {
}
@Override
protected ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args) {
protected ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args) {
Player p = (Player) sender;
instance.getSettingsManager().openSettingsManager(p);
return ReturnType.SUCCESS;
@ -20,7 +20,7 @@ public class CommandSettings extends AbstractCommand {
@Override
public String getPermissionNode() {
return "repairplus.admin";
return "ultimaterepairing.admin";
}
@Override
@ -30,6 +30,6 @@ public class CommandSettings extends AbstractCommand {
@Override
public String getDescription() {
return "Edit the RepairPlus Settings.";
return "Edit the UltimateRepairing Settings.";
}
}

View File

@ -1,18 +1,18 @@
package com.songoda.repairplus.command.commands;
package com.songoda.ultimaterepairing.command.commands;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.command.AbstractCommand;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.command.AbstractCommand;
import org.bukkit.command.CommandSender;
public class CommandRepairPlus extends AbstractCommand {
public class CommandUltimateRepairing extends AbstractCommand {
public CommandRepairPlus() {
super("RepairPlus", null, false);
public CommandUltimateRepairing() {
super("UltimateRepairing", null, false);
}
@Override
protected ReturnType runCommand(RepairPlus instance, CommandSender sender, String... args) {
protected ReturnType runCommand(UltimateRepairing instance, CommandSender sender, String... args) {
sender.sendMessage("");
sender.sendMessage(TextComponent.formatText(instance.references.getPrefix() + "&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oBrianna"));
@ -33,7 +33,7 @@ public class CommandRepairPlus extends AbstractCommand {
@Override
public String getSyntax() {
return "/RepairPlus";
return "/UltimateRepairing";
}
@Override

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.events;
package com.songoda.ultimaterepairing.events;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.utils.Debugger;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -15,16 +15,16 @@ import org.bukkit.event.block.BlockPlaceEvent;
*/
public class BlockListeners implements Listener {
private final RepairPlus instance;
private final UltimateRepairing instance;
public BlockListeners(RepairPlus instance) {
public BlockListeners(UltimateRepairing instance) {
this.instance = instance;
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
try {
if (!e.getPlayer().hasPermission("repairplus.permPlace") || !e.getBlockPlaced().getType().equals(Material.ANVIL)) {
if (!e.getPlayer().hasPermission("ultimaterepairing.permPlace") || !e.getBlockPlaced().getType().equals(Material.ANVIL)) {
return;
}

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.events;
package com.songoda.ultimaterepairing.events;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.utils.Debugger;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -19,9 +19,9 @@ import org.bukkit.inventory.Inventory;
public class InteractListeners implements Listener {
private final RepairPlus instance;
private final UltimateRepairing instance;
public InteractListeners(RepairPlus instance) {
public InteractListeners(UltimateRepairing instance) {
this.instance = instance;
}
@ -37,7 +37,7 @@ public class InteractListeners implements Listener {
String loc = Arconix.pl().getApi().serialize().serializeLocation(e.getClickedBlock());
if (e.getClickedBlock().getType() != Material.ANVIL
|| !((instance.getConfig().getBoolean("data.anvil." + loc + ".permPlaced")
|| !instance.getConfig().getBoolean("Main.Require Permission On RepairPlus Anvil Place")))) {
|| !instance.getConfig().getBoolean("Main.Require Permission On UltimateRepairing Anvil Place")))) {
return;
}
if (instance.getConfig().getString("data.anvil." + loc + ".inf") != null) {

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.events;
package com.songoda.ultimaterepairing.events;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.anvil.PlayerAnvilData.RepairType;
import com.songoda.repairplus.utils.Debugger;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.PlayerAnvilData.RepairType;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -15,15 +15,15 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent;
*/
public class InventoryListeners implements Listener {
private final RepairPlus instance;
private final UltimateRepairing instance;
public InventoryListeners(RepairPlus instance) {
public InventoryListeners(UltimateRepairing instance) {
this.instance = instance;
}
@EventHandler
public void OnPickup(InventoryPickupItemEvent event) {
if (event.getItem().hasMetadata("RepairPlus"))
if (event.getItem().hasMetadata("UltimateRepairing"))
event.setCancelled(true);
}
@ -46,15 +46,15 @@ public class InventoryListeners implements Listener {
Location loc = instance.getRepairHandler().getDataFor(p).getLocation();
if (event.getSlot() == 11) {
p.closeInventory();
if (p.hasPermission("repairplus.use.ECO"))
if (p.hasPermission("ultimaterepairing.use.ECO"))
instance.getRepairHandler().preRepair(p, RepairType.ECONOMY, loc);
} else if (event.getSlot() == 13) {
p.closeInventory();
if (p.hasPermission("repairplus.use.ITEM"))
if (p.hasPermission("ultimaterepairing.use.ITEM"))
instance.getRepairHandler().preRepair(p, RepairType.ITEM, loc);
} else if (event.getSlot() == 15) {
p.closeInventory();
if (p.hasPermission("repairplus.use.XP"))
if (p.hasPermission("ultimaterepairing.use.XP"))
instance.getRepairHandler().preRepair(p, RepairType.XP, loc);
}
}

View File

@ -1,7 +1,7 @@
package com.songoda.repairplus.events;
package com.songoda.ultimaterepairing.events;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.anvil.PlayerAnvilData;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.PlayerAnvilData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
@ -9,9 +9,9 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListeners implements Listener {
private final RepairPlus instance;
private final UltimateRepairing instance;
public PlayerListeners(RepairPlus instance) {
public PlayerListeners(UltimateRepairing instance) {
this.instance = instance;
}

View File

@ -1,9 +1,9 @@
package com.songoda.repairplus.handlers;
package com.songoda.ultimaterepairing.handlers;
import com.songoda.arconix.api.packets.Hologram;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.utils.Debugger;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -17,9 +17,9 @@ import java.util.List;
*/
public class HologramHandler {
private final RepairPlus instance;
private final UltimateRepairing instance;
public HologramHandler(RepairPlus plugin) {
public HologramHandler(UltimateRepairing plugin) {
this.instance = plugin;
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::updateHolograms, 0L, 5000L);
}

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.handlers;
package com.songoda.ultimaterepairing.handlers;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.utils.Debugger;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.utils.Debugger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -14,9 +14,9 @@ import org.bukkit.event.Listener;
*/
public class ParticleHandler implements Listener {
private RepairPlus instance;
private UltimateRepairing instance;
public ParticleHandler(RepairPlus instance) {
public ParticleHandler(UltimateRepairing instance) {
this.instance = instance;
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(instance, this::applyParticles, 0L, 10L);
}

View File

@ -1,6 +1,6 @@
package com.songoda.repairplus.utils;
package com.songoda.ultimaterepairing.utils;
import com.songoda.repairplus.RepairPlus;
import com.songoda.ultimaterepairing.UltimateRepairing;
/**
* Created by songoda on 3/21/2017.
@ -11,7 +11,7 @@ public class Debugger {
public static void runReport(Exception e) {
if (isDebug()) {
System.out.println("==============================================================");
System.out.println("The following is an error encountered in RepairPlus.");
System.out.println("The following is an error encountered in UltimateRepairing.");
System.out.println("--------------------------------------------------------------");
e.printStackTrace();
System.out.println("==============================================================");
@ -24,7 +24,7 @@ public class Debugger {
}
public static boolean isDebug() {
return RepairPlus.getInstance().getConfig().getBoolean("System.Debugger Enabled");
return UltimateRepairing.getInstance().getConfig().getBoolean("System.Debugger Enabled");
}
}

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.utils;
package com.songoda.ultimaterepairing.utils;
import com.songoda.arconix.plugin.Arconix;
import com.songoda.repairplus.RepairPlus;
import com.songoda.repairplus.anvil.PlayerAnvilData.RepairType;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.PlayerAnvilData.RepairType;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -17,7 +17,7 @@ public class Methods {
public static ItemStack getGlass() {
try {
return Arconix.pl().getApi().getGUI().getGlass(RepairPlus.getInstance().getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), RepairPlus.getInstance().getConfig().getInt("Interfaces.Glass Type 1"));
return Arconix.pl().getApi().getGUI().getGlass(UltimateRepairing.getInstance().getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), UltimateRepairing.getInstance().getConfig().getInt("Interfaces.Glass Type 1"));
} catch (Exception e) {
Debugger.runReport(e);
}
@ -27,9 +27,9 @@ public class Methods {
public static ItemStack getBackgroundGlass(boolean type) {
try {
if (type)
return Arconix.pl().getApi().getGUI().getGlass(false, RepairPlus.getInstance().getConfig().getInt("Interfaces.Glass Type 2"));
return Arconix.pl().getApi().getGUI().getGlass(false, UltimateRepairing.getInstance().getConfig().getInt("Interfaces.Glass Type 2"));
else
return Arconix.pl().getApi().getGUI().getGlass(false, RepairPlus.getInstance().getConfig().getInt("Interfaces.Glass Type 3"));
return Arconix.pl().getApi().getGUI().getGlass(false, UltimateRepairing.getInstance().getConfig().getInt("Interfaces.Glass Type 3"));
} catch (Exception e) {
Debugger.runReport(e);
}
@ -42,9 +42,9 @@ public class Methods {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String equationXP = RepairPlus.getInstance().getConfig().getString("Main.Experience Cost Equation");
String equationECO = RepairPlus.getInstance().getConfig().getString("Main.Economy Cost Equation");
String equationITEM = RepairPlus.getInstance().getConfig().getString("Main.Item Cost Equation");
String equationXP = UltimateRepairing.getInstance().getConfig().getString("Main.Experience Cost Equation");
String equationECO = UltimateRepairing.getInstance().getConfig().getString("Main.Economy Cost Equation");
String equationITEM = UltimateRepairing.getInstance().getConfig().getString("Main.Item Cost Equation");
equationXP = equationXP.replace("{MaxDurability}", Short.toString(item.getType().getMaxDurability()))
.replace("{Durability}", Short.toString(item.getDurability()));
@ -64,7 +64,7 @@ public class Methods {
if (item.hasItemMeta() &&
item.getItemMeta().hasEnchants()) {
int multi = RepairPlus.getInstance().getConfig().getInt("Main.Cost Multiplier For Enchanted Items");
int multi = UltimateRepairing.getInstance().getConfig().getInt("Main.Cost Multiplier For Enchanted Items");
XPCost = XPCost * multi;
ECOCost = ECOCost * multi;
ITEMCost = ITEMCost * multi;
@ -83,7 +83,7 @@ public class Methods {
}
public static Material getType(ItemStack item) {
if (RepairPlus.getInstance().getConfig().getBoolean("Main.Repair Items Only With Items Of That Items Type")) {
if (UltimateRepairing.getInstance().getConfig().getBoolean("Main.Repair Items Only With Items Of That Items Type")) {
if (item.getType().name().contains("DIAMOND"))
return Material.DIAMOND;
if (item.getType().name().contains("IRON"))
@ -97,6 +97,6 @@ public class Methods {
if (item.getType().name().contains("WOOD"))
return Material.OAK_WOOD;
}
return Material.valueOf(RepairPlus.getInstance().getConfig().getString("Interfaces.Item Icon"));
return Material.valueOf(UltimateRepairing.getInstance().getConfig().getString("Interfaces.Item Icon"));
}
}

View File

@ -1,8 +1,8 @@
package com.songoda.repairplus.utils;
package com.songoda.ultimaterepairing.utils;
import com.songoda.arconix.api.methods.formatting.TextComponent;
import com.songoda.arconix.api.utils.ConfigWrapper;
import com.songoda.repairplus.RepairPlus;
import com.songoda.ultimaterepairing.UltimateRepairing;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -25,7 +25,7 @@ import java.util.regex.Pattern;
*/
public class SettingsManager implements Listener {
private String pluginName = "RepairPlus";
private String pluginName = "UltimateRepairing";
private static final Pattern SETTINGS_PATTERN = Pattern.compile("(.{1,28}(?:\\s|$))|(.{0,28})", Pattern.DOTALL);
@ -33,9 +33,9 @@ public class SettingsManager implements Listener {
private Map<Player, String> cat = new HashMap<>();
private final RepairPlus instance;
private final UltimateRepairing instance;
public SettingsManager(RepairPlus plugin) {
public SettingsManager(UltimateRepairing plugin) {
this.instance = plugin;
plugin.saveResource("SettingDefinitions.yml", true);
@ -223,7 +223,7 @@ public class SettingsManager implements Listener {
o18("Swap-Functions", "Main.Swap Right And Left Click Options", false),
o19("Perms-Only", "Main.Require Permission On RepairPlus Anvil Place", false),
o19("Perms-Only", "Main.Require Permission On UltimateRepairing Anvil Place", false),
o20("-", "Main.Particle Amount", 25),

View File

@ -9,7 +9,7 @@ ITEM: 'This is the default icon that will be used for the Item repair button.'
Glass-Type: 'This is the id of the glass used for the background in the guis .'
Rainbow-Glass: 'If this is enabled the glass background will be randomized colors. '
Item-Match-Type: 'Setting this to true will force the user to repair an item with the material used to create that item.'
Enable-Default-Anvil-Function: 'Setting this to false will disable default Minecraft anvils leaving only the RepairPlus features.'
Swap-Functions: 'Setting this to true will swap the RepairPlus function a right-click and the default Minecraft function a left-click.'
Perms-Only: 'Setting this to true will require the permission ''RepairPlus.permPlace'' to place a RepairPlus Anvil.'
Enable-Default-Anvil-Function: 'Setting this to false will disable default Minecraft anvils leaving only the UltimateRepairing features.'
Swap-Functions: 'Setting this to true will swap the UltimateRepairing function a right-click and the default Minecraft function a left-click.'
Perms-Only: 'Setting this to true will require the permission ''UltimateRepairing.permPlace'' to place a UltimateRepairing Anvil.'
Debug-Mode: 'Setting this to true will show any and all errors the plugin may be having in your server console.'

View File

@ -1,6 +1,6 @@
#General Messages
general.nametag.prefix = "&8[&6RepairPlus&8]"
general.nametag.prefix = "&8[&6UltimateRepairing&8]"
general.hologram.click = "Left-Click with an item"
general.hologram.swapclick = "Right-Click with an item"
general.hologram.oneclick = "Click with an item"

View File

@ -1,17 +1,17 @@
name: RepairPlus
description: RepairPlus
main: com.songoda.repairplus.RepairPlus
name: UltimateRepairing
description: UltimateRepairing
main: com.songoda.ultimaterepairing.UltimateRepairing
depend: [Arconix]
softdepend: [Vault]
version: 1.4.1
version: 1
author: Songoda
api-version: 1.13
commands:
repairplus:
ultimaterepairing:
description: View information on this plugin.
default: true
aliases: [rp]
usage: /RP
aliases: [ur]
usage: /ur
rpanvil:
description: View information on this plugin.
default: true