mirror of
https://github.com/songoda/UltimateKits.git
synced 2025-02-16 19:31:25 +01:00
Merge branch 'development' into 'master'
Development See merge request Songoda/ultimatekits!28
This commit is contained in:
commit
d9c10f0a17
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "UltimateKits"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.2.9"
|
||||
version: "2.3"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
39
pom.xml
39
pom.xml
@ -38,6 +38,39 @@
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:songodaupdater</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@ -50,12 +83,12 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.13.2</version>
|
||||
<version>1.14-pre5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>arconix</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<artifactId>songodaupdater</artifactId>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org</groupId>
|
||||
|
@ -2,15 +2,18 @@ package com.songoda.ultimatekits;
|
||||
|
||||
import com.songoda.ultimatekits.command.CommandManager;
|
||||
import com.songoda.ultimatekits.conversion.Convert;
|
||||
import com.songoda.ultimatekits.hologram.HologramHolographicDisplays;
|
||||
import com.songoda.ultimatekits.listeners.*;
|
||||
import com.songoda.ultimatekits.handlers.DisplayItemHandler;
|
||||
import com.songoda.ultimatekits.handlers.ParticleHandler;
|
||||
import com.songoda.ultimatekits.hologram.Hologram;
|
||||
import com.songoda.ultimatekits.hologram.HologramArconix;
|
||||
import com.songoda.ultimatekits.key.Key;
|
||||
import com.songoda.ultimatekits.key.KeyManager;
|
||||
import com.songoda.ultimatekits.kit.*;
|
||||
import com.songoda.ultimatekits.utils.*;
|
||||
import com.songoda.ultimatekits.utils.updateModules.LocaleModule;
|
||||
import com.songoda.update.Plugin;
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -112,9 +115,10 @@ public class UltimateKits extends JavaPlugin {
|
||||
Locale.saveDefaultLocale("en_US");
|
||||
this.locale = Locale.getLocale(getConfig().getString("System.Language Mode", langMode));
|
||||
|
||||
if (getConfig().getBoolean("System.Download Needed Data Files")) {
|
||||
this.update();
|
||||
}
|
||||
//Running Songoda Updater
|
||||
Plugin plugin = new Plugin(this, 14);
|
||||
plugin.addModule(new LocaleModule());
|
||||
SongodaUpdate.load(plugin);
|
||||
|
||||
this.references = new References();
|
||||
|
||||
@ -125,8 +129,8 @@ public class UltimateKits extends JavaPlugin {
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
|
||||
// Register Hologram Plugin
|
||||
if (pluginManager.isPluginEnabled("Arconix"))
|
||||
hologram = new HologramArconix(this);
|
||||
if (pluginManager.isPluginEnabled("HolographicDisplays"))
|
||||
hologram = new HologramHolographicDisplays(this);
|
||||
|
||||
// Event registration
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
@ -157,39 +161,6 @@ public class UltimateKits extends JavaPlugin {
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
}
|
||||
|
||||
private void update() {
|
||||
try {
|
||||
URL url = new URL("http://update.songoda.com/index.php?plugin=" + getDescription().getName() + "&version=" + getDescription().getVersion());
|
||||
URLConnection urlConnection = url.openConnection();
|
||||
InputStream is = urlConnection.getInputStream();
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
|
||||
int numCharsRead;
|
||||
char[] charArray = new char[1024];
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while ((numCharsRead = isr.read(charArray)) > 0) {
|
||||
sb.append(charArray, 0, numCharsRead);
|
||||
}
|
||||
String jsonString = sb.toString();
|
||||
JSONObject json = (JSONObject) new JSONParser().parse(jsonString);
|
||||
|
||||
JSONArray files = (JSONArray) json.get("neededFiles");
|
||||
for (Object o : files) {
|
||||
JSONObject file = (JSONObject) o;
|
||||
|
||||
switch ((String) file.get("type")) {
|
||||
case "locale":
|
||||
InputStream in = new URL((String) file.get("link")).openStream();
|
||||
Locale.saveDefaultLocale(in, (String) file.get("name"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to update.");
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load configuration files into memory.
|
||||
*/
|
||||
|
@ -24,7 +24,9 @@ public class CommandRemove extends AbstractCommand {
|
||||
Block block = player.getTargetBlock(null, 200);
|
||||
Kit kit = instance.getKitManager().removeKitFromLocation(block.getLocation());
|
||||
if (kit == null) return ReturnType.FAILURE;
|
||||
instance.getHologram().remove(kit);
|
||||
|
||||
if (instance.getHologram() != null)
|
||||
instance.getHologram().remove(kit);
|
||||
player.sendMessage(Methods.formatText(UltimateKits.getInstance().getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType().toString() + "&8."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -82,11 +82,15 @@ public class GUIBlockEditor extends AbstractGUI {
|
||||
registerClickable(11, (player, inventory, cursor, slot, type) -> {
|
||||
UltimateKits instance = UltimateKits.getInstance();
|
||||
|
||||
if (instance.getHologram() != null)
|
||||
instance.getHologram().remove(kitBlockData);
|
||||
|
||||
if (kitBlockData.getType() == KitType.PREVIEW) kitBlockData.setType(KitType.CRATE);
|
||||
else if (kitBlockData.getType() == KitType.CRATE) kitBlockData.setType(KitType.CLAIM);
|
||||
else if (kitBlockData.getType() == KitType.CLAIM) kitBlockData.setType(KitType.PREVIEW);
|
||||
|
||||
instance.saveConfig();
|
||||
if (instance.getHologram() != null)
|
||||
instance.getHologram().update(kitBlockData);
|
||||
constructGUI();
|
||||
});
|
||||
|
@ -14,10 +14,13 @@ import java.util.ArrayList;
|
||||
|
||||
public class GUIDecorOptions extends AbstractGUI {
|
||||
|
||||
private UltimateKits plugin;
|
||||
|
||||
private KitBlockData kitBlockData;
|
||||
|
||||
public GUIDecorOptions(UltimateKits plugin, Player player, Location location) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
kitBlockData = plugin.getKitManager().getKit(location);
|
||||
init("&8Editing decor for &a" + kitBlockData.getKit().getShowableName() + "&8.", 27);
|
||||
}
|
||||
@ -61,7 +64,7 @@ public class GUIDecorOptions extends AbstractGUI {
|
||||
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
|
||||
}
|
||||
|
||||
createButton(10, Material.SIGN, "&9&lToggle Holograms", lore);
|
||||
createButton(10, Material.NAME_TAG, "&9&lToggle Holograms", lore);
|
||||
|
||||
lore = new ArrayList<>();
|
||||
if (kitBlockData.hasParticles()) {
|
||||
@ -108,6 +111,8 @@ public class GUIDecorOptions extends AbstractGUI {
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
registerClickable(10, (player, inventory, cursor, slot, type) -> {
|
||||
if (plugin.getHologram() == null) return;
|
||||
|
||||
if (kitBlockData.showHologram()) {
|
||||
kitBlockData.setShowHologram(false);
|
||||
} else {
|
||||
@ -127,7 +132,7 @@ public class GUIDecorOptions extends AbstractGUI {
|
||||
});
|
||||
|
||||
registerClickable(14, (player, inventory, cursor, slot, type) -> {
|
||||
boolean isHolo = kitBlockData.showHologram();
|
||||
boolean isHolo = plugin.getHologram() != null && kitBlockData.showHologram();
|
||||
|
||||
if (isHolo) {
|
||||
UltimateKits.getInstance().getHologram().remove(kitBlockData);
|
||||
|
@ -155,7 +155,6 @@ public class GUIDisplayKit extends AbstractGUI {
|
||||
if (num == 17 || num == (max - 18)) num++;
|
||||
if (num == 18 && max == 36) num++;
|
||||
}
|
||||
System.out.println("hit " + num);
|
||||
|
||||
ItemMeta meta = is.hasItemMeta() ? is.getItemMeta() : Bukkit.getItemFactory().getItemMeta(is.getType());
|
||||
ArrayDeque<String> lore;
|
||||
@ -213,7 +212,7 @@ public class GUIDisplayKit extends AbstractGUI {
|
||||
protected void registerClickables() {
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> {
|
||||
if (back == null) return;
|
||||
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
|
||||
back.init(back.getSetTitle(), back.getInventory().getSize());
|
||||
});
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
@ -110,7 +110,7 @@ public class GUIGUIOptions extends AbstractGUI {
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getInventory().getTitle(), back.getInventory().getSize()));
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
@ -121,10 +121,11 @@ public class GUIGUIOptions extends AbstractGUI {
|
||||
kit.setTitle(msg);
|
||||
plugin.saveConfig();
|
||||
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8Title &5" + msg + "&8 added to Kit &a" + kit.getShowableName() + "&8."));
|
||||
plugin.getHologram().update(kit);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
@ -135,7 +136,8 @@ public class GUIGUIOptions extends AbstractGUI {
|
||||
gui.open();
|
||||
} else {
|
||||
kit.setTitle("");
|
||||
plugin.getHologram().update(kit);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
|
@ -77,7 +77,7 @@ public class GUIGeneralOptions extends AbstractGUI {
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getInventory().getTitle(), back.getInventory().getSize()));
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
@ -88,7 +88,8 @@ public class GUIGeneralOptions extends AbstractGUI {
|
||||
|
||||
if (msg.trim().equalsIgnoreCase(kit.getName())) {
|
||||
plugin.getKitManager().removeKit(kit);
|
||||
plugin.getHologram().update(kit);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&cKit destroyed successfully."));
|
||||
} else {
|
||||
player.sendMessage(plugin.getReferences().getPrefix() + Methods.formatText("&cKit was not Destroyed."));
|
||||
@ -97,7 +98,7 @@ public class GUIGeneralOptions extends AbstractGUI {
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> {
|
||||
if (plugin.getKitManager().getKit(name) != null) {
|
||||
init(inventory.getTitle(), inventory.getSize());
|
||||
init(setTitle, inventory.getSize());
|
||||
}
|
||||
});
|
||||
|
||||
@ -123,7 +124,7 @@ public class GUIGeneralOptions extends AbstractGUI {
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
@ -498,7 +498,7 @@ public class GUIKitEditor extends AbstractGUI {
|
||||
|
||||
registerClickable(0, ((player, inventory, cursor, slot, type) -> {
|
||||
if (back == null) return;
|
||||
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
|
||||
back.init(back.getSetTitle(), back.getInventory().getSize());
|
||||
}));
|
||||
|
||||
registerClickable(48, ((player1, inventory, cursor, slot1, type) -> {
|
||||
|
@ -106,7 +106,7 @@ public class GUISellingOptions extends AbstractGUI {
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getInventory().getTitle(), back.getInventory().getSize()));
|
||||
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
|
||||
|
||||
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
|
||||
|
||||
@ -126,11 +126,12 @@ public class GUISellingOptions extends AbstractGUI {
|
||||
}
|
||||
Double eco = Double.parseDouble(msg);
|
||||
kit.setPrice(eco);
|
||||
plugin.getHologram().update(kit);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
}
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.SUNFLOWER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
@ -150,10 +151,11 @@ public class GUISellingOptions extends AbstractGUI {
|
||||
player.sendMessage(Methods.formatText(plugin.getReferences().getPrefix() + "&8ECO has been removed from this kit. Note you cannot have ECO & LINK set at the same time.."));
|
||||
}
|
||||
kit.setLink(msg);
|
||||
plugin.getHologram().update(kit);
|
||||
if (plugin.getHologram() != null)
|
||||
plugin.getHologram().update(kit);
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
@ -55,10 +55,9 @@ public class DisplayItemHandler {
|
||||
continue;
|
||||
}
|
||||
Item i = (Item) e;
|
||||
if (i.getItemStack().getItemMeta().getDisplayName() == null) {
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!kitBlockData.isDisplayingItems()) e.remove();
|
||||
|
||||
int inum = Integer.parseInt(i.getItemStack().getItemMeta().getDisplayName().replace(String.valueOf(ChatColor.COLOR_CHAR), "")) + 1;
|
||||
if (inum > list.size()) inum = 1;
|
||||
|
||||
|
@ -127,7 +127,7 @@ public abstract class Hologram {
|
||||
|
||||
if (b.getType() == Material.TRAPPED_CHEST
|
||||
|| b.getType() == Material.CHEST
|
||||
|| b.getType() == Material.SIGN
|
||||
|| b.getType().name().contains("SIGN")
|
||||
|| b.getType() == Material.ENDER_CHEST) multi -= .15;
|
||||
|
||||
location.add(0, multi, 0);
|
||||
|
@ -1,47 +0,0 @@
|
||||
package com.songoda.ultimatekits.hologram;
|
||||
|
||||
import com.songoda.arconix.api.hologram.HologramObject;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HologramArconix extends Hologram {
|
||||
|
||||
private com.songoda.arconix.api.packets.Hologram hologramManager;
|
||||
|
||||
public HologramArconix(UltimateKits instance) {
|
||||
super(instance);
|
||||
this.hologramManager = Arconix.pl().getApi().packetLibrary.getHologramManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Location location, ArrayList<String> lines) {
|
||||
fixLocation(location);
|
||||
HologramObject hologram = new HologramObject(null, location, lines);
|
||||
hologramManager.addHologram(hologram);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Location location) {
|
||||
fixLocation(location);
|
||||
location.add(0, 0.25, 0);
|
||||
hologramManager.removeHologram(location, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Location location, ArrayList<String> lines) {
|
||||
remove(location.clone());
|
||||
fixLocation(location);
|
||||
HologramObject hologram = new HologramObject(null, location, lines);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(), () -> {
|
||||
hologramManager.addHologram(hologram);
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
private void fixLocation(Location location) {
|
||||
location.add(0.5, 0.75, 0.5);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.songoda.ultimatekits.hologram;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HologramHolographicDisplays extends Hologram {
|
||||
|
||||
|
||||
public HologramHolographicDisplays(UltimateKits instance) {
|
||||
super(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Location location, ArrayList<String> lines) {
|
||||
fixLocation(location);
|
||||
|
||||
com.gmail.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(instance, location);
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Location location) {
|
||||
fixLocation(location);
|
||||
for (com.gmail.filoghost.holographicdisplays.api.Hologram hologram : HologramsAPI.getHolograms(instance)) {
|
||||
if (hologram.getX() != location.getX()
|
||||
|| hologram.getY() != location.getY()
|
||||
|| hologram.getZ() != location.getZ()) continue;
|
||||
hologram.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Location location, ArrayList<String> lines) {
|
||||
for (com.gmail.filoghost.holographicdisplays.api.Hologram hologram : HologramsAPI.getHolograms(instance)) {
|
||||
if (hologram.getX() != location.getX()
|
||||
|| hologram.getY() != location.getY()
|
||||
|| hologram.getZ() != location.getZ()) continue;
|
||||
fixLocation(location);
|
||||
hologram.clearLines();
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
return;
|
||||
}
|
||||
add(location, lines);
|
||||
}
|
||||
|
||||
private void fixLocation(Location location) {
|
||||
location.add(.5, 1.3, .5);
|
||||
}
|
||||
}
|
@ -31,7 +31,9 @@ public class KitBlockData {
|
||||
setDisplayingItems(false);
|
||||
setHasParticles(false);
|
||||
UltimateKits.getInstance().getDisplayItemHandler().displayItem(this);
|
||||
UltimateKits.getInstance().getHologram().remove(this);
|
||||
|
||||
if (UltimateKits.getInstance().getHologram() != null)
|
||||
UltimateKits.getInstance().getHologram().remove(this);
|
||||
}
|
||||
|
||||
public Kit getKit() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.ultimatekits.kit;
|
||||
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.*;
|
||||
@ -33,7 +34,9 @@ public final class KitManager {
|
||||
}
|
||||
|
||||
public void addKitToLocation(Kit kit, Location location, KitType type, boolean hologram, boolean particles, boolean items, boolean itemOverride) {
|
||||
kitsAtLocations.put(roundLocation(location), new KitBlockData(kit, location, type, hologram, particles, items, itemOverride));
|
||||
KitBlockData kitBlockData = kitsAtLocations.put(roundLocation(location), new KitBlockData(kit, location, type, hologram, particles, items, itemOverride));
|
||||
if (UltimateKits.getInstance().getHologram() != null)
|
||||
UltimateKits.getInstance().getHologram().update(kitBlockData);
|
||||
}
|
||||
|
||||
public Kit removeKitFromLocation(Location location) {
|
||||
|
@ -30,8 +30,12 @@ public class BlockListeners implements Listener {
|
||||
KitBlockData kitBlockData = instance.getKitManager().getKit(block.getLocation());
|
||||
if (kitBlockData == null) return;
|
||||
Kit kit = kitBlockData.getKit();
|
||||
|
||||
if (instance.getHologram() != null)
|
||||
instance.getHologram().remove(kitBlockData);
|
||||
|
||||
instance.getKitManager().removeKitFromLocation(block.getLocation());
|
||||
instance.getHologram().remove(kitBlockData);
|
||||
|
||||
event.getPlayer().sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType() + "&8."));
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -1,34 +1,22 @@
|
||||
package com.songoda.ultimatekits.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/24/2017.
|
||||
@ -268,7 +256,7 @@ public class Methods {
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", new Object[]{headURL}).getBytes());
|
||||
byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", new Object[]{headURL}).getBytes());
|
||||
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
|
||||
|
||||
Field profileField;
|
||||
|
@ -46,7 +46,7 @@ public class SettingsManager implements Listener {
|
||||
|| e.getWhoClicked().getOpenInventory().getTopInventory() != e.getInventory()) {
|
||||
return;
|
||||
}
|
||||
if (e.getInventory().getTitle().equals(pluginName + " Settings Manager")) {
|
||||
if (e.getView().getTitle().equals(pluginName + " Settings Manager")) {
|
||||
|
||||
if (e.getCurrentItem().getType().name().contains("STAINED_GLASS")) {
|
||||
e.setCancelled(true);
|
||||
@ -57,7 +57,7 @@ public class SettingsManager implements Listener {
|
||||
cat.put((Player) e.getWhoClicked(), type);
|
||||
openEditor((Player) e.getWhoClicked());
|
||||
e.setCancelled(true);
|
||||
} else if (e.getInventory().getTitle().equals(pluginName + " Settings KitEditor")) {
|
||||
} else if (e.getView().getTitle().equals(pluginName + " Settings KitEditor")) {
|
||||
|
||||
if (e.getCurrentItem().getType().name().contains("STAINED_GLASS")) {
|
||||
e.setCancelled(true);
|
||||
@ -99,7 +99,10 @@ public class SettingsManager implements Listener {
|
||||
instance.getConfig().set(current.get(p), e.getMessage());
|
||||
break;
|
||||
}
|
||||
finishEditing(p);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(), () ->
|
||||
this.finishEditing(p), 0L);
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
}
|
||||
@ -231,7 +234,6 @@ public class SettingsManager implements Listener {
|
||||
o14("Rainbow-Glass", "Interfaces.Replace Glass Type 1 With Rainbow Glass", false),
|
||||
o15("glassless", "Interfaces.Do Not Use Glass Borders", false),
|
||||
|
||||
DOWNLOAD_FILES("-", "System.Download Needed Data Files", true),
|
||||
LANGUGE_MODE("-", "System.Language Mode", "en_US"),
|
||||
o16("Debug-Mode", "System.Debugger Enabled", false);
|
||||
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -23,15 +24,20 @@ import java.util.Map;
|
||||
|
||||
public class AbstractAnvilGUI {
|
||||
|
||||
private static Class<?> BlockPosition;
|
||||
private static Class<?> PacketPlayOutOpenWindow;
|
||||
private static Class<?> ContainerAnvil;
|
||||
private static Class<?> ChatMessage;
|
||||
private static Class<?> EntityHuman;
|
||||
private static boolean loadedClasses = false;
|
||||
private static Class<?> BlockPositionClass;
|
||||
private static Class<?> PacketPlayOutOpenWindowClass;
|
||||
private static Class<?> IChatBaseComponentClass;
|
||||
private static Class<?> ICraftingClass;
|
||||
private static Class<?> ContainerAnvilClass;
|
||||
private static Class<?> ChatMessageClass;
|
||||
private static Class<?> EntityHumanClass;
|
||||
private static Class<?> ContainerClass;
|
||||
private static Class<?> ContainerAccessClass;
|
||||
private static Class<?> WorldClass;
|
||||
private static Class<?> PlayerInventoryClass;
|
||||
private static Class<?> ContainersClass;
|
||||
|
||||
private Player player;
|
||||
@SuppressWarnings("unused")
|
||||
private AnvilClickEventHandler handler;
|
||||
private Map<AnvilSlot, ItemStack> items = new HashMap<>();
|
||||
private OnClose onClose = null;
|
||||
private Inventory inv;
|
||||
@ -39,81 +45,93 @@ public class AbstractAnvilGUI {
|
||||
|
||||
private Sound closeSound = Sound.ENTITY_PLAYER_LEVELUP;
|
||||
|
||||
static {
|
||||
BlockPositionClass = NMSUtil.getNMSClass("BlockPosition");
|
||||
PacketPlayOutOpenWindowClass = NMSUtil.getNMSClass("PacketPlayOutOpenWindow");
|
||||
IChatBaseComponentClass = NMSUtil.getNMSClass("IChatBaseComponent");
|
||||
ICraftingClass = NMSUtil.getNMSClass("ICrafting");
|
||||
ContainerAnvilClass = NMSUtil.getNMSClass("ContainerAnvil");
|
||||
EntityHumanClass = NMSUtil.getNMSClass("EntityHuman");
|
||||
ChatMessageClass = NMSUtil.getNMSClass("ChatMessage");
|
||||
ContainerClass = NMSUtil.getNMSClass("Container");
|
||||
WorldClass = NMSUtil.getNMSClass("World");
|
||||
PlayerInventoryClass = NMSUtil.getNMSClass("PlayerInventory");
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerAccessClass = NMSUtil.getNMSClass("ContainerAccess");
|
||||
ContainersClass = NMSUtil.getNMSClass("Containers");
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractAnvilGUI(final Player player, final AnvilClickEventHandler handler) {
|
||||
loadClasses();
|
||||
this.player = player;
|
||||
this.handler = handler;
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player) || !event.getInventory().equals(inv)) return;
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
|
||||
event.setCancelled(true);
|
||||
if (event.getInventory().equals(inv)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
int slot = event.getRawSlot();
|
||||
String name = "";
|
||||
ItemStack item = event.getCurrentItem();
|
||||
int slot = event.getRawSlot();
|
||||
String name = "";
|
||||
|
||||
if (item != null) {
|
||||
if (item.hasItemMeta()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (item != null) {
|
||||
if (item.hasItemMeta()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (meta.hasDisplayName()) {
|
||||
name = meta.getDisplayName();
|
||||
if (meta != null && meta.hasDisplayName()) {
|
||||
name = meta.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
|
||||
|
||||
handler.onAnvilClick(clickEvent);
|
||||
|
||||
if (clickEvent.getWillClose()) {
|
||||
event.getWhoClicked().closeInventory();
|
||||
}
|
||||
|
||||
if (clickEvent.getWillDestroy()) {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
|
||||
|
||||
handler.onAnvilClick(clickEvent);
|
||||
|
||||
if (clickEvent.getWillClose()) {
|
||||
event.getWhoClicked().closeInventory();
|
||||
}
|
||||
|
||||
if (clickEvent.getWillDestroy()) {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if (!(event.getPlayer() instanceof Player)) return;
|
||||
Inventory inv = event.getInventory();
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
if (!inv.equals(AbstractAnvilGUI.this.inv)) return;
|
||||
inv.clear();
|
||||
OnClose onClose = getOnClose();
|
||||
player.playSound(player.getLocation(), closeSound, 1F, 1F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(), () -> {
|
||||
if (onClose != null) onClose.OnClose(player, inv);
|
||||
destroy();
|
||||
}, 1L);
|
||||
if (event.getPlayer() instanceof Player) {
|
||||
Inventory inv = event.getInventory();
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
if (inv.equals(inv)) {
|
||||
inv.clear();
|
||||
player.playSound(player.getLocation(), closeSound, 1F, 1F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateKits.getInstance(), () -> {
|
||||
if (onClose != null) onClose.OnClose(player, inv);
|
||||
destroy();
|
||||
}, 1L);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (!event.getPlayer().equals(getPlayer())) return;
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
destroy();
|
||||
if (event.getPlayer().equals(getPlayer())) {
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(listener, UltimateKits.getInstance());
|
||||
}
|
||||
|
||||
private void loadClasses() {
|
||||
if (loadedClasses) return;
|
||||
BlockPosition = NMSUtil.getNMSClass("BlockPosition");
|
||||
PacketPlayOutOpenWindow = NMSUtil.getNMSClass("PacketPlayOutOpenWindow");
|
||||
ContainerAnvil = NMSUtil.getNMSClass("ContainerAnvil");
|
||||
EntityHuman = NMSUtil.getNMSClass("EntityHuman");
|
||||
ChatMessage = NMSUtil.getNMSClass("ChatMessage");
|
||||
loadedClasses = true;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
@ -127,50 +145,66 @@ public class AbstractAnvilGUI {
|
||||
|
||||
try {
|
||||
Object craftPlayer = NMSUtil.getCraftClass("entity.CraftPlayer").cast(player);
|
||||
Method getHandleMethod = craftPlayer.getClass().getMethod("getHandle", new Class<?>[0]);
|
||||
Object entityPlayer = getHandleMethod.invoke(craftPlayer, new Object[0]);
|
||||
Method getHandleMethod = craftPlayer.getClass().getMethod("getHandle");
|
||||
Object entityPlayer = getHandleMethod.invoke(craftPlayer);
|
||||
Object playerInventory = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false));
|
||||
Object world = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false));
|
||||
Object blockPosition = BlockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(0, 0, 0);
|
||||
|
||||
Object container;
|
||||
|
||||
if (NMSUtil.getVersionNumber() == 7) {
|
||||
container = ContainerAnvil.getConstructor(new Class[]{NMSUtil.getNMSClass("PlayerInventory"), NMSUtil.getNMSClass("World"), Integer.TYPE, Integer.TYPE, Integer.TYPE, EntityHuman}).newInstance(new Object[]{NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false)), NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false)), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0), entityPlayer});
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(int.class, PlayerInventoryClass, ContainerAccessClass)
|
||||
.newInstance(7, playerInventory, ContainerAccessClass.getMethod("at", WorldClass, BlockPositionClass).invoke(null, world, blockPosition));
|
||||
} else {
|
||||
container = ContainerAnvil.getConstructor(NMSUtil.getNMSClass("PlayerInventory"), NMSUtil.getNMSClass("World"), BlockPosition, EntityHuman).newInstance(NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false)), NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false)), BlockPosition.getConstructor(int.class, int.class, int.class).newInstance(0, 0, 0), entityPlayer);
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(PlayerInventoryClass, WorldClass, BlockPositionClass, EntityHumanClass)
|
||||
.newInstance(playerInventory, world, blockPosition, entityPlayer);
|
||||
}
|
||||
|
||||
NMSUtil.getField(NMSUtil.getNMSClass("Container"), "checkReachable", true).set(container, false);
|
||||
NMSUtil.getField(ContainerClass, "checkReachable", true).set(container, false);
|
||||
|
||||
Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView", new Class<?>[0]);
|
||||
Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView");
|
||||
Object bukkitView = getBukkitViewMethod.invoke(container);
|
||||
Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory", new Class<?>[0]);
|
||||
Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory");
|
||||
inv = (Inventory) getTopInventoryMethod.invoke(bukkitView);
|
||||
|
||||
for (AnvilSlot slot : items.keySet()) {
|
||||
inv.setItem(slot.getSlot(), items.get(slot));
|
||||
}
|
||||
|
||||
Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter", new Class<?>[0]);
|
||||
Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter");
|
||||
int c = (int) nextContainerCounterMethod.invoke(entityPlayer);
|
||||
|
||||
Constructor<?> chatMessageConstructor = ChatMessage.getConstructor(String.class, Object[].class);
|
||||
Constructor<?> chatMessageConstructor = ChatMessageClass.getConstructor(String.class, Object[].class);
|
||||
Object inventoryTitle = chatMessageConstructor.newInstance("Repairing", new Object[]{});
|
||||
|
||||
Object packet;
|
||||
|
||||
if (NMSUtil.getVersionNumber() == 7) {
|
||||
packet = PacketPlayOutOpenWindow.getConstructor(new Class[]{Integer.TYPE, Integer.TYPE, String.class, Integer.TYPE, Boolean.TYPE, Integer.TYPE}).newInstance(new Object[]{Integer.valueOf(c), Integer.valueOf(8), "Repairing", Integer.valueOf(0), Boolean.valueOf(true), Integer.valueOf(0)});
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, ContainersClass, IChatBaseComponentClass)
|
||||
.newInstance(c, ContainersClass.getField("ANVIL").get(null), inventoryTitle);
|
||||
} else {
|
||||
packet = PacketPlayOutOpenWindow.getConstructor(int.class, String.class, NMSUtil.getNMSClass("IChatBaseComponent"), int.class).newInstance(c, "minecraft:anvil", chatMessageConstructor.newInstance("Repairing", new Object[]{}), 0);
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, String.class, IChatBaseComponentClass, int.class)
|
||||
.newInstance(c, "minecraft:anvil", inventoryTitle, 0);
|
||||
}
|
||||
|
||||
NMSUtil.sendPacket(player, packet);
|
||||
|
||||
Field activeContainerField = NMSUtil.getField(EntityHuman, "activeContainer", true);
|
||||
Field activeContainerField = NMSUtil.getField(EntityHumanClass, "activeContainer", true);
|
||||
|
||||
if (activeContainerField != null) {
|
||||
activeContainerField.set(entityPlayer, container);
|
||||
NMSUtil.getField(NMSUtil.getNMSClass("Container"), "windowId", true).set(activeContainerField.get(entityPlayer), c);
|
||||
|
||||
Method addSlotListenerMethod = activeContainerField.get(entityPlayer).getClass().getMethod("addSlotListener", NMSUtil.getNMSClass("ICrafting"));
|
||||
NMSUtil.getField(ContainerClass, "windowId", true).set(activeContainerField.get(entityPlayer), c);
|
||||
Method addSlotListenerMethod = activeContainerField.get(entityPlayer).getClass().getMethod("addSlotListener", ICraftingClass);
|
||||
addSlotListenerMethod.invoke(activeContainerField.get(entityPlayer), entityPlayer);
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerClass.getMethod("setTitle", IChatBaseComponentClass).invoke(container, inventoryTitle);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -178,9 +212,7 @@ public class AbstractAnvilGUI {
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
onClose = null;
|
||||
player = null;
|
||||
handler = null;
|
||||
items = null;
|
||||
|
||||
HandlerList.unregisterAll(listener);
|
||||
@ -207,7 +239,7 @@ public class AbstractAnvilGUI {
|
||||
|
||||
private int slot;
|
||||
|
||||
private AnvilSlot(int slot) {
|
||||
AnvilSlot(int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@ -226,6 +258,7 @@ public class AbstractAnvilGUI {
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AnvilClickEventHandler {
|
||||
void onAnvilClick(AnvilClickEvent event);
|
||||
}
|
||||
@ -267,4 +300,5 @@ public class AbstractAnvilGUI {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public abstract class AbstractGUI implements Listener {
|
||||
private static boolean listenersInitialized = false;
|
||||
protected Player player;
|
||||
protected Inventory inventory = null;
|
||||
protected String setTitle = null;
|
||||
protected boolean cancelBottom = false;
|
||||
private Map<Range, Clickable> clickables = new HashMap<>();
|
||||
private List<OnClose> onCloses = new ArrayList<>();
|
||||
@ -115,8 +116,9 @@ public abstract class AbstractGUI implements Listener {
|
||||
public void init(String title, int slots) {
|
||||
if (inventory == null
|
||||
|| inventory.getSize() != slots
|
||||
|| ChatColor.translateAlternateColorCodes('&', title) != inventory.getTitle()) {
|
||||
|| !ChatColor.translateAlternateColorCodes('&', title).equals(player.getOpenInventory().getTitle())) {
|
||||
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, Methods.formatTitle(title));
|
||||
this.setTitle = Methods.formatText(title);
|
||||
if (this.clickables.size() == 0)
|
||||
registerClickables();
|
||||
if (this.onCloses.size() == 0)
|
||||
@ -217,4 +219,8 @@ public abstract class AbstractGUI implements Listener {
|
||||
return AbstractGUI.this;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSetTitle() {
|
||||
return setTitle;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.songoda.ultimatekits.utils.updateModules;
|
||||
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.update.Module;
|
||||
import com.songoda.update.Plugin;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public class LocaleModule implements Module {
|
||||
|
||||
@Override
|
||||
public void run(Plugin plugin) {
|
||||
JSONObject json = plugin.getJson();
|
||||
try {
|
||||
JSONArray files = (JSONArray) json.get("neededFiles");
|
||||
for (Object o : files) {
|
||||
JSONObject file = (JSONObject) o;
|
||||
|
||||
if (file.get("type").equals("locale")) {
|
||||
InputStream in = new URL((String) file.get("link")).openStream();
|
||||
UltimateKits.getInstance().getLocale().saveDefaultLocale(in, (String) file.get("name"));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
name: UltimateKits
|
||||
main: com.songoda.ultimatekits.UltimateKits
|
||||
version: maven-version-number
|
||||
softdepend: [Arconix, PlaceholderAPI, Vault, UltimateCore, Essentials, MiniKitPvP]
|
||||
softdepend: [HolographicDisplays, PlaceholderAPI, Vault, UltimateCore, Essentials, MiniKitPvP]
|
||||
description: View a kit before you purchase it!
|
||||
author: Songoda
|
||||
api-version: 1.13
|
||||
|
Loading…
Reference in New Issue
Block a user