mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-30 13:07:46 +01:00
Improved addon loading error reporting
Fixed a bug in the team invite error strings.
This commit is contained in:
parent
6d22f199ee
commit
f2831c7258
@ -14,7 +14,6 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.util.permissions.DefaultPermissions;
|
||||
|
||||
import world.bentobox.bbox.BentoBox;
|
||||
import world.bentobox.bbox.api.addons.AddonDescription.AddonDescriptionBuilder;
|
||||
import world.bentobox.bbox.api.addons.exception.InvalidAddonFormatException;
|
||||
import world.bentobox.bbox.api.addons.exception.InvalidAddonInheritException;
|
||||
@ -45,12 +44,12 @@ public class AddonClassLoader extends URLClassLoader {
|
||||
try {
|
||||
String mainClass = data.getString("main");
|
||||
javaClass = Class.forName(mainClass, true, this);
|
||||
if(mainClass.contains("us.tastybento")){
|
||||
throw new InvalidAddonFormatException("Packages declaration cannot start with 'us.tastybento'");
|
||||
if(mainClass.startsWith("world.bentobox")){
|
||||
throw new InvalidAddonFormatException("Packages declaration cannot start with 'world.bentobox'");
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
BentoBox.getInstance().logError("Could not load '" + path.getName() + "' in folder '" + path.getParent() + "' - invalid addon.yml");
|
||||
throw new InvalidDescriptionException("Invalid addon.yml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new InvalidDescriptionException("Could not load '" + path.getName() + "' in folder '" + path.getParent() + "' - " + e.getMessage());
|
||||
}
|
||||
|
||||
Class<? extends Addon> addonClass;
|
||||
|
@ -71,19 +71,19 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
||||
}
|
||||
// Player cannot invite themselves
|
||||
if (playerUUID.equals(invitedPlayerUUID)) {
|
||||
user.sendMessage("commands.island.team.invite.cannot-invite-self");
|
||||
user.sendMessage("commands.island.team.invite.errors.cannot-invite-self");
|
||||
return false;
|
||||
}
|
||||
// Check if this player can be invited to this island, or
|
||||
// whether they are still on cooldown
|
||||
long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(getWorld(), playerUUID));
|
||||
if (time > 0 && !user.isOp()) {
|
||||
user.sendMessage("commands.island.team.invite.cooldown", TextVariables.NUMBER, String.valueOf(time));
|
||||
user.sendMessage("commands.island.team.invite.errors.cooldown", TextVariables.NUMBER, String.valueOf(time));
|
||||
return false;
|
||||
}
|
||||
// Player cannot invite someone already on a team
|
||||
if (getIslands().inTeam(getWorld(), invitedPlayerUUID)) {
|
||||
user.sendMessage("commands.island.team.invite.already-on-team");
|
||||
user.sendMessage("commands.island.team.invite.errors.already-on-team");
|
||||
return false;
|
||||
}
|
||||
return invite(user,invitedPlayer);
|
||||
@ -148,12 +148,12 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum team size for this player in this game based on the permission or the world's setting
|
||||
* @param user - user
|
||||
* @return max team size of user
|
||||
*/
|
||||
public int getMaxTeamSize(User user) {
|
||||
return Util.getPermValue(user.getPlayer(), getPermissionPrefix() + "team.maxsize.", getIWM().getMaxTeamSize(getWorld()));
|
||||
}
|
||||
* Gets the maximum team size for this player in this game based on the permission or the world's setting
|
||||
* @param user - user
|
||||
* @return max team size of user
|
||||
*/
|
||||
public int getMaxTeamSize(User user) {
|
||||
return Util.getPermValue(user.getPlayer(), getPermissionPrefix() + "team.maxsize.", getIWM().getMaxTeamSize(getWorld()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,8 +92,7 @@ public class AddonsManager {
|
||||
// Obtain the addon.yml file
|
||||
JarEntry entry = jar.getJarEntry("addon.yml");
|
||||
if (entry == null) {
|
||||
throw new InvalidAddonFormatException("Addon doesn't contains description file");
|
||||
|
||||
throw new InvalidAddonFormatException("Addon '" + f.getName() + "' doesn't contains addon.yml file");
|
||||
}
|
||||
// Open a reader to the jar
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(jar.getInputStream(entry)));
|
||||
|
@ -190,7 +190,7 @@ public class IslandTeamInviteCommandTest {
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(Mockito.any())).thenReturn(uuid);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.cannot-invite-self"));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.errors.cannot-invite-self"));
|
||||
}
|
||||
|
||||
|
||||
@ -207,7 +207,7 @@ public class IslandTeamInviteCommandTest {
|
||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.already-on-team"));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.errors.already-on-team"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user