mirror of
				https://github.com/CodeMC/WorldGuardWrapper.git
				synced 2025-11-04 07:02:38 +01:00 
			
		
		
		
	Make API class a singleton
This commit is contained in:
		
							parent
							
								
									8da3ac3b92
								
							
						
					
					
						commit
						2fca599c04
					
				| 
						 | 
					@ -1,20 +1,26 @@
 | 
				
			||||||
package org.codemc.worldguardwrapper;
 | 
					package org.codemc.worldguardwrapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import lombok.experimental.Delegate;
 | 
					 | 
				
			||||||
import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
 | 
					import org.codemc.worldguardwrapper.implementation.IWorldGuardImplementation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.experimental.Delegate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class WorldGuardWrapper implements IWorldGuardImplementation {
 | 
					public class WorldGuardWrapper implements IWorldGuardImplementation {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Delegate
 | 
					    @Delegate
 | 
				
			||||||
    private IWorldGuardImplementation implementation;
 | 
					    private IWorldGuardImplementation delegate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public WorldGuardWrapper() {
 | 
					    private WorldGuardWrapper() {
 | 
				
			||||||
        // TODO: better way to detect version
 | 
					        // TODO: better way to detect version
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            Class.forName("com.sk89q.worldguard.WorldGuard");
 | 
					            Class.forName("com.sk89q.worldguard.WorldGuard");
 | 
				
			||||||
            implementation = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation();
 | 
					            delegate = new org.codemc.worldguardwrapper.implementation.v7.WorldGuardImplementation();
 | 
				
			||||||
        } catch (ClassNotFoundException e) {
 | 
					        } catch (ClassNotFoundException e) {
 | 
				
			||||||
            implementation = new org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation();
 | 
					            delegate = new org.codemc.worldguardwrapper.implementation.v6.WorldGuardImplementation();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public WorldGuardWrapper getInstance() {
 | 
				
			||||||
 | 
					        return this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user