Migration to Maven, removing buggy code

In preparation for using sk89q's command framework
This commit is contained in:
Charlie 2014-07-28 09:37:04 -04:00
parent 70a94aa4b1
commit b490df861e
9 changed files with 214 additions and 56 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target/

View File

@ -3,8 +3,18 @@ DiscoSheep
A plugin for [Bukkit](http://bukkit.org/), the Minecraft server API. This is a from-scratch remake of the fabulous [DiscoSheep plugin](http://forums.bukkit.org/threads/inactive-fun-discosheep-v0-3-uninvited-guesssts-permissions-and-source-code-522.7106/) which spawns a dance party of sheep at your whim.
###DiscoFix###
An attempt to fix up DiscoSheep. No new big features. A short (non-binding) todo list:
* fix NPE for guests
* refactor command handling (use sk89q's framework)
* fix wifi, bluetooth, GPS (wipe dalvik x333)
* you tell me
##A note on UUIDs##
DiscoSheep doesn't store anything after a party and getPlayer(name), and disco-party-on-join is handled by a permissions plugin. Thus, we don't need to worry about the migration to UUIDs.
###Versions###
Tested up to CraftBukkit build 2918 (RB for 1.6.4 R2.0); can be built with Java 6.
Tested up to CraftBukkit build 2918 (RB for 1.6.4 R2.0); can be built with Java 7.
###[BukkitDev](http://dev.bukkit.org/bukkit-plugins/superdiscosheep/)###

52
pom.xml Normal file
View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ca.gibstick</groupId>
<artifactId>DiscoSheep</artifactId>
<version>1.1.2</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<scope>provided</scope>
<version>1.7.9-R0.2</version>
</dependency>
</dependencies>
<build>
<finalName>DiscoSheep</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerArgs>
<arg>-Xlint:deprecation</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>

View File

@ -276,7 +276,7 @@ public class DiscoParty {
}
loc = player.getLocation();
this.spawnFloor(world, new Location(world, loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()));
//this.spawnFloor(world, new Location(world, loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()));
}
void spawnSheep(World world, Location loc) {
@ -428,9 +428,9 @@ public class DiscoParty {
}
}
for (Block block : this.floorBlocks) {
/* for (Block block : this.floorBlocks) {
this.randomizeFloor(block);
}
}*/
}

View File

@ -25,7 +25,7 @@ public final class DiscoSheep extends JavaPlugin {
static final String PERMISSION_SPAWNGUESTS = "discosheep.party.spawnguests";
static final String PERMISSION_TOGGLEPARTYONJOIN = "discosheep.admin.toggleonjoin";
static final String PERMISSION_LIGHTNING = "discosheep.party.lightning";
static boolean partyOnJoin = true;
static boolean partyOnJoin = false;
Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
@Override
@ -48,7 +48,7 @@ public final class DiscoSheep extends JavaPlugin {
* Iterate through all live entities and create default configuration values for them
* excludes bosses and other mobs that throw NPE
*/
for (EntityType ent : EntityType.values()) {
/* for (EntityType ent : EntityType.values()) {
if (ent.isAlive()
&& !ent.equals(EntityType.ENDER_DRAGON)
&& !ent.equals(EntityType.WITHER)
@ -62,8 +62,7 @@ public final class DiscoSheep extends JavaPlugin {
getConfig().addDefault("default.guests." + ent.toString(), 0);
getConfig().addDefault("max.guests." + ent.toString(), 0);
}
}
}*/
loadConfigFromDisk();
}
@ -82,13 +81,13 @@ public final class DiscoSheep extends JavaPlugin {
DiscoParty.defaultDuration = toTicks(getConfig().getInt("default.duration"));
DiscoParty.defaultPeriod = getConfig().getInt("default.period-ticks");
for (String key : getConfig().getConfigurationSection("default.guests").getKeys(false)) {
/* for (String key : getConfig().getConfigurationSection("default.guests").getKeys(false)) {
DiscoParty.getDefaultGuestNumbers().put(key, getConfig().getInt("default.guests." + key));
}
for (String key : getConfig().getConfigurationSection("max.guests").getKeys(false)) {
DiscoParty.getMaxGuestNumbers().put(key, getConfig().getInt("max.guests." + key));
}
}*/
}
@ -104,9 +103,9 @@ public final class DiscoSheep extends JavaPlugin {
getConfig().set("default.duration", toSeconds_i(DiscoParty.defaultDuration));
getConfig().set("default.period-ticks", DiscoParty.defaultPeriod);
for (Map.Entry<String, Integer> entry : DiscoParty.getDefaultGuestNumbers().entrySet()) {
/* for (Map.Entry<String, Integer> entry : DiscoParty.getDefaultGuestNumbers().entrySet()) {
getConfig().set("default.guests." + entry.getKey(), entry.getValue());
}
}*/
saveConfig();
}
@ -176,8 +175,8 @@ public final class DiscoSheep extends JavaPlugin {
+ "-t <integer>: set the party duration in seconds\n"
+ "-p <ticks>: set the number of ticks between each disco beat\n"
+ "-r <integer>: set radius of the area in which sheep can spawn\n"
+ "-g <mob> <number>: set spawns for other mobs"
+ "-l: enables lightning"
//+ "-g <mob> <number>: set spawns for other mobs\n"
+ "-l: enables lightning\n"
+ "-fw: enables fireworks");
return true;
}
@ -220,6 +219,9 @@ public final class DiscoSheep extends JavaPlugin {
}
}
@SuppressWarnings( "deprecation" )
// UUIDs not necessary since DiscoSheep only lasts for one session at most
// and permissions will handle onJoin DiscoSheep
boolean partyOtherCommand(String[] players, CommandSender sender, DiscoParty party) {
if (sender.hasPermission(PERMISSION_OTHER)) {
Player p;

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class DiscoSheepCommandExecutor implements CommandExecutor {
private DiscoSheep parent;
private final DiscoSheep parent;
public DiscoSheepCommandExecutor(DiscoSheep parent) {
this.parent = parent;
@ -147,26 +147,26 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
+ DiscoParty.maxPeriod + "]");
return false;
}
} else if (args[i].equalsIgnoreCase("-g")) {
if (!sender.hasPermission(DiscoSheep.PERMISSION_SPAWNGUESTS)) {
return parent.noPermsMessage(sender, DiscoSheep.PERMISSION_SPAWNGUESTS);
}
if (parseNextArg(args, i, "none")) {
return parent.clearGuests(mainParty);
}
String[] guests = getNextArgs(args, i + 1);
int j = 0;
while (j < guests.length - 1) {
try {
mainParty.setGuestNumber(guests[j], getNextIntArg(guests, j));
} catch (IllegalArgumentException e) {
sender.sendMessage(ChatColor.RED + "Invalid arguments: " + ChatColor.WHITE + guests[j] + ", " + guests[j + 1]
+ ".\nEither a name typo or a number that is not within limits.");
}
j += 2; // skip over two arguments, since they come in pairs of entity-number
}
// } else if (args[i].equalsIgnoreCase("-g")) {
// if (!sender.hasPermission(DiscoSheep.PERMISSION_SPAWNGUESTS)) {
// return parent.noPermsMessage(sender, DiscoSheep.PERMISSION_SPAWNGUESTS);
// }
//
// if (parseNextArg(args, i, "none")) {
// return parent.clearGuests(mainParty);
// }
//
// String[] guests = getNextArgs(args, i + 1);
// int j = 0;
// while (j < guests.length - 1) {
// try {
// mainParty.setGuestNumber(guests[j], getNextIntArg(guests, j));
// } catch (IllegalArgumentException e) {
// sender.sendMessage(ChatColor.RED + "Invalid arguments: " + ChatColor.WHITE + guests[j] + ", " + guests[j + 1]
// + ".\nEither a name typo or a number that is not within limits.");
// }
// j += 2; // skip over two arguments, since they come in pairs of entity-number
// }
} else if (args[i].equalsIgnoreCase("-l")) {
if (!sender.hasPermission(DiscoSheep.PERMISSION_LIGHTNING)) {
return parent.noPermsMessage(sender, DiscoSheep.PERMISSION_LIGHTNING);

View File

@ -0,0 +1,93 @@
name: DiscoSheep
main: ca.gibstick.discosheep.DiscoSheep
authors: [Gibstick, RangerMauve]
version: 1.1.1
commands:
ds:
description: "Main DiscoSheep command"
usage: |
<command> <subcommand> [arguments]
Use /ds help for more information
To stop your party, use /ds stop.
permissions:
# If default is set to false, console will not have permission!
discosheep.*:
description: Permission node for all DiscoSheep commands
default: op
children:
discosheep.party: true
discosheep.admin: true
discosheep.party.*:
description: All permissions related to parties
defualt: op
children:
discosheep.party.me: true
discosheep.party.all: true
discosheep.party.fireworks: true
discosheep.party.other: true
discosheep.party.changeperiod: true
discosheep.party.spawnguests: true
discosheep.party.lightning: true
discosheep.admin.*:
description: Suggested permissions for administrators
default: op
children:
discosheep.admin.stopall: true
discosheep.admin.reload: true
discosheep.admin.changedefaults: true
discosheep.admin.saveconfig: true
discosheep.admin.toggleonjoin: true
discosheep.party.me:
description: Allows a player to have a party of one
default: op
discosheep.party.all:
description: Allows a player to call a server-wide party
default: op
discosheep.admin.stopall:
description: Allows a player to stop all parties on the server
default: op
discosheep.party.fireworks:
description: Allows a player to enable have parties with fireworks
default: op
discosheep.admin.reload:
description: Allows a player to reload settings from config.yml
default: op
discosheep.party.other:
description: Allows a player to call parties for other people, including themselves.
default: op
children:
discosheep.party.me: true
discosheep.party.changeperiod:
description: Allows a player to use the -p switch
default: op
discosheep.admin.changedefaults:
description: Allows a player to change the default settings
default: op
discosheep.admin.saveconfig:
description: Allows a player to save the config with current values set in memory
default: op
discosheep.party.onjoin:
description: Gives a player a disco party on join
default: false
discosheep.party.spawnguests:
description: Allow a player to spawn other mobs
default: op
discosheep.admin.toggleonjoin:
description: Allow a player to toggle party-on-join functionality (force disable)
default: op
discosheep.party.lightning:
description: Allow a player to use lightning for parties
default: op
# FOR BACKWARDS COMPAT FROM 1.1 TO 1.1.1
discosheep.party:
children:
discosheep.party.me: true
discosheep.partyall:
children:
discosheep.party.all: true
discosheep.reload:
children:
discoshep.admin.reload: true
discosheep.stopall:
children:
discosheep.admin.stopall: true