mirror of
https://github.com/TotalFreedomMC/TF-Marriage.git
synced 2024-06-15 16:21:23 +00:00
Add serveral bug fixes
This commit is contained in:
parent
26ca82f572
commit
b4529cb7d4
77
dependency-reduced-pom.xml
Normal file
77
dependency-reduced-pom.xml
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.lenis0012.bukkit</groupId>
|
||||
<artifactId>marriage2</artifactId>
|
||||
<name>Marriage</name>
|
||||
<version>2.0</version>
|
||||
<url>http://dev.bukkit.org/server-mods/marriage-reloaded/</url>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>${project.name}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.google.guava:guava</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>md5-repo</id>
|
||||
<url>http://repo.md-5.net/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.7.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
34
pom.xml
34
pom.xml
|
@ -2,11 +2,10 @@
|
|||
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>me.lenis0012.mr</groupId>
|
||||
<artifactId>Marriage</artifactId>
|
||||
<version>1.2.6</version>
|
||||
<groupId>com.lenis0012.bukkit</groupId>
|
||||
<artifactId>marriage2</artifactId>
|
||||
<version>2.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Marriage</name>
|
||||
<url>http://dev.bukkit.org/server-mods/marriage-reloaded/</url>
|
||||
|
||||
|
@ -15,37 +14,19 @@
|
|||
</properties>
|
||||
|
||||
<repositories>
|
||||
<!-- Repo for access to Vault -->
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://ci.herocraftonline.com/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<!-- Repo for access to CraftBukkit -->
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
<id>md5-repo</id>
|
||||
<url>http://repo.md-5.net/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.7.10-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dthielke</groupId>
|
||||
<artifactId>Herochat</artifactId>
|
||||
<version>5.6.7-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/HeroChat.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
@ -74,7 +55,7 @@
|
|||
</resource>
|
||||
</resources>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>Marriage</finalName>
|
||||
<finalName>${project.name}</finalName>
|
||||
<!-- Plugins -->
|
||||
<plugins>
|
||||
<!-- Compiler plugin -->
|
||||
|
@ -89,6 +70,7 @@
|
|||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Shade guava to make sure we have the reflection API even on older versions of bukkit -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
|
|
|
@ -38,7 +38,7 @@ public interface Marriage {
|
|||
ListQuery getMarriageList(int scale, int page);
|
||||
|
||||
/**
|
||||
* Marry 2 players to eachother.
|
||||
* Marry 2 players to each other.
|
||||
*
|
||||
* @param player1 Player 1
|
||||
* @param player2 Player 2
|
||||
|
|
|
@ -27,12 +27,12 @@ public enum Message {
|
|||
private final String defaultMessage;
|
||||
private String message;
|
||||
|
||||
private Message(String def) {
|
||||
Message(String def) {
|
||||
this.defaultMessage = def;
|
||||
}
|
||||
|
||||
private void reload(BConfig config) {
|
||||
this.message = config.getOrSet(toString().toLowerCase(), defaultMessage);
|
||||
this.message = config.getOrSet(name().toLowerCase(), defaultMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,7 @@ public enum Message {
|
|||
|
||||
public static void reloadAll(Marriage marriage) {
|
||||
BConfig config = marriage.getBukkitConfig("messages.yml");
|
||||
for(Message message : Message.values()) {
|
||||
for(Message message : values()) {
|
||||
message.reload(config);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.lenis0012.bukkit.marriage2.config;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.util.com.google.common.reflect.ClassPath;
|
||||
import net.minecraft.util.com.google.common.reflect.ClassPath.ClassInfo;
|
||||
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
|
@ -48,7 +46,7 @@ public abstract class MarriageBase implements Marriage {
|
|||
|
||||
@Override
|
||||
public BConfig getBukkitConfig(String fileName) {
|
||||
File file = new File(fileName);
|
||||
File file = new File(plugin.getDataFolder(), fileName);
|
||||
return new BConfig(this, file);
|
||||
}
|
||||
|
||||
|
@ -69,10 +67,10 @@ public abstract class MarriageBase implements Marriage {
|
|||
@SuppressWarnings("unchecked")
|
||||
protected <T> List<Class<? extends T>> findClasses(String pkg, Class<T> type, Object... params) {
|
||||
List<Class<? extends T>> list = Lists.newArrayList();
|
||||
for(ClassInfo info : classPath.getTopLevelClassesRecursive(pkg)) {
|
||||
for(ClassPath.ClassInfo info : classPath.getTopLevelClassesRecursive(pkg)) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(info.getName());
|
||||
if(type.isAssignableFrom(clazz)) {
|
||||
if(type.isAssignableFrom(clazz) && !type.equals(clazz)) {
|
||||
list.add((Class<? extends T>) clazz);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
|
|
|
@ -4,8 +4,7 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.util.com.google.common.collect.Maps;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
|
|
@ -26,7 +26,8 @@ public class MarriageCore extends MarriageBase {
|
|||
|
||||
@Register(name = "config", type = Register.Type.ENABLE, priority = 0)
|
||||
public void loadConfig() {
|
||||
plugin.saveDefaultConfig();
|
||||
// plugin.saveDefaultConfig();
|
||||
enable();
|
||||
Settings.reloadAll(this);
|
||||
Message.reloadAll(this);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.lenis0012.bukkit.marriage2.Marriage;
|
||||
|
@ -24,7 +25,9 @@ public class MarriagePlugin extends JavaPlugin {
|
|||
core = new MarriageCore(this);
|
||||
|
||||
//Scan methods
|
||||
Arrays.fill(methods, new ArrayList<Method>());
|
||||
for(int i = 0; i < methods.length; i++) {
|
||||
methods[i] = Lists.newArrayList();
|
||||
}
|
||||
scanMethods(core.getClass());
|
||||
}
|
||||
|
||||
|
@ -61,12 +64,12 @@ public class MarriagePlugin extends JavaPlugin {
|
|||
}
|
||||
|
||||
private void executeMethods(Register.Type type) {
|
||||
List<Method> list = new ArrayList<Method>(methods[type.ordinal()]);
|
||||
List<Method> list = Lists.newArrayList(methods[type.ordinal()]);
|
||||
while(!list.isEmpty()) {
|
||||
Method method = null;
|
||||
int lowestPriority = Integer.MAX_VALUE;
|
||||
for(Method m : list) {
|
||||
Register register = method.getAnnotation(Register.class);
|
||||
Register register = m.getAnnotation(Register.class);
|
||||
if(register.priority() < lowestPriority) {
|
||||
method = m;
|
||||
lowestPriority = register.priority();
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.lenis0012.bukkit.marriage2.MData;
|
||||
|
@ -48,13 +49,10 @@ public class DataManager {
|
|||
try {
|
||||
Statement statement = connection.createStatement();
|
||||
statement.executeUpdate(String.format("CREATE TABLE IF NOT EXISTS %splayers ("
|
||||
+ "id NOT NULL UNIQUE AUTO_INCREMENT,"
|
||||
+ "unique_user_id VARCHAR(128) NOT NULL UNIQUE,"
|
||||
+ "gender VARCHAR(32),"
|
||||
+ "lastlogin BIGINT,"
|
||||
+ "PRIMARY KEY (id);", prefix));
|
||||
+ "lastlogin BIGINT);", prefix));
|
||||
statement.executeUpdate(String.format("CREATE TABLE IF NOT EXISTS %sdata ("
|
||||
+ "id NOT NULL UNIQUE AUTO_INCREMENT,"
|
||||
+ "player1 VARCHAR(128) NOT NULL,"
|
||||
+ "player2 VARCHAR(128) NOT NULL,"
|
||||
+ "home_world VARCHAR(128) NOT NULL,"
|
||||
|
@ -63,8 +61,7 @@ public class DataManager {
|
|||
+ "home_z DOUBLE,"
|
||||
+ "home_yaw FLOAT,"
|
||||
+ "home_pitch FLOAT,"
|
||||
+ "pvp_enabled BIT,"
|
||||
+ "PRIMARY KEY (id);", prefix));
|
||||
+ "pvp_enabled BIT);", prefix));
|
||||
} catch (SQLException e) {
|
||||
core.getLogger().log(Level.WARNING, "Failed to load player data", e);
|
||||
} finally {
|
||||
|
@ -111,7 +108,6 @@ public class DataManager {
|
|||
ResultSet result = ps.executeQuery();
|
||||
if(result.next()) {
|
||||
// Already in database (update)
|
||||
if(!ps.isClosed()) ps.close();
|
||||
ps = connection.prepareStatement(String.format(
|
||||
"UPDATE %splayers SET gender=?,lastlogin=? WHERE unique_user_id=?;", prefix));
|
||||
ps.setString(1, player.getGender().toString());
|
||||
|
@ -120,7 +116,6 @@ public class DataManager {
|
|||
ps.executeUpdate();
|
||||
} else {
|
||||
// Not in database yet
|
||||
if(!ps.isClosed()) ps.close();
|
||||
ps = connection.prepareStatement(String.format(
|
||||
"INSERT INTO %splayers (unique_user_id,gender,lastlogin) VALUES(?,?,?);", prefix));
|
||||
ps.setString(1, player.getUniqueId().toString());
|
||||
|
@ -134,16 +129,14 @@ public class DataManager {
|
|||
MarriageData mdata = (MarriageData) player.getMarriage();
|
||||
if(mdata.getId() >= 0) {
|
||||
// Update existing entry
|
||||
if(!ps.isClosed()) ps.close();
|
||||
ps = connection.prepareStatement(String.format(
|
||||
"UPDATE %sdata SET player1=?,player2=?,home_word=?,home_x=?,home_y=?,home_z=?,home_yaw=?,home_pitch=?,pvp_enabled=? WHERE id=?;", prefix));
|
||||
mdata.save(ps);
|
||||
ps.setInt(10, mdata.getId());
|
||||
ps.executeUpdate();
|
||||
} else {
|
||||
if(!ps.isClosed()) ps.close();
|
||||
ps = connection.prepareStatement(String.format(
|
||||
"INSERT INTO %splayers (player1,player2,home_world,home_x,home_y,home_z,home_yaw,home_pitch,pvp_enabled) VALUES(?,?,?,?,?,?,?,?,?);", prefix));
|
||||
"INSERT INTO %sdata (player1,player2,home_world,home_x,home_y,home_z,home_yaw,home_pitch,pvp_enabled) VALUES(?,?,?,?,?,?,?,?,?);", prefix));
|
||||
mdata.save(ps);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
|
@ -178,16 +171,18 @@ public class DataManager {
|
|||
Connection connection = newConnection();
|
||||
try {
|
||||
// Count rows to get amount of pages
|
||||
PreparedStatement ps = connection.prepareStatement("SELECT COUNT(*) FROM " + prefix + "data;");
|
||||
PreparedStatement ps = connection.prepareStatement("SELECT COUNT(*) AS COUNT FROM " + prefix + "data;");
|
||||
ResultSet result = ps.executeQuery();
|
||||
result.next();
|
||||
int pages = (int) Math.ceil(result.getInt("COUNT") / (double) scale);
|
||||
|
||||
// Fetch te right page
|
||||
ps = connection.prepareStatement(String.format(
|
||||
"SELECT * FROM %sdata ORDER BY id DESC LIMIT %s OFFSET %s;", prefix, scale, scale * page));
|
||||
"SELECT * FROM %sdata LIMIT %s OFFSET %s;", prefix, scale, scale * page));
|
||||
//"SELECT * FROM %sdata ORDER BY id DESC LIMIT %s OFFSET %s;", prefix, scale, scale * page));
|
||||
result = ps.executeQuery();
|
||||
|
||||
List<MData> list = new ArrayList<MData>();
|
||||
List<MData> list = Lists.newArrayList();
|
||||
while(result.next()) {
|
||||
list.add(new MarriageData(result));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.util.com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.lenis0012.bukkit.marriage2.Gender;
|
||||
import com.lenis0012.bukkit.marriage2.MData;
|
||||
|
|
BIN
target/Marriage.jar
Normal file
BIN
target/Marriage.jar
Normal file
Binary file not shown.
BIN
target/classes/com/lenis0012/bukkit/marriage2/Gender$1.class
Normal file
BIN
target/classes/com/lenis0012/bukkit/marriage2/Gender$1.class
Normal file
Binary file not shown.
BIN
target/classes/com/lenis0012/bukkit/marriage2/Gender.class
Normal file
BIN
target/classes/com/lenis0012/bukkit/marriage2/Gender.class
Normal file
Binary file not shown.
BIN
target/classes/com/lenis0012/bukkit/marriage2/MData.class
Normal file
BIN
target/classes/com/lenis0012/bukkit/marriage2/MData.class
Normal file
Binary file not shown.
BIN
target/classes/com/lenis0012/bukkit/marriage2/MPlayer.class
Normal file
BIN
target/classes/com/lenis0012/bukkit/marriage2/MPlayer.class
Normal file
Binary file not shown.
BIN
target/classes/com/lenis0012/bukkit/marriage2/Marriage.class
Normal file
BIN
target/classes/com/lenis0012/bukkit/marriage2/Marriage.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/lenis0012/bukkit/marriage2/misc/BConfig.class
Normal file
BIN
target/classes/com/lenis0012/bukkit/marriage2/misc/BConfig.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
60
target/classes/plugin.yml
Normal file
60
target/classes/plugin.yml
Normal file
|
@ -0,0 +1,60 @@
|
|||
name: Marriage
|
||||
version: 2.0
|
||||
main: com.lenis0012.bukkit.marriage2.internal.MarriagePlugin
|
||||
author: lenis0012
|
||||
description: A plugin wich provides the function to start a relationship in minecraft.
|
||||
dev-url: http://dev.bukkit.org/bukkit-mods/marriage-reloaded/
|
||||
softdepend: [Vault]
|
||||
commands:
|
||||
marry:
|
||||
description: Marriage main command.
|
||||
usage: /marry <args>
|
||||
permissions:
|
||||
marry.*:
|
||||
description: Allows all Marriage Commands
|
||||
default: false
|
||||
children:
|
||||
marry.admin:
|
||||
description: Allows all admin commands
|
||||
default: false
|
||||
children:
|
||||
marry.reload:
|
||||
description: Allows to reload the config files
|
||||
defalt: op
|
||||
marry.priest:
|
||||
description: Allows player to marry 2 orther players.
|
||||
default: false
|
||||
marry.chatspy:
|
||||
description: Allows player to view all mchat.
|
||||
default: op
|
||||
marry.default:
|
||||
description: Allows default player commands
|
||||
default: true
|
||||
children:
|
||||
marry.marry:
|
||||
description: Allows to marry with players
|
||||
default: true
|
||||
marry.chat:
|
||||
description: Allows to chat with your partner
|
||||
default: true
|
||||
marry.tp:
|
||||
description: Allows to tp to your partner
|
||||
default: true
|
||||
marry.home:
|
||||
description: Allows to tp to your home if set
|
||||
default: true
|
||||
marry.sethome:
|
||||
description: Allwos to set your Marriage home
|
||||
default: true
|
||||
marry.gift:
|
||||
description: Allows to gift itesm to your partner
|
||||
default: true
|
||||
marry.chat:
|
||||
description: Allows to chat with your partner
|
||||
default: true
|
||||
marry.child:
|
||||
description: Allows everything with children in marriage.
|
||||
default: true
|
||||
marry.seen:
|
||||
description: Allows to see your last login from your partner
|
||||
default: true
|
5
target/maven-archiver/pom.properties
Normal file
5
target/maven-archiver/pom.properties
Normal file
|
@ -0,0 +1,5 @@
|
|||
#Generated by Maven
|
||||
#Tue May 26 23:56:34 CEST 2015
|
||||
version=2.0
|
||||
groupId=com.lenis0012.bukkit
|
||||
artifactId=marriage2
|
BIN
target/original-Marriage.jar
Normal file
BIN
target/original-Marriage.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue