3
0
Fork 0

Added message to sign creation/removal

Fixed name errors
This commit is contained in:
thomas 2021-09-03 22:24:29 +02:00
parent f8a6df8479
commit 06b579ee27
35 changed files with 107 additions and 63 deletions

View file

@ -1,5 +1,6 @@
package nl.iobyte.themepark.api.menu.objects;
import com.cryptomorin.xseries.XMaterial;
import nl.iobyte.menuapi.MenuAPI;
import nl.iobyte.menuapi.action.HandlerAction;
import nl.iobyte.menuapi.basic.Menu;
@ -59,10 +60,14 @@ public class MainMenu {
if(name == null || name.equals(""))
name = " ";
Material material = Material.getMaterial(manager.getString(StorageLocation.MENU, path+".material"));
XMaterial material = XMaterial.matchXMaterial(manager.getString(StorageLocation.MENU, path+".material")).orElse(null);
if(material == null)
continue;
Material m = material.parseMaterial();
if(m == null)
continue;
int amount = manager.getInt(StorageLocation.MENU, path+".amount");
if(amount < 1)
amount = 1;
@ -71,7 +76,7 @@ public class MainMenu {
if(data < 0)
continue;
builder = new ItemBuilder(material, amount, data);
builder = new ItemBuilder(m, amount, data);
builder.setName(name);
String lore = manager.getString(StorageLocation.MENU, path+".lore");

View file

@ -1,7 +1,9 @@
package nl.iobyte.themepark.api.menu.objects.actions;
import nl.iobyte.menuapi.action.MenuAction;
import nl.iobyte.themepark.ThemePark;
import nl.iobyte.themepark.api.attraction.objects.Attraction;
import nl.iobyte.themepark.api.config.enums.StorageKey;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -14,7 +16,7 @@ public class TPAction extends MenuAction {
}
public void execute(Player player) {
Bukkit.dispatchCommand(player, "themepark attraction warp "+attraction.getID());
Bukkit.dispatchCommand(player, ThemePark.getInstance().getAPI().getConfigurationManager().getString(StorageKey.CMD)+" attraction warp "+attraction.getID());
}
}

View file

@ -19,21 +19,22 @@ public class SignManager {
return signs;
}
public void addSign(StatusSign sign) {
public boolean addSign(StatusSign sign) {
if(sign == null || sign.getLocation() == null)
return;
return false;
if(!(sign.getLocation().getBlock().getState() instanceof Sign))
return;
return false;
if(signs.containsKey(sign.getAttraction())) {
signs.get(sign.getAttraction()).add(sign);
return;
return true;
}
ArrayList<StatusSign> array = new ArrayList<>();
array.add(sign);
signs.put(sign.getAttraction(), array);
return true;
}
public boolean hasSigns(Attraction attraction) {
@ -84,36 +85,40 @@ public class SignManager {
ThemePark.getInstance().getAPI().getConfigurationManager().set(StorageLocation.SIGN_DATA, "signs."+attraction.getID(), null);
}
public void removeSign(StatusSign sign) {
public boolean removeSign(StatusSign sign) {
if(sign == null || sign.getLocation() == null || sign.getAttraction() == null)
return;
return false;
if(!hasSigns(sign.getAttraction()))
return;
return false;
String str2;
Location loc1 = sign.getLocation();
String str1 = LocationUtil.toString(loc1);
ArrayList<StatusSign> array = signs.get(sign.getAttraction());
boolean b = false;
for(StatusSign s : new ArrayList<>(array)) {
Location loc2 = s.getLocation();
if(loc1 == null || loc2 == null)
return;
String str2 = LocationUtil.toString(loc2);
continue;
str2 = LocationUtil.toString(loc2);
if(!str1.equals(str2))
return;
continue;
array.remove(s);
b = true;
break;
}
if(array.isEmpty()) {
signs.remove(sign.getAttraction());
ThemePark.getInstance().getAPI().getConfigurationManager().set(StorageLocation.SIGN_DATA, "signs."+sign.getAttraction().getID(), null);
return;
return b;
}
signs.put(sign.getAttraction(), array);
return b;
}
}

View file

@ -35,7 +35,7 @@ public class ItemCommand extends SubCommand {
Player player = (Player) sender.getOriginal();
player.getInventory().addItem(builder.getItem());
player.updateInventory();
player.sendMessage(Text.color("&6&lThemeParkMC &f➢ Added item to your inventory"));
player.sendMessage(Text.color("&6&lThemePark &f➢ Added item to your inventory"));
}
}

View file

@ -22,6 +22,6 @@ public class AttractionCoverCommand extends SubCommand {
Attraction attraction = (Attraction) list.get(0);
String url = (String) list.get(1);
attraction.setCover(url);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the cover of attraction &f"+attraction.getID()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the cover of attraction &f"+attraction.getID()));
}
}

View file

@ -64,7 +64,7 @@ public class AttractionCreateCommand extends SubCommand {
status,
location
));
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully created attraction &f"+id));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully created attraction &f"+id));
}
}

View file

