Skip to content

Commit

Permalink
1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
hultberg committed Oct 25, 2017
1 parent 073f1f5 commit 29030df
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### 1.3.4

* Allow to configure motd.
* Allow to configure default access level.

### 1.3.3

* Log block changes in new Threads.
Expand Down
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.mittnett.reke</groupId>
<artifactId>Rekeverden</artifactId>
<version>1.3.3</version>
<version>1.3.4</version>
<developers>
<developer>
<id>thypthon</id>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>net.mittnett.reke</groupId>
<artifactId>Rekeverden</artifactId>
<version>1.3.3</version>
<version>1.3.4</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/mittnett/reke/Rekeverden/Rekeverden.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,8 @@ public UserHandler getUserHandler() {
public UserHomeHandler getUserHomeHandler() {
return this.userHomeHandler;
}

public Configuration getConfiguration() {
return this.config;
}
}
Original file line number Diff line number Diff line change
@@ -1,62 +1,82 @@
package net.mittnett.reke.Rekeverden.config;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import net.mittnett.reke.Rekeverden.Rekeverden;
import org.bukkit.configuration.file.FileConfiguration;

public class Configuration
{
protected Rekeverden plugin;
protected FileConfiguration config;

public Configuration(Rekeverden plugin)
{
this.plugin = plugin;
this.config = plugin.getConfig();
}

public void addDefaults()
{
this.config.addDefault("db.host", "");
this.config.addDefault("db.user", "");
this.config.addDefault("db.pass", "");
this.config.addDefault("db.name", "");
this.config.addDefault("db.port", 3306);

this.config.addDefault("access.default", 0);

List<String> motd = new ArrayList<>();
motd.add("Welcome to this server");
motd.add(" - Ask an admin or mod to be given access.");
this.config.addDefault("motd", motd);

this.config.options().copyDefaults(true);
}

public void save()
{
this.plugin.saveConfig();
}

public void reload()
{
this.plugin.reloadConfig();
}

public String getDatabaseHost()
{
return this.config.getString("db.host");
}

public String getDatabaseUser()
{
return this.config.getString("db.user");
}

public String getDatabasePass()
{
return this.config.getString("db.pass");
}

public String getDatabaseName()
{
return this.config.getString("db.name");
}


public int getDefaultAccess() {
return this.config.getInt("access.default");
}

public List<String> getMotdLines()
{
return this.config.getStringList("motd");
}

public int getDatabasePort()
{
return this.config.getInt("db.port");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.mittnett.reke.Rekeverden.Rekeverden;

import net.mittnett.reke.Rekeverden.config.Configuration;
import net.mittnett.reke.Rekeverden.mysql.SQLSelectResult;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
Expand All @@ -21,11 +22,13 @@ public class UserHandler implements Handler {
private final Rekeverden plugin;
private Set<User> onlineUsers;
private Set<User> localCachedUsers;
private Configuration config;

public UserHandler(Rekeverden plugin) {
this.plugin = plugin;
this.onlineUsers = new HashSet<>();
this.localCachedUsers = new HashSet<>();
this.config = plugin.getConfiguration();
}

public interface UserComparator {
Expand Down Expand Up @@ -67,7 +70,7 @@ public User loginPlayer(Player p) {
if (userExists(p.getUniqueId())) {
user = getUser(p.getUniqueId(), true);
} else {
user = createUser(p.getUniqueId(), p.getName(), User.GUEST);
user = createUser(p.getUniqueId(), p.getName(), this.config.getDefaultAccess());
}

this.updatePlayerCanPickUp(user);
Expand Down Expand Up @@ -95,7 +98,6 @@ public boolean userExists(UUID uuid) {
public User createUser(UUID uuid, String nick, int accessLevel) {
int newUserId = this.plugin.getMySQLHandler().insert("INSERT INTO `r_users`(`nick`,`uuid`,`access`,`groups`)VALUES('" + nick + "', '" + uuid.toString() + "', " + accessLevel + ", '')");


if (newUserId < 1) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.logging.Level;

import net.mittnett.reke.Rekeverden.config.Configuration;
import net.mittnett.reke.Rekeverden.handlers.UserHandler;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
Expand All @@ -26,10 +27,12 @@
public class PlayerListener implements org.bukkit.event.Listener {
public Rekeverden plugin;
private UserHandler userHandler;
private Configuration config;

public PlayerListener(Rekeverden instance) {
this.plugin = instance;
this.userHandler = instance.getUserHandler();
this.config = instance.getConfiguration();
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
Expand All @@ -41,8 +44,12 @@ public void onPlayerJoin(PlayerJoinEvent event) {
try {
User user = this.userHandler.loginPlayer(pl);

pl.sendMessage(ChatColor.GRAY + "|| " + ChatColor.GOLD + "---------- WELCOME TO Rekeverden");
pl.sendMessage(ChatColor.GRAY + "|| " + ChatColor.RESET + "Dynmap: http://mc.rekalarsen.no:8123/");
//pl.sendMessage(ChatColor.GRAY + "|| " + ChatColor.GOLD + "---------- WELCOME TO Rekeverden");
//pl.sendMessage(ChatColor.GRAY + "|| " + ChatColor.RESET + "Dynmap: http://mc.rekalarsen.no:8123/");

for (String s : this.config.getMotdLines()) {
pl.sendMessage(s);
}

if (user.getGroupInvites().size() > 0) {
pl.sendMessage(ChatColor.GRAY + "|| " + ChatColor.DARK_GREEN + "You have " + ChatColor.WHITE
Expand Down

0 comments on commit 29030df

Please sign in to comment.