mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-26 20:25:53 +01:00
Added HolographicDisplays. Removed Arconix. Added Songoda Updater.
This commit is contained in:
parent
dc1906ab17
commit
06dcafc47c
37
pom.xml
37
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>
|
||||
@ -54,8 +87,8 @@
|
||||
</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.
|
||||
*/
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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,10 +30,12 @@ public class BlockListeners implements Listener {
|
||||
KitBlockData kitBlockData = instance.getKitManager().getKit(block.getLocation());
|
||||
if (kitBlockData == null) return;
|
||||
Kit kit = kitBlockData.getKit();
|
||||
instance.getKitManager().removeKitFromLocation(block.getLocation());
|
||||
|
||||
if (instance.getHologram() != null)
|
||||
instance.getHologram().remove(kitBlockData);
|
||||
|
||||
instance.getKitManager().removeKitFromLocation(block.getLocation());
|
||||
|
||||
event.getPlayer().sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&8Kit &9" + kit.getName() + " &8unassigned from: &a" + block.getType() + "&8."));
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -234,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);
|
||||
|
||||
|
@ -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