@ -75,7 +75,7 @@ public class AttractionListCommand extends SubCommand {
private void sendMultiPage(ICommandExecutor sender, int page, String title, Collection<Attraction> attractions) {
int pages = (int) Math.ceil(((double) attractions.size()) / 5);
if(page < 1 || page > pages) {
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ Page &6"+page+" &fdoesn't exist"));
sender.sendMessage(Text.color("&6&lThemePark &f➢ Page &6"+page+" &fdoesn't exist"));
return;
}

View file

@ -22,7 +22,7 @@ public class AttractionLocationCommand extends SubCommand {
Attraction attraction = (Attraction) list.get(0);
Player player = (Player) sender.getOriginal();
attraction.setLocation(player.getLocation());
player.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the location of attraction &f"+attraction.getID()));
player.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the location of attraction &f"+attraction.getID()));
}
}

View file

@ -22,7 +22,7 @@ public class AttractionNameCommand extends SubCommand {
Attraction attraction = (Attraction) list.get(0);
String name = (String) list.get(1);
attraction.setName(name);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the name of attraction &f"+attraction.getID()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the name of attraction &f"+attraction.getID()));
}
}

View file

@ -23,7 +23,7 @@ public class AttractionRegionCommand extends SubCommand {
Attraction attraction = (Attraction) list.get(0);
Region region = (Region) list.get(1);
attraction.setRegionID(region.getID());
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the region of attraction &f"+attraction.getID()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the region of attraction &f"+attraction.getID()));
}
}

View file

@ -20,7 +20,7 @@ public class AttractionRemoveCommand extends SubCommand {
public void onCommand(ICommandExecutor sender, List<Object> list, int i) {
Attraction attraction = (Attraction) list.get(0);
ThemePark.getInstance().getAPI().getAttractionService().removeAttraction(attraction.getID());
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully removed attraction &f"+attraction.getID()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully removed attraction &f"+attraction.getID()));
}
}

View file

@ -37,7 +37,7 @@ public class AttractionStatusCommand extends SubCommand {
return;
attraction.setStatus(status);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the status of attraction &f"+attraction.getID()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the status of attraction &f"+attraction.getID()));
}
);
}

View file

@ -32,7 +32,7 @@ public class AttractionWarpCommand extends SubCommand {
}
if(attraction.getLocation() == null) {
player.sendMessage(Text.color("&6&lThemeParkMC &f➢ &4No location available for this attraction"));
player.sendMessage(Text.color("&6&lThemePark &f➢ &4No location available for this attraction"));
return;
}

View file

@ -28,7 +28,7 @@ public class RegionCreateCommand extends SubCommand {
id,
name
));
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully created region &f"+id));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully created region &f"+id));
}
}

View file

@ -49,7 +49,7 @@ public class RegionListCommand extends SubCommand {
page = (Integer) list.get(0);
if(page < 1 || page > pages) {
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ Page &6"+page+" &fdoesn't exist"));
sender.sendMessage(Text.color("&6&lThemePark &f➢ Page &6"+page+" &fdoesn't exist"));
return;
}

View file

@ -22,7 +22,7 @@ public class RegionNameCommand extends SubCommand {
Region region = (Region) list.get(0);
String name = (String) list.get(1);
region.setName(name);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the name of region &f"+region.getID()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the name of region &f"+region.getID()));
}
}

View file

@ -20,7 +20,7 @@ public class RegionRemoveCommand extends SubCommand {
public void onCommand(ICommandExecutor sender, List<Object> list, int i) {
Region region = (Region) list.get(0);
ThemePark.getInstance().getAPI().getAttractionService().removeRegion(region.getID());
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully removed region &f"+region.getID()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully removed region &f"+region.getID()));
}
}

View file

@ -36,7 +36,7 @@ public class RideCountAddCommand extends SubCommand {
);
sender.sendMessage(Text.color(
"&6&lThemeParkMC &f➢ &aSuccessfully added count of: &6"+amount+"x &ato attraction: &f"+attraction.getID()+" &afor &6"+players.size()+" &aplayers"
"&6&lThemePark &f➢ &aSuccessfully added count of: &6"+amount+"x &ato attraction: &f"+attraction.getID()+" &afor &6"+players.size()+" &aplayers"
));
}

View file

@ -22,7 +22,7 @@ public class RideCountChangeTotalTypeCommand extends SubCommand {
TotalType type = (TotalType) list.get(0);
ThemePark.getInstance().getAPI().getRideCountService().setType(type);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ Changed total type for ridecount to: &f"+type.toString()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ Changed total type for ridecount to: &f"+type.toString()));
}
}

View file

@ -32,7 +32,7 @@ public class RideCountGetCommand extends SubCommand {
);
sender.sendMessage(Text.color(
"&6&lThemeParkMC &f➢ You have ridden attraction: &f"+attraction.getID()+" &ffor &6"+(count == null ? 0 : count.getCount())+"x"
"&6&lThemePark &f➢ You have ridden attraction: &f"+attraction.getID()+" &ffor &6"+(count == null ? 0 : count.getCount())+"x"
));
}

View file

@ -24,7 +24,7 @@ public class StatusColorCommand extends SubCommand {
Status status = (Status) list.get(0);
String color = (String) list.get(1);
status.setColor(color);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the color of status &f"+status.toString()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the color of status &f"+status.toString()));
}
}

View file

@ -25,7 +25,7 @@ public class StatusHexColorCommand extends SubCommand {
Status status = (Status) list.get(0);
String hex_color = (String) list.get(1);
status.setHexColor(hex_color);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the hex color of status &f"+status.toString()));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the hex color of status &f"+status.toString()));
}
}

View file

@ -25,7 +25,7 @@ public class StatusMaterialCommand extends SubCommand {
XMaterial material = (XMaterial) list.get(1);
status.setMaterial(material);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the material of status &f"+ status));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the material of status &f"+ status));
}
}

View file

@ -23,7 +23,7 @@ public class StatusNameCommand extends SubCommand {
Status status = (Status) list.get(0);
String name = (String) list.get(1);
status.setName(name);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed the name of status &f"+ status));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed the name of status &f"+ status));
}
}

View file

@ -24,7 +24,7 @@ public class StatusTeleportCommand extends SubCommand {
Status status = (Status) list.get(0);
boolean b = (boolean) list.get(1);
status.setCanTeleport(b);
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ &aSuccessfully changed if status &f"+status.toString()+" &acan teleport"));
sender.sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully changed if status &f"+status.toString()+" &acan teleport"));
}
}

View file

@ -38,7 +38,7 @@ public class AttractionListener implements Listener {
ThemePark.getInstance().getAPI().getDatabaseService().executeAsync(
"remote",
"INSERT IGNORE INTO attractions(id, region_id, name, cover, status_id) VALUES (?,?,?,?,?)",
new HashMap<Integer, Object>() {{
new HashMap<>() {{
put(1, attraction.getID());
put(2, attraction.getRegionID());
put(3, attraction.getName());

View file

@ -138,7 +138,7 @@ public class PlayerListener implements Listener {
e.setCancelled(true);
Player player = e.getPlayer();
Bukkit.dispatchCommand(player, "themepark menu");
Bukkit.dispatchCommand(player, manager.getString(StorageKey.CMD)+" menu");
}
//Handle Menu item drop

View file

@ -42,7 +42,8 @@ public class StatusSignListener implements Listener {
Location location = e.getBlock().getLocation();
StatusSign statusSign = new StatusSign(attraction, location);
manager.addSign(statusSign);
if(manager.addSign(statusSign))
e.getPlayer().sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully created a status sign"));
}
@EventHandler
@ -62,7 +63,9 @@ public class StatusSignListener implements Listener {
Location location = e.getBlock().getLocation();
StatusSign s = new StatusSign(attraction, location);
manager.removeSign(s);
if(manager.removeSign(s))
e.getPlayer().sendMessage(Text.color("&6&lThemePark &f➢ &aSuccessfully removed a status sign"));
}
@EventHandler

View file

@ -6,6 +6,7 @@ import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import nl.iobyte.themepark.ThemePark;
import nl.iobyte.themepark.api.attraction.objects.Attraction;
import nl.iobyte.themepark.api.config.enums.StorageKey;
import nl.iobyte.themepark.api.config.enums.StorageLocation;
import nl.iobyte.themepark.api.message.MessageKey;
import nl.iobyte.themepark.api.message.Text;
@ -21,7 +22,7 @@ public class StatusMessage {
public static void broadcast(Attraction attraction) {
HashMap<String, String> change = new HashMap<>();
change.put("{name}", attraction.getName());
ClickEvent click = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/themepark attraction warp "+attraction.getID());
ClickEvent click = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/"+ThemePark.getInstance().getAPI().getConfigurationManager().getString(StorageKey.CMD)+" attraction warp "+attraction.getID());
HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Text.color(ThemePark.getInstance().getAPI().getConfigurationManager().getString(StorageLocation.MESSAGE, "attraction.changed.hover"))));
if(hover.getValue()[0].toPlainText().isEmpty())
hover = null;

View file

@ -95,34 +95,31 @@ public class UpdateManager {
public void check() {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
BufferedReader in = null;
HttpsURLConnection con;
if (type == CheckType.SPIGOT) {
HttpsURLConnection con = (HttpsURLConnection) new URL(String.format(SPIGOT_API, this.resourceID)).openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con = (HttpsURLConnection) new URL(String.format(SPIGOT_API, this.resourceID)).openConnection();
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
} else if (type == CheckType.SBDPLUGINS) {
HttpsURLConnection con = (HttpsURLConnection) new URL(String.format(SBDPLUGINS_API, this.resourceID)).openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
con = (HttpsURLConnection) new URL(String.format(SBDPLUGINS_API, this.resourceID)).openConnection();
} else {
return;
}
if (in == null) return;
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream())
);
String version;
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
while ((inputLine = in.readLine()) != null)
response.append(inputLine);
}
in.close();
JsonParser parser = new JsonParser();
if (type == CheckType.SPIGOT) {
JsonArray array = parser.parse(response.toString()).getAsJsonArray